about summary refs log tree commit diff homepage
path: root/test
diff options
context:
space:
mode:
authorJulian Büning <julian.buening@comsys.rwth-aachen.de>2021-05-06 17:53:06 +0200
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2021-05-10 17:48:34 +0100
commitc155cc7132a4d4bff042bf982ee08bf142a21b5e (patch)
tree9de07107a954efc78b913e4b9fa45d9c8d7b1c90 /test
parent41e84de8c64f15526f33e0b9769a9e6f0b861c44 (diff)
downloadklee-c155cc7132a4d4bff042bf982ee08bf142a21b5e.tar.gz
extend function pointer test
Part of the test was already disabled in the initial checkin.
However, we do support function pointers if they are restricted to
one or more possible values.
Diffstat (limited to 'test')
-rw-r--r--test/Feature/FunctionPointer.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/test/Feature/FunctionPointer.c b/test/Feature/FunctionPointer.c
index bed9ad5e..649946dc 100644
--- a/test/Feature/FunctionPointer.c
+++ b/test/Feature/FunctionPointer.c
@@ -1,6 +1,8 @@
-// RUN: %clang %s -emit-llvm -g -c -o %t1.bc
+// RUN: %clang %s -emit-llvm -g -c -o %t.bc
 // RUN: rm -rf %t.klee-out
-// RUN: %klee --output-dir=%t.klee-out --write-no-tests --exit-on-error %t1.bc
+// RUN: %klee --output-dir=%t.klee-out --write-no-tests --exit-on-error %t.bc 2>&1 | FileCheck %s
+
+#include "klee/klee.h"
 
 #include <stdio.h>
 
@@ -15,23 +17,35 @@ int main(int argc, char **argv) {
   void (*fp)(const char *) = foo;
 
   printf("going to call through fp\n");
+  // CHECK: foo: called via fp
   fp("called via fp");
 
   printf("calling via pass through\n");
+  // CHECK: foo: called via bar
   bar(foo);
-        
+
   fp = baz;
+  // CHECK: baz: called via fp
   fp("called via fp");
 
+  // CHECK: foo: called via xx
   xx("called via xx");
 
-#if 0
   klee_make_symbolic(&fp, sizeof fp, "fp");
   if(fp == baz) {
+    // CHECK: baz: calling via simple symbolic!
     printf("fp = %p, baz = %p\n", fp, baz);
-    fp("calling via symbolic!");
+    fp("calling via simple symbolic!");
+    return 0;
+  }
+
+  void (*fp2)(const char *);
+  klee_make_symbolic(&fp2, sizeof fp2, "fp2");
+  if(fp2 == baz || fp2 == foo) {
+    // CHECK-DAG: baz: calling via symbolic!
+    // CHECK-DAG: foo: calling via symbolic!
+    fp2("calling via symbolic!");
   }
-#endif
 
   return 0;
 }