about summary refs log tree commit diff homepage
path: root/test
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2023-10-20 16:58:26 +0100
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2024-01-30 17:30:11 +0000
commitcbf10dbdd7345434e0ec74526ec3ca3d0391797a (patch)
treed3fe2ecf35d427d477159b14591f36bae6908c3e /test
parent72b6207d49ce204b13dc2017033211f1b2cbd935 (diff)
downloadklee-cbf10dbdd7345434e0ec74526ec3ca3d0391797a.tar.gz
Concretize constants using seed values, when available. Added two tests (w/ and w/o seed extension) based on FP concretization.
Diffstat (limited to 'test')
-rw-r--r--test/Feature/SeedConcretizeFP.c27
-rw-r--r--test/Feature/SeedConcretizePatchedFP.c33
2 files changed, 60 insertions, 0 deletions
diff --git a/test/Feature/SeedConcretizeFP.c b/test/Feature/SeedConcretizeFP.c
new file mode 100644
index 00000000..bc5246ad
--- /dev/null
+++ b/test/Feature/SeedConcretizeFP.c
@@ -0,0 +1,27 @@
+// RUN: %clang -emit-llvm -c -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 %t.bc 2>&1 | FileCheck %s
+
+#include "klee/klee.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+void TestGen() {
+  unsigned x;
+  klee_make_symbolic(&x, sizeof(x), "x");
+  klee_assume(x == 12345678);
+}
+
+int main() {
+  unsigned i;
+  klee_make_symbolic(&i, sizeof(i), "i");
+  double d = i;
+  // CHECK: concretizing (reason: floating point)
+  assert((unsigned) d == 12345678);
+}
diff --git a/test/Feature/SeedConcretizePatchedFP.c b/test/Feature/SeedConcretizePatchedFP.c
new file mode 100644
index 00000000..b8b758b5
--- /dev/null
+++ b/test/Feature/SeedConcretizePatchedFP.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 --zero-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);
+  }
+}