Skip to content

Commit 2e44dda

Browse files
committed
Enable cbmc-concurrency regression tests by default
For some reason we had not included these in our standard set of regression tests, and sure enough they got out of sync and one actual regression happened.
1 parent 98f33a7 commit 2e44dda

File tree

30 files changed

+60
-33
lines changed

30 files changed

+60
-33
lines changed

regression/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ add_subdirectory(goto-analyzer)
2929
add_subdirectory(ansi-c)
3030
add_subdirectory(goto-instrument)
3131
add_subdirectory(cpp)
32+
add_subdirectory(cbmc-concurrency)
3233
add_subdirectory(cbmc-cover)
3334
add_subdirectory(goto-instrument-typedef)
3435
add_subdirectory(smt2_solver)

regression/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ DIRS = cbmc \
77
ansi-c \
88
goto-instrument \
99
cpp \
10+
cbmc-concurrency \
1011
cbmc-cover \
1112
goto-instrument-typedef \
1213
smt2_solver \
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if(NOT WIN32)
2+
add_test_pl_tests(
3+
"$<TARGET_FILE:cbmc>"
4+
)
5+
else()
6+
add_test_pl_tests(
7+
"$<TARGET_FILE:cbmc>"
8+
"cbmc-concurrency"
9+
"$<TARGET_FILE:cbmc>"
10+
"-C;-X;pthread"
11+
"CORE"
12+
)
13+
endif()

regression/cbmc-concurrency/Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
default: tests.log
22

3+
include ../../src/config.inc
4+
include ../../src/common
5+
6+
ifeq ($(BUILD_ENV_),MSVC)
7+
no_pthread = -X pthread
8+
endif
9+
310
test:
4-
@../test.pl -c ../../../src/cbmc/cbmc
11+
@../test.pl -e -p -c ../../../src/cbmc/cbmc $(no_pthread)
512

613
tests.log: ../test.pl
7-
@../test.pl -c ../../../src/cbmc/cbmc
14+
@../test.pl -e -p -c ../../../src/cbmc/cbmc $(no_pthread)
815

916
show:
1017
@for dir in *; do \
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
CORE
22
main.c
33

4-
^EXIT=10$
4+
^EXIT=6$
55
^SIGNAL=0$
6-
^file main.c line 12 function spawn: start_thread in atomic section detected$
6+
^spawning threads out of atomic sections is not allowed
77
--
88
^warning: ignoring

regression/cbmc-concurrency/conditional_spawn1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33

44
^EXIT=10$

regression/cbmc-concurrency/deadlock1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33

44
^EXIT=0$

regression/cbmc-concurrency/deadlock2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33

44
^EXIT=10$

regression/cbmc-concurrency/malloc1/main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <stdlib.h>
2-
#include <pthread.h>
32

43
#define BUG
54

@@ -13,12 +12,9 @@ void* set_x(void* arg) {
1312
}
1413

1514
int main() {
16-
pthread_t thread;
1715
x = malloc(sizeof(int));
1816
#ifdef BUG
1917
__CPROVER_ASYNC_1: set_x(NULL);
20-
//pthread_create(&thread,NULL,set_x,NULL);
21-
//pthread_join(thread,NULL);
2218
__CPROVER_assume(set_done);
2319
#else
2420
set_x(NULL);

regression/cbmc-concurrency/malloc2/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <stdlib.h>
2-
#include <pthread.h>
32

43
_Bool set_done;
54
int *ptr;

regression/cbmc-concurrency/memory_barrier1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33
--unwind 1 --no-unwinding-assertions
44
^EXIT=0$

regression/cbmc-concurrency/memory_barrier2/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ volatile int flag1 = 0, flag2 = 0; // boolean flags
99
void* thr1(void * arg) { // frontend produces 12 transitions from this thread. It would be better if it would produce only 8!
1010
flag1 = 1;
1111
turn = 1;
12+
#ifdef __GNUC__
1213
__asm__ __volatile__ ("mfence": : :"memory");
14+
#else
15+
__CPROVER_fence("WWfence", "RRfence", "RWfence", "WRfence");
16+
#endif
1317
__CPROVER_assume(! (flag2==1 && turn==1) );
1418
// begin: critical section
1519
x = 0;
@@ -21,7 +25,11 @@ void* thr1(void * arg) { // frontend produces 12 transitions from this thread. I
2125
void* thr2(void * arg) {
2226
flag2 = 1;
2327
turn = 0;
28+
#ifdef __GNUC__
2429
__asm__ __volatile__ ("mfence": : :"memory");
30+
#else
31+
__CPROVER_fence("WWfence", "RRfence", "RWfence", "WRfence");
32+
#endif
2533
__CPROVER_assume(! (flag1==1 && turn==0) );
2634
// begin: critical section
2735
x = 1;
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--mm tso
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
77
--
88
^warning: ignoring
9+
--
10+
Some past change broke this test such that we now report verification failures.

regression/cbmc-concurrency/mutex2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33
-DMUTEX
44
^EXIT=0$

regression/cbmc-concurrency/norace_array1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
KNOWNBUG pthread
22
main.c
33

44
^EXIT=0$

regression/cbmc-concurrency/norace_array2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
KNOWNBUG pthread
22
main.c
33

44
^EXIT=0$

regression/cbmc-concurrency/norace_scalar1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33

44
^EXIT=0$

regression/cbmc-concurrency/norace_struct1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
KNOWNBUG pthread
22
main.c
33

44
^EXIT=0$

regression/cbmc-concurrency/pthread_create_tso1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33
--mm tso
44
^EXIT=0$
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
CORE
1+
CORE pthread
22
main.c
33
--all-properties
44
^EXIT=10$
55
^SIGNAL=0$
6-
^\[main\.assertion\.1\] assertion i==1: FAILURE$
7-
^\[main\.assertion\.2\] assertion i==2: SUCCESS$
6+
^\[main\.assertion\.1\] line 21 assertion i==1: FAILURE$
7+
^\[main\.assertion\.2\] line 22 assertion i==2: SUCCESS$
88
^\*\* 1 of 2 failed
99
--
1010
^warning: ignoring

regression/cbmc-concurrency/pthread_join2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33
--unwind 2
44
^EXIT=10$

regression/cbmc-concurrency/sc6/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33

44
^EXIT=0$

regression/cbmc-concurrency/svcomp13_fib_bench_longer_safe/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33
--error-label ERROR
44
^EXIT=0$

regression/cbmc-concurrency/svcomp13_fib_bench_longer_unsafe/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33
--error-label ERROR
44
^EXIT=10$

regression/cbmc-concurrency/thread_chain_posix1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33

44
^EXIT=10$

regression/cbmc-concurrency/thread_chain_posix2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
KNOWNBUG pthread
22
main.c
33
-D_ENABLE_CHAIN_ --unwind 2
44
^EXIT=0$

regression/cbmc-concurrency/thread_chain_posix3/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
KNOWNBUG pthread
22
main.c
33
-D_ENABLE_CHAIN_ -D_SANITY_CHECK_ --unwind 2
44
^EXIT=10$

regression/cbmc-concurrency/thread_local1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33

44
^EXIT=0$

regression/cbmc-concurrency/trace1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ main.c
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7-
^[[:space:]]*r2=1u \(.*\)$
7+
^[[:space:]]*r2=1u(l)? \(.*\)$
88
--
99
^warning: ignoring

regression/cbmc-concurrency/uf_with_threads1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE pthread
22
main.c
33

44
^EXIT=0$

0 commit comments

Comments
 (0)