File tree 11 files changed +136
-0
lines changed
goto-cc-cbmc-shared-options 11 files changed +136
-0
lines changed Original file line number Diff line number Diff line change 47
47
add_subdirectory (goto-cl)
48
48
endif ()
49
49
add_subdirectory (goto-cc-cbmc)
50
+ add_subdirectory (goto-cc-cbmc-shared-options )
50
51
add_subdirectory (cbmc-cpp)
51
52
add_subdirectory (goto-cc-goto-analyzer)
52
53
add_subdirectory (statement-list)
Original file line number Diff line number Diff line change
1
+ if (WIN32 )
2
+ set (is_windows true )
3
+ else ()
4
+ set (is_windows false )
5
+ endif ()
6
+
7
+ add_test_pl_tests(
8
+ "${CMAKE_CURRENT_SOURCE_DIR} /chain.sh $<TARGET_FILE:goto-cc> $<TARGET_FILE:cbmc> ${is_windows} "
9
+ )
Original file line number Diff line number Diff line change
1
+ default : tests.log
2
+
3
+ include ../../src/config.inc
4
+ include ../../src/common
5
+
6
+ ifeq ($(BUILD_ENV_ ) ,MSVC)
7
+ exe=../../../src/goto-cc/goto-cl
8
+ is_windows=true
9
+ else
10
+ exe=../../../src/goto-cc/goto-cc
11
+ is_windows=false
12
+ endif
13
+
14
+ test :
15
+ @../test.pl -e -p -c ' ../chain.sh $(exe) ../../../src/cbmc/cbmc $(is_windows)'
16
+
17
+ tests.log :
18
+ @../test.pl -e -p -c ' ../chain.sh $(exe) ../../../src/cbmc/cbmc $(is_windows)'
19
+
20
+ show :
21
+ @for dir in * ; do \
22
+ if [ -d " $$ dir" ]; then \
23
+ vim -o " $$ dir/*.c" " $$ dir/*.out" ; \
24
+ fi ; \
25
+ done ;
26
+
27
+ clean :
28
+ @for dir in * ; do \
29
+ $(RM ) tests.log; \
30
+ if [ -d " $$ dir" ]; then \
31
+ cd " $$ dir" ; \
32
+ $(RM ) * .out * .gb; \
33
+ cd ..; \
34
+ fi \
35
+ done
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ goto_cc=$1
4
+ cbmc=$2
5
+ is_windows=$3
6
+
7
+ options=${*: 4: $# -4}
8
+ name=${*: $# }
9
+ base_name=${name% .c}
10
+ base_name=${base_name% .cpp}
11
+
12
+ if [[ " ${is_windows} " == " true" ]]; then
13
+ " ${goto_cc} " " ${name} " ${options}
14
+ mv " ${base_name} .exe" " ${base_name} .gb"
15
+ else
16
+ " ${goto_cc} " " ${name} " -o " ${base_name} .gb" ${options}
17
+ fi
18
+
19
+ " ${cbmc} " " ${base_name} .gb" ${options}
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.c
3
+ --function main
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION FAILED$
7
+ assertion object_bits != 8: FAILURE
8
+ --
9
+ ^warning: ignoring
10
+ --
11
+ Test that the default value for object-bits is 8.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.c
3
+ --function main --object-bits 6
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION FAILED$
7
+ assertion object_bits != 6: FAILURE
8
+ --
9
+ ^warning: ignoring
10
+ --
11
+ Test test running with fewer bits than usual results in correct setup of
12
+ intrinsic constants.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.c
3
+ --function main --object-bits 10
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION FAILED$
7
+ assertion object_bits != 10: FAILURE
8
+ --
9
+ ^warning: ignoring
10
+ --
11
+ Test test running with more bits than usual results in correct setup of
12
+ intrinsic constants.
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ extern __CPROVER_size_t __CPROVER_malloc_size ;
5
+
6
+ size_t find_first_set (
7
+ const size_t max_malloc_size ,
8
+ const size_t bits_accumulator )
9
+ {
10
+ // Implemented using recursion to avoid excessive unwinding or specifying an
11
+ // unwind limit.
12
+ if (max_malloc_size & 1 )
13
+ return bits_accumulator ;
14
+ return find_first_set (max_malloc_size >> 1 , bits_accumulator + 1 );
15
+ }
16
+
17
+ size_t calculate_object_bits ()
18
+ {
19
+ const size_t ptr_size = sizeof (void * ) * 8 ;
20
+ return ptr_size - find_first_set (__CPROVER_max_malloc_size , 1 );
21
+ }
22
+
23
+ int main ()
24
+ {
25
+ void * temp = malloc (2 );
26
+ size_t object_bits = calculate_object_bits ();
27
+ assert (object_bits != 6 );
28
+ assert (object_bits != 8 );
29
+ assert (object_bits != 10 );
30
+ __CPROVER_assume ("end of main." );
31
+ }
Original file line number Diff line number Diff line change
1
+ This directory is for tests where we -
2
+ 1 ) Run ` goto-cc ` on the specified input file, with the specified options.
3
+ 2 ) Run ` cbmc ` on the goto binary produced in step 1. Using the same options
4
+ from the ` .desc ` file as were specified in step 1.
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ const char *goto_cc_options_with_separated_argument[]=
28
28
" --native-linker" ,
29
29
" --print-rejected-preprocessed-source" ,
30
30
" --mangle-suffix" ,
31
+ " --object-bits" ,
31
32
nullptr
32
33
};
33
34
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ void goto_cc_modet::help()
66
66
" --native-assembler cmd command to invoke as assembler (goto-as only)\n "
67
67
" --print-rejected-preprocessed-source file\n "
68
68
" copy failing (preprocessed) source to file\n "
69
+ " --object-bits number of bits used for object addresses\n "
69
70
" \n " ;
70
71
// clang-format on
71
72
}
You can’t perform that action at this time.
0 commit comments