Skip to content
Snippets Groups Projects
Commit f924bd13 authored by Anh Nguyen-Tuong's avatar Anh Nguyen-Tuong
Browse files

Update graph tests

parent 2ab13ef3
No related branches found
No related tags found
No related merge requests found
cd $(dirname $(realpath $0) ) cd $(dirname $(realpath $0) )
PUT=test_mystrlen.exe PUT=test_mystrlen.exe
MYARG="0123456789abcdef"
PUT2=test_mystrlen2.exe PUT2=test_mystrlen2.exe
MYARG="0123456789abcdef1" MYARG2="0123456789abcdef12345sdafdasjfadsjk"
ZAFL_PUT="$PUT.zafl $PUT.zafl.c $PUT.zafl.g $PUT.zafl.d $PUT.zafl.d.g $PUT.zafl.c.d.g" ZAFL_PUT="$PUT.zafl $PUT.zafl.c $PUT.zafl.g $PUT.zafl.d $PUT.zafl.d.g $PUT.zafl.c.d.g"
ZAFL_PUT2="$PUT2.zafl $PUT2.zafl.c $PUT2.zafl.g $PUT2.zafl.d $PUT2.zafl.d.g $PUT2.zafl.c.d.g" ZAFL_PUT2="$PUT2.zafl $PUT2.zafl.c $PUT2.zafl.g $PUT2.zafl.d $PUT2.zafl.d.g $PUT2.zafl.c.d.g"
...@@ -44,8 +45,11 @@ build_all() ...@@ -44,8 +45,11 @@ build_all()
{ {
g++ test_mystrlen.cpp -o $PUT g++ test_mystrlen.cpp -o $PUT
g++ test_mystrlen2.cpp -o $PUT2 g++ test_mystrlen2.cpp -o $PUT2
}
for p in $PUT $PUT2 zafl_all()
{
for p in $*
do do
build_one $p $p.zafl -v -t $p.analysis build_one $p $p.zafl -v -t $p.analysis
build_one $p $p.zafl.c -c -v -t $p.analysis.c build_one $p $p.zafl.c -c -v -t $p.analysis.c
...@@ -58,46 +62,41 @@ build_all() ...@@ -58,46 +62,41 @@ build_all()
clean_all() clean_all()
{ {
rm -fr ${PUT}* ${PUT2}* rm -fr ${PUT}* ${PUT2}*
} }
verify_output() verify_output()
{ {
./$PUT $MYARG > $PUT.output.orig orig_zafl=$1
./$PUT2 $MYARG > $PUT2.output.orig shift
all_configs=$*
for p in $ZAFL_PUT ./$orig_zafl $MYARG > $orig_zafl.output.orig
do
echo "Program under test: $p"
./${p} $MYARG > $p.output
diff $PUT.output.orig $p.output
if [ ! $? -eq 0 ]; then
log_error "output verification failure: $p.output"
fi
done
for p in $ZAFL_PUT2 for p in $all_configs
do do
echo "Program under test: $p" echo "Program under test: $p"
./${p} $MYARG > $p.output ./${p} $MYARG > $p.output
diff $PUT2.output.orig $p.output diff $orig_zafl.output.orig $p.output
if [ ! $? -eq 0 ]; then if [ ! $? -eq 0 ]; then
log_error "output verification failure: $p.output" log_error "output verification failure: $p.output"
fi fi
done done
log_msg "output verified" log_msg "output verified for $orig_zafl"
} }
verify_afl_map() verify_afl_map()
{ {
arg=$1
shift
orig_zafl=$1 orig_zafl=$1
shift shift
all_configs=$* all_configs=$*
for p in $all_configs for p in $all_configs
do do
echo "Computing trace maps for input $MYARG" echo "Computing trace maps for input $MYARG"
afl-showmap -o $p.map -- ./$p $MYARG afl-showmap -o $p.map -- ./$p $arg
cut -d':' -f2 $p.map | sort -r | head -n 1 > $p.max_count cut -d':' -f2 $p.map | sort -r | head -n 1 > $p.max_count
done done
...@@ -119,8 +118,15 @@ verify_afl_map() ...@@ -119,8 +118,15 @@ verify_afl_map()
clean_all clean_all
check_afl check_afl
build_all build_all
verify_output
verify_afl_map $PUT $ZAFL_PUT zafl_all $PUT
verify_afl_map $PUT2 $ZAFL_PUT2 verify_output $PUT $ZAFL_PUT
verify_afl_map $MYARG $PUT $ZAFL_PUT
zafl_all $PUT2
verify_output $PUT2 $ZAFL_PUT2
verify_afl_map $MYARG2 $PUT2 $ZAFL_PUT2
clean_all clean_all
...@@ -2,9 +2,15 @@ ...@@ -2,9 +2,15 @@
using namespace std; using namespace std;
volatile int identity(int x) int x = 0;
volatile int identity(int y)
{ {
return x; if (y % 39 == 0)
x = 1;
else
x = 2;
return y;
} }
size_t my_strlen(char *arg) size_t my_strlen(char *arg)
...@@ -23,5 +29,6 @@ size_t my_strlen(char *arg) ...@@ -23,5 +29,6 @@ size_t my_strlen(char *arg)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
if (argc > 1) if (argc > 1)
cout << "length: " << my_strlen(argv[1]) << endl; cout << "length= " << my_strlen(argv[1]) << endl;
cout << "x= " << x << endl;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment