Skip to content

Commit

Permalink
fix minor issues + move csmithedge single file script to script folder
Browse files Browse the repository at this point in the history
  • Loading branch information
karineek committed Aug 10, 2021
1 parent d0db5fc commit 37dbeb3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 40 deletions.
32 changes: 18 additions & 14 deletions AE/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CsmithEdge - AE

## Install the Tool with its requirements
Before starting, please check you have all the requirements installed.

You can do this by running this script, which will also clone Csmith into this project.
Expand All @@ -11,35 +12,37 @@ for example:
./setupReq.sh /home/user42/git
```

## Generating Tests (section 4 in general)
## Generating a Single Test Case:

CsmithEdge (regular and lazy) diff-testing with two compilers (A and B):
To generate a single test case with CsmithEdege, please use the following script (this will not invoke diff-testing scripts):
```
./gen_and_diff_testing_csmithedge.sh <base-folder> <Reg. or lazy> <compiler A> <compiler B>
/home/user42/git/CsmithEdge/scripts/CsmithEdge.sh <base-folder> <logger> <seed> <compiler A> <compiler B> <Reg. or lazy> <print-debug-information>
```
For example, diff-testing with regular CsmithEdge, clang-10 and gcc-10:
Where compiler B is required only for lazy version. For example:
```
./gen_and_diff_testing_csmithedge.sh /home/user42/git/CsmithEdge/ 0 clang-10 gcc-10
/home/user42/git/CsmithEdge/scripts/CsmithEdge.sh /home/user42/git/CsmithEdge/ single_file_gen.log 1235349863 gcc-10 clang-10 1 0
```
or lazy CsmithEdge with gcc-11 and clang-12
or
```
./gen_and_diff_testing_csmithedge.sh /home/user42/git/CsmithEdge/ 1 gcc-11 clang-12
/home/user42/git/CsmithEdge/scripts/CsmithEdge.sh /home/user42/git/CsmithEdge/ single_file_gen.log 1235349863 clang-11 clang-11 0 0
```

To generate a single test case with CsmithEdege, please use the following script (this will not invoke diff-testing scripts):
## Generating Tests (section 4.1 and 4 in general)

CsmithEdge (regular and lazy) diff-testing with two compilers (A and B):
```
/home/user42/git/CsmithEdge/scripts/CsmithEdge/CsmithEdge.sh <base-folder> <logger> <seed> <compiler A> <compiler B> <Reg. or lazy>
./gen_and_diff_testing_csmithedge.sh <base-folder> <Reg. or lazy> <compiler A> <compiler B>
```
Where compiler B is required only for lazy version. For example:
For example, diff-testing with regular CsmithEdge, clang-10 and gcc-10:
```
/home/user42/git/CsmithEdge/scripts/CsmithEdge/CsmithEdge.sh /home/user42/git/CsmithEdge/ single_file_gen.log 1235349863 gcc-10 clang-10 1
./gen_and_diff_testing_csmithedge.sh /home/user42/git/CsmithEdge/ 0 clang-10 gcc-10
```
or
or lazy CsmithEdge with gcc-11 and clang-12
```
/home/user42/git/CsmithEdge/scripts/CsmithEdge/CsmithEdge.sh /home/user42/git/CsmithEdge/ single_file_gen.log 1235349863 gcc-10 gcc-10 0
./gen_and_diff_testing_csmithedge.sh /home/user42/git/CsmithEdge/ 1 gcc-11 clang-12
```

## Rate of differential testing (Section 4.2 in the paper)
## Rate of differential testing (Section 4.2)

This section describes how to restore the results of section 4.2 in the evaluation. The scripts are currently set to run on a small set of programs. To restore similar results to what was reported in the paper, one should use a much larger set (say around 100,000 programs).

Expand Down Expand Up @@ -75,3 +78,4 @@ for example

## Coverage (Section 4.3)


12 changes: 10 additions & 2 deletions scripts/CsmithEdge/CsmithEdge.sh → scripts/CsmithEdge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ function exit_error {
echo " >> (ERROR) Testcase creation failed. <loc=$loc>"
touch $fileinvalid
clean_itr $xFolder

if [[ $debug -eq 1 ]]; then
cat $logger
fi

exit -1
}

Expand All @@ -32,9 +37,13 @@ testedCompilerB=$5
## Lazy or regular?
lazy=$6 # lazy=1

## Print Debug information
debug=$7

scripts_folder=$base/scripts/CsmithEdge
tool_location=$base/csmith

cd $scripts_folder

# Check if the first parameter is a compiler exist in the machine
var=`dpkg --list | grep -c "$testedCompilerA"`
Expand Down Expand Up @@ -73,7 +82,6 @@ rm -f $confgFile $fileinvalid $safelist $modified_testcase $logger
# Clean before start
clean_itr "$scripts_folder"


## Generate WA test-case:
if [[ "$lazy" == "0" ]] ; then
(ulimit -St 9999; ./WA1_gen_test.sh $seed $base "$temp_folder" "$logger" "$logger" $testedCompilerA) >> "$logger" 2>&1
Expand Down Expand Up @@ -106,5 +114,5 @@ fi
# cleaning
clean_itr "$scripts_folder"
# Exit
echo " >> Write test case to $modified_testcase"
echo " >> Write test case to $modified_testcase with configuration files <$confgFile,$safelist>."
exit 0
9 changes: 2 additions & 7 deletions scripts/CsmithEdge/WA1_gen_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function general_report {
testValid=1 # nothing crashed, same code, hence valid
elif [[ $diff_lines_progs == 1 ]]; then
testValid=1 # same code, two different way to reproduce it!
elif [[ $time_out_flag_edge -eq 1 ]] || [[ $same_res -eq 0 ]] ; then
elif [[ $time_out_flag_edge -eq 1 ]]; then
testValid=0 ## save time, if gets time out skips all sanitizers and checkers and marks as not-valid test
else
## Check the reports:
Expand Down Expand Up @@ -567,11 +567,9 @@ function test_single_seed {
diff_lines_progs=`diff -y --suppress-common-lines $progA $progB | wc -l`
## If the same program, then no need to validate
if [[ $diff_lines_progs -eq 0 ]]; then
## Skip --> invalid test for diff-testing
gen_RRS_mix_prob $prog $probfile_curr
echo "(same file) Skips validation for $seed"
elif [[ $diff_lines_progs -eq 1 ]]; then
## Skip --> invalid test for diff-testing
gen_RRS_mix_prob $prog $probfile_curr
echo "(same code) Skips validation for $seed"
else
Expand All @@ -590,7 +588,6 @@ function test_single_seed {
is_valid_program $tool $prog "$tool_build" ASANres2.txt MSANres2.txt UBSANres2.txt Fres2.txt
else
touch $curr_folder/ASANres2.txt $curr_folder/MSANres2.txt $curr_folder/UBSANres2.txt $framac_run_folder/Fres2.txt
## cp $curr_folder/temp_edge.c $outputF/__test_invalid$seed.c
fi
## Keep the flag regarding timeout
time_out_flag_edge=$time_out_flag
Expand All @@ -616,10 +613,8 @@ function test_single_seed {
is_valid_program $tool $prog "$tool_build" ASANres1.txt MSANres1.txt UBSANres1.txt Fres1.txt
fi
fi
else
check_plain $tool $prog $tool_build $curr_folder/Plain1.txt ## Crashed, then we just get the result
fi
touch $curr_folder/ASANres1.txt $curr_folder/MSANres1.txt $curr_folder/UBSANres1.txt $framac_run_folder/Fres1.txt
touch $curr_folder/Plain1.txt $curr_folder/ASANres1.txt $curr_folder/MSANres1.txt $curr_folder/UBSANres1.txt $framac_run_folder/Fres1.txt
## Keep the flag regarding timeout
time_out_flag_orig=$time_out_flag
fi
Expand Down
17 changes: 0 additions & 17 deletions scripts/diff_testing_rate/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--bitfields --packed-struct
0
0
0
0
0
0
-I$csmith_location/$runtime -I$csmith_location/build/runtime

0 comments on commit 37dbeb3

Please sign in to comment.