diff --git a/regression/snapshot-harness/function_pointer_01/main.c b/regression/snapshot-harness/function_pointer_01/main.c new file mode 100644 index 0000000000..c09357b1b3 --- /dev/null +++ b/regression/snapshot-harness/function_pointer_01/main.c @@ -0,0 +1,28 @@ +#include + +int foo(int i) +{ + return i + 1; +} + +int (*fun_ptr)(int); + +void initialize() +{ + fun_ptr = &foo; +} + +void checkpoint() +{ +} + +int main() +{ + initialize(); + checkpoint(); + + assert(fun_ptr == &foo); + assert((*fun_ptr)(5) == 6); + assert((*fun_ptr)(5) == foo(5)); + return 0; +} diff --git a/regression/snapshot-harness/function_pointer_01/test.desc b/regression/snapshot-harness/function_pointer_01/test.desc new file mode 100644 index 0000000000..025c9ef29b --- /dev/null +++ b/regression/snapshot-harness/function_pointer_01/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +fun_ptr --harness-type initialise-with-memory-snapshot --initial-goto-location main:4 +^EXIT=0$ +^SIGNAL=0$ +\[main.assertion.1\] line [0-9]+ assertion fun_ptr == \&foo: SUCCESS +\[main.assertion.2\] line [0-9]+ assertion \(\*fun_ptr\)\(5\) == 6: SUCCESS +\[main.assertion.3\] line [0-9]+ assertion \(\*fun_ptr\)\(5\) == foo\(5\): SUCCESS +VERIFICATION SUCCESSFUL +-- +^warning: ignoring diff --git a/regression/snapshot-harness/function_pointer_02/main.c b/regression/snapshot-harness/function_pointer_02/main.c new file mode 100644 index 0000000000..28a6fdd2b6 --- /dev/null +++ b/regression/snapshot-harness/function_pointer_02/main.c @@ -0,0 +1,37 @@ +#include + +int plus(int i) +{ + return i + 1; +} + +int minus(int i) +{ + return i - 1; +} + +int (*fun_ptr1)(int); +int (*fun_ptr2)(int); + +void initialize() +{ + fun_ptr1 = + + fun_ptr2 = − +} + +void checkpoint() +{ +} + +int main() +{ + initialize(); + checkpoint(); + + assert(fun_ptr1 == &plus); + assert((*fun_ptr1)(5) == 6); + assert((*fun_ptr1)(5) == plus(5)); + assert(fun_ptr2 != fun_ptr1); + assert((*fun_ptr2)(5) == 4); + return 0; +} diff --git a/regression/snapshot-harness/function_pointer_02/test.desc b/regression/snapshot-harness/function_pointer_02/test.desc new file mode 100644 index 0000000000..7fd5bdee7c --- /dev/null +++ b/regression/snapshot-harness/function_pointer_02/test.desc @@ -0,0 +1,13 @@ +CORE +main.c +fun_ptr1,fun_ptr2 --harness-type initialise-with-memory-snapshot --initial-goto-location main:4 +^EXIT=0$ +^SIGNAL=0$ +\[main.assertion.1\] line [0-9]+ assertion fun_ptr1 == \&plus: SUCCESS +\[main.assertion.2\] line [0-9]+ assertion \(\*fun_ptr1\)\(5\) == 6: SUCCESS +\[main.assertion.3\] line [0-9]+ assertion \(\*fun_ptr1\)\(5\) == plus\(5\): SUCCESS +\[main.assertion.4\] line [0-9]+ assertion fun_ptr2 \!= fun_ptr1: SUCCESS +\[main.assertion.5\] line [0-9]+ assertion \(\*fun_ptr2\)\(5\) == 4: SUCCESS +VERIFICATION SUCCESSFUL +-- +^warning: ignoring diff --git a/regression/snapshot-harness/function_pointer_03/main.c b/regression/snapshot-harness/function_pointer_03/main.c new file mode 100644 index 0000000000..968a768ebf --- /dev/null +++ b/regression/snapshot-harness/function_pointer_03/main.c @@ -0,0 +1,42 @@ +#include + +int plus(int i) +{ + return i + 1; +} + +int minus(int i) +{ + return i - 1; +} + +typedef int (*fun_ptrt)(int); +fun_ptrt fun_array[2]; + +fun_ptrt fun_ptr1; +fun_ptrt fun_ptr2; + +void initialize() +{ + fun_array[0] = + + fun_array[1] = − + fun_ptr1 = *fun_array; + fun_ptr2 = fun_array[1]; +} + +void checkpoint() +{ +} + +int main() +{ + initialize(); + checkpoint(); + + assert(fun_ptr1 == &plus); + assert((*fun_ptr1)(5) == 6); + assert((*fun_ptr1)(5) == plus(5)); + assert(fun_ptr2 != fun_ptr1); + assert((*fun_ptr2)(5) == 4); + return 0; +} diff --git a/regression/snapshot-harness/function_pointer_03/test.desc b/regression/snapshot-harness/function_pointer_03/test.desc new file mode 100644 index 0000000000..cd66bd09c6 --- /dev/null +++ b/regression/snapshot-harness/function_pointer_03/test.desc @@ -0,0 +1,13 @@ +CORE +main.c +fun_array,fun_ptr1,fun_ptr2 --harness-type initialise-with-memory-snapshot --initial-goto-location main:4 +^EXIT=0$ +^SIGNAL=0$ +\[main.assertion.1\] line [0-9]+ assertion fun_ptr1 == \&plus: SUCCESS +\[main.assertion.2\] line [0-9]+ assertion \(\*fun_ptr1\)\(5\) == 6: SUCCESS +\[main.assertion.3\] line [0-9]+ assertion \(\*fun_ptr1\)\(5\) == plus\(5\): SUCCESS +\[main.assertion.4\] line [0-9]+ assertion fun_ptr2 \!= fun_ptr1: SUCCESS +\[main.assertion.5\] line [0-9]+ assertion \(\*fun_ptr2\)\(5\) == 4: SUCCESS +VERIFICATION SUCCESSFUL +-- +^warning: ignoring