File tree Expand file tree Collapse file tree 6 files changed +109
-0
lines changed
regression/cbmc-java-concurrency Expand file tree Collapse file tree 6 files changed +109
-0
lines changed Original file line number Diff line number Diff line change 1+ add_test_pl_tests(
2+ "$<TARGET_FILE:jbmc>"
3+ )
Original file line number Diff line number Diff line change 1+ default : tests.log
2+
3+ test :
4+ @../test.pl -p -c ../../../src/jbmc/jbmc
5+
6+ tests.log : ../test.pl
7+ @../test.pl -p -c ../../../src/jbmc/jbmc
8+
9+ show :
10+ @for dir in * ; do \
11+ if [ -d " $$ dir" ]; then \
12+ vim -o " $$ dir/*.java" " $$ dir/*.out" ; \
13+ fi ; \
14+ done ;
15+
16+ clean :
17+ find -name ' *.out' -execdir $(RM ) ' {}' \;
18+ find -name ' *.gb' -execdir $(RM ) ' {}' \;
19+ $(RM ) tests.log
20+
21+ % .class : % .java ../../src/org.cprover.jar
22+ javac -g -cp ../../src/org.cprover.jar:. $<
23+
24+ nondet_java_files := $(shell find . -name "Nondet* .java")
25+ nondet_class_files := $(patsubst % .java, % .class, $(nondet_java_files ) )
26+
27+ .PHONY : nondet-class-files
28+ nondet-class-files : $(nondet_class_files )
29+
30+ .PHONY : clean-nondet-class-files
31+ clean-nondet-class-files :
32+ -rm $(nondet_class_files )
Original file line number Diff line number Diff line change 1+ import java .lang .Thread ;
2+ import org .cprover .CProver ;
3+
4+ public class A
5+ {
6+ static int x = 0 ;
7+
8+ // verification success
9+ public void me ()
10+ {
11+ x = 5 ;
12+ CProver .startThread (333 );
13+ x = 10 ;
14+ CProver .endThread (333 );
15+ assert (x == 5 || x == 10 );
16+ }
17+
18+ // verification failed
19+ public void me2 ()
20+ {
21+ x = 5 ;
22+ CProver .startThread (333 );
23+ x = 10 ;
24+ CProver .endThread (333 );
25+ assert (x == 10 );
26+ }
27+
28+ // Known-bug, thread id mismatch, this should be detected by the conversation
29+ // process. It is currently not and thus will result in an assertion violation
30+ // during symbolic execution.
31+ public void me3 ()
32+ {
33+ x = 5 ;
34+ CProver .startThread (22333 );
35+ x = 10 ;
36+ CProver .endThread (333 );
37+ assert (x == 10 );
38+ }
39+
40+ // Known-bug, see: https://github.com/diffblue/cbmc/issues/1630
41+ public void me4 ()
42+ {
43+ int x2 = 10 ;
44+ CProver .startThread (22333 );
45+ x = x2 ;
46+ assert (x == 10 );
47+ CProver .endThread (333 );
48+ }
49+
50+ // Known-bug, symex cannot handle nested thread-blocks
51+ public void me5 ()
52+ {
53+ CProver .startThread (333 );
54+ x = 5 ;
55+ CProver .startThread (222 );
56+ x = 8 ;
57+ CProver .endThread (222 );
58+ CProver .endThread (333 );
59+ assert (x == 5 || x == 0 || x == 8 );
60+ }
61+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ A.class
3+ --function "A.me:()V" --lazy-methods --java-threading
4+
5+ ^EXIT=0$
6+ ^SIGNAL=0$
7+ ^VERIFICATION SUCCESSFUL
Original file line number Diff line number Diff line change 1+ CORE
2+ A.class
3+ --function "A.me2:()V" --lazy-methods --java-threading
4+
5+ ^SIGNAL=0$
6+ ^VERIFICATION FAILED
You can’t perform that action at this time.
0 commit comments