diff options
-rw-r--r-- | test/Feature/ExtCall.c | 24 | ||||
-rw-r--r-- | test/Feature/ExtCallOverapprox.c | 26 |
2 files changed, 50 insertions, 0 deletions
diff --git a/test/Feature/ExtCall.c b/test/Feature/ExtCall.c new file mode 100644 index 00000000..5d9c0684 --- /dev/null +++ b/test/Feature/ExtCall.c @@ -0,0 +1,24 @@ +// XFAIL: * +// This test checks that symbolic arguments to a function call are correctly concretized +// RUN: %clang %s -emit-llvm %O0opt -g -c -o %t.bc + +// RUN: rm -rf %t.klee-out +// RUN: %klee --output-dir=%t.klee-out --external-calls=all --exit-on-error %t.bc 2>&1 | FileCheck %s + +#include "klee/klee.h" + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +int main() { + int x; + klee_make_symbolic(&x, sizeof(x), "x"); + klee_assume(x >= 0); + + int y = abs(x); + printf("y = %d\n", y); + // CHECK: calling external: abs((ReadLSB w32 0 x)) + + assert(x == y); +} diff --git a/test/Feature/ExtCallOverapprox.c b/test/Feature/ExtCallOverapprox.c new file mode 100644 index 00000000..83f73163 --- /dev/null +++ b/test/Feature/ExtCallOverapprox.c @@ -0,0 +1,26 @@ +// This test checks that under using the under-approximate external call policy, the symbolic arguments are left unconstrained by the external call + +// RUN: %clang %s -emit-llvm %O0opt -g -c -o %t.bc +// RUN: rm -rf %t.klee-out +// RUN: %klee --output-dir=%t.klee-out --external-calls=all %t.bc 2>&1 | FileCheck %s + +#include "klee/klee.h" + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +int main() { + int x; + klee_make_symbolic(&x, sizeof(x), "x"); + + printf("%d\n", x); + // CHECK: calling external: printf + if (x > 0) { + printf("Yes\n"); + // CHECK-DAG: Yes + } else { + printf("No\n"); + // CHECK-DAG: No + } +} |