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 22:03:38 +0100
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2024-01-30 17:30:11 +0000
commit9d5bbe8a309c5760166febf7edfc3b790d77ab7e (patch)
tree6d8f74441cde360f12f3a859da856e3c35eee0bd /test
parent251b28e464921a9507f56f1d1138ff8df146888f (diff)
downloadklee-9d5bbe8a309c5760166febf7edfc3b790d77ab7e.tar.gz
On a symbolic allocation, retrieve size from a seed, if available
Diffstat (limited to 'test')
-rw-r--r--test/Feature/SeedConcretizeMalloc.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/Feature/SeedConcretizeMalloc.c b/test/Feature/SeedConcretizeMalloc.c
new file mode 100644
index 00000000..1f916723
--- /dev/null
+++ b/test/Feature/SeedConcretizeMalloc.c
@@ -0,0 +1,32 @@
+// 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=SeedGen %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 --output-dir=%t.klee-out-2 --seed-file %t.klee-out/test000001.ktest %t.bc | FileCheck --allow-empty %s
+
+#include "klee/klee.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void SeedGen() {
+  unsigned x;
+  klee_make_symbolic(&x, sizeof(x), "x");
+  klee_assume(x == 100);
+}
+
+int main(int argc, char **argv) {
+  unsigned s;
+  klee_make_symbolic(&s, sizeof(s), "size");
+  char *p = (char *)malloc(s);
+  if (!p)
+    return 0;
+
+  if (s != 100)
+    printf("Error\n");
+    // CHECK-NOT: Error
+}