about summary refs log tree commit diff homepage
path: root/test/Feature/SeedConcretizeExtendFP.c
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2023-11-08 18:18:47 +0000
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2024-01-30 17:30:11 +0000
commit513de049a419f550198da0d96e9442579c09239c (patch)
treea6e4a974339bdd11aa280551bf304c168f8db3a0 /test/Feature/SeedConcretizeExtendFP.c
parent4e99f8f1c7a336d83168ceb07b576a63b838cb2e (diff)
downloadklee-513de049a419f550198da0d96e9442579c09239c.tar.gz
Removed --zero-seed-extension, and merge it with --allow-seed-extension. This reworked logic also fixes a buffer overflow which could be triggered during seed extension.
Diffstat (limited to 'test/Feature/SeedConcretizeExtendFP.c')
-rw-r--r--test/Feature/SeedConcretizeExtendFP.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/Feature/SeedConcretizeExtendFP.c b/test/Feature/SeedConcretizeExtendFP.c
new file mode 100644
index 00000000..6a8de589
--- /dev/null
+++ b/test/Feature/SeedConcretizeExtendFP.c
@@ -0,0 +1,33 @@
+/* This test checks the case where the seed needs to be patched on re-run */
+
+// RUN: %clang -emit-llvm -c %O0opt -g %s -o %t.bc
+// RUN: rm -rf %t.klee-out
+// RUN: %klee --output-dir=%t.klee-out --entry-point=TestGen %t.bc
+// RUN: test -f %t.klee-out/test000001.ktest
+// RUN: not test -f %t.klee-out/test000002.ktest
+
+// RUN: rm -rf %t.klee-out-2
+// RUN: %klee --exit-on-error --output-dir=%t.klee-out-2 --seed-file %t.klee-out/test000001.ktest --allow-seed-extension %t.bc 2>&1 | FileCheck %s
+
+#include "klee/klee.h"
+
+#include <assert.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+void TestGen() {
+  uint16_t x;
+  klee_make_symbolic(&x, sizeof(x), "x");
+  klee_assume(x == 1234);
+}
+
+int main() {
+  uint32_t i;
+  klee_make_symbolic(&i, sizeof(i), "i");
+
+  if (i < 5000) {
+    double d = i;
+    // CHECK: concretizing (reason: floating point)
+    assert((unsigned) d < 5001);
+  }
+}