From c155cc7132a4d4bff042bf982ee08bf142a21b5e Mon Sep 17 00:00:00 2001 From: Julian Büning Date: Thu, 6 May 2021 17:53:06 +0200 Subject: 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. --- test/Feature/FunctionPointer.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'test') 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 @@ -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; } -- cgit 1.4.1