-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5440 from thomasspriggs/tas/goto-cc-object-bits-size
Add `--object-bits` option to goto-cc
- Loading branch information
Showing
12 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
if(WIN32) | ||
set(is_windows true) | ||
else() | ||
set(is_windows false) | ||
endif() | ||
|
||
add_test_pl_tests( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $<TARGET_FILE:goto-cc> $<TARGET_FILE:cbmc> ${is_windows}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
default: tests.log | ||
|
||
include ../../src/config.inc | ||
include ../../src/common | ||
|
||
ifeq ($(BUILD_ENV_),MSVC) | ||
exe=../../../src/goto-cc/goto-cl | ||
is_windows=true | ||
else | ||
exe=../../../src/goto-cc/goto-cc | ||
is_windows=false | ||
endif | ||
|
||
test: | ||
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/cbmc/cbmc $(is_windows)' | ||
|
||
tests.log: | ||
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/cbmc/cbmc $(is_windows)' | ||
|
||
show: | ||
@for dir in *; do \ | ||
if [ -d "$$dir" ]; then \ | ||
vim -o "$$dir/*.c" "$$dir/*.out"; \ | ||
fi; \ | ||
done; | ||
|
||
clean: | ||
@for dir in *; do \ | ||
$(RM) tests.log; \ | ||
if [ -d "$$dir" ]; then \ | ||
cd "$$dir"; \ | ||
$(RM) *.out *.gb; \ | ||
cd ..; \ | ||
fi \ | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
goto_cc=$1 | ||
cbmc=$2 | ||
is_windows=$3 | ||
|
||
options=${*:4:$#-4} | ||
name=${*:$#} | ||
base_name=${name%.c} | ||
base_name=${base_name%.cpp} | ||
|
||
if [[ "${is_windows}" == "true" ]]; then | ||
"${goto_cc}" "${name}" ${options} | ||
mv "${base_name}.exe" "${base_name}.gb" | ||
else | ||
"${goto_cc}" "${name}" -o "${base_name}.gb" ${options} | ||
fi | ||
|
||
"${cbmc}" "${base_name}.gb" ${options} |
13 changes: 13 additions & 0 deletions
13
regression/goto-cc-cbmc-shared-options/object-bits/default_bits.desc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CORE | ||
test.c | ||
--function main | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
assertion object_bits != 6: SUCCESS | ||
assertion object_bits != 8: FAILURE | ||
assertion object_bits != 10: SUCCESS | ||
-- | ||
^warning: ignoring | ||
-- | ||
Test that the default value for object-bits is 8. |
14 changes: 14 additions & 0 deletions
14
regression/goto-cc-cbmc-shared-options/object-bits/fewer_bits.desc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CORE | ||
test.c | ||
--function main --object-bits 6 | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
assertion object_bits != 6: FAILURE | ||
assertion object_bits != 8: SUCCESS | ||
assertion object_bits != 10: SUCCESS | ||
-- | ||
^warning: ignoring | ||
-- | ||
Test test running with fewer bits than usual results in correct setup of | ||
intrinsic constants. |
14 changes: 14 additions & 0 deletions
14
regression/goto-cc-cbmc-shared-options/object-bits/more_bits.desc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CORE | ||
test.c | ||
--function main --object-bits 10 | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
assertion object_bits != 6: SUCCESS | ||
assertion object_bits != 8: SUCCESS | ||
assertion object_bits != 10: FAILURE | ||
-- | ||
^warning: ignoring | ||
-- | ||
Test test running with more bits than usual results in correct setup of | ||
intrinsic constants. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <assert.h> | ||
#include <stdlib.h> | ||
|
||
size_t | ||
find_first_set(const size_t max_malloc_size, const size_t bits_accumulator) | ||
{ | ||
if(max_malloc_size & 1) | ||
return bits_accumulator; | ||
return find_first_set(max_malloc_size >> 1, bits_accumulator + 1); | ||
} | ||
|
||
size_t calculate_object_bits() | ||
{ | ||
const size_t ptr_size = sizeof(void *) * 8; | ||
return ptr_size - find_first_set(__CPROVER_max_malloc_size, 1); | ||
} | ||
|
||
int main() | ||
{ | ||
void *temp = malloc(2); | ||
size_t object_bits = calculate_object_bits(); | ||
assert(object_bits != 6); | ||
assert(object_bits != 8); | ||
assert(object_bits != 10); | ||
__CPROVER_assume("end of main."); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This directory is for tests where we - | ||
1) Run `goto-cc` on the specified input file, with the specified options. | ||
2) Run `cbmc` on the goto binary produced in step 1. Using the same options | ||
from the `.desc` file as were specified in step 1. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters