Skip to content

Commit ec06f44

Browse files
author
Lefan Zhang
authored
Merge pull request diffblue#5 from lefanz-amazon/abst-test-script
test: add script to test all abstractions
2 parents 8a95d32 + d3a012b commit ec06f44

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

regression/abstraction/test.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
# whether verify the program or not
4+
CHECK=false
5+
6+
# paths to the benchmark repos
7+
AWS_C_COMMON_PATH="/home/ubuntu/aws-c-common"
8+
AWS_IOT_SDK_PATH="/home/ubuntu/aws-iot-device-sdk-embedded-C-tuttle"
9+
10+
# executables
11+
MAKE="make"
12+
GOTO_INSTRUMENT="goto-instrument"
13+
CBMC="cbmc"
14+
CBMC_FLAGS="--unwind 10
15+
--bounds-check
16+
--pointer-check
17+
--unwinding-assertions
18+
--nondet-static
19+
--div-by-zero-check
20+
--float-overflow-check
21+
--nan-check
22+
--pointer-overflow-check
23+
--undefined-shift-check
24+
--signed-overflow-check
25+
--unsigned-overflow-check
26+
--trace"
27+
28+
AWS_C_COMMON_TESTS=(
29+
"aws_array_eq"
30+
"aws_array_eq_c_str_ignore_case"
31+
"aws_array_eq_ignore_case"
32+
"aws_array_list_comparator_string"
33+
"aws_array_list_front"
34+
"aws_array_list_get_at"
35+
"aws_array_list_pop_back"
36+
)
37+
38+
AWS_IOT_SDK_TEST="skip_string"
39+
40+
cwd=$(pwd)
41+
for test in ${AWS_C_COMMON_TESTS[@]}; do
42+
echo "===== $test ====="
43+
cd $AWS_C_COMMON_PATH/.cbmc-batch/jobs/$test/
44+
# compile program into goto-programs
45+
$MAKE goto 2&>1
46+
echo "Goto programs built"
47+
cd $cwd
48+
# run goto-instrument to make abstracted goto-programs
49+
$GOTO_INSTRUMENT --use-abstraction $cwd/$test.json \
50+
$AWS_C_COMMON_PATH/.cbmc-batch/jobs/$test/${test}_harness.goto \
51+
$AWS_C_COMMON_PATH/.cbmc-batch/jobs/$test/${test}_harness_abst.goto
52+
# print the goto-programs into txts
53+
rm $AWS_C_COMMON_PATH/.cbmc-batch/jobs/$test/${test}_harness_abst.txt
54+
$GOTO_INSTRUMENT --print-internal-representation \
55+
$AWS_C_COMMON_PATH/.cbmc-batch/jobs/$test/${test}_harness_abst.goto \
56+
>> $AWS_C_COMMON_PATH/.cbmc-batch/jobs/$test/${test}_harness_abst.txt
57+
# check the program
58+
if [ $CHECK = true ]; then
59+
$CBMC $CBMC_FLAGS $AWS_C_COMMON_PATH/.cbmc-batch/jobs/$test/${test}_harness_abst.goto
60+
fi
61+
done
62+
63+
echo "===== $AWS_IOT_SDK_TEST ====="
64+
cd $AWS_IOT_SDK_PATH/cbmc/proofs/JsonParser/proofs
65+
# compile program into goto-programs
66+
$MAKE goto ENTRY=String 2&>1
67+
cd $cwd
68+
# run goto-instrument to make abstracted goto-programs
69+
$GOTO_INSTRUMENT --use-abstraction $cwd/$AWS_IOT_SDK_TEST.json \
70+
$AWS_IOT_SDK_PATH/cbmc/proofs/JsonParser/proofs/String.goto \
71+
$AWS_IOT_SDK_PATH/cbmc/proofs/JsonParser/proofs/String_abst.goto
72+
# print the goto-programs into txts
73+
rm $AWS_IOT_SDK_PATH/cbmc/proofs/JsonParser/proofs/String_abst.txt
74+
$GOTO_INSTRUMENT --print-internal-representation \
75+
$AWS_IOT_SDK_PATH/cbmc/proofs/JsonParser/proofs/String_abst.goto \
76+
>> $AWS_IOT_SDK_PATH/cbmc/proofs/JsonParser/proofs/String_abst.txt
77+
# check the program
78+
if [ $CHECK = true ]; then
79+
$CBMC $CBMC_FLAGS $AWS_IOT_SDK_PATH/cbmc/proofs/JsonParser/proofs/String_abst.goto
80+
fi

0 commit comments

Comments
 (0)