diff --git a/afl_transforms/tools/zax/test/test_graph.sh b/afl_transforms/tools/zax/test/test_graph.sh index af4277f3de0d7e6f6c56bac0bf75ec3b3c4e5a88..f16f05b6a74f354896dcce4afd7fc392e69b5992 100755 --- a/afl_transforms/tools/zax/test/test_graph.sh +++ b/afl_transforms/tools/zax/test/test_graph.sh @@ -1,8 +1,11 @@ cd $(dirname $(realpath $0) ) + PUT=test_mystrlen.exe -MYARG="0123456789abcdef" +PUT2=test_mystrlen2.exe +MYARG="0123456789abcdef1" 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" log_msg() { @@ -40,25 +43,30 @@ build_one() build_all() { g++ test_mystrlen.cpp -o $PUT + g++ test_mystrlen2.cpp -o $PUT2 - build_one $PUT $PUT.zafl -v -t $PUT.analysis - build_one $PUT $PUT.zafl.c -c -v -t $PUT.analysis.c - build_one $PUT $PUT.zafl.g -g -v -t $PUT.analysis.g - build_one $PUT $PUT.zafl.d -d -v -t $PUT.analysis.d - build_one $PUT $PUT.zafl.d.g -d -g -v -t $PUT.analysis.d.g - build_one $PUT $PUT.zafl.c.d.g -d -g -v -t $PUT.analysis.c.d.g + for p in $PUT $PUT2 + do + 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.g -g -v -t $p.analysis.g + build_one $p $p.zafl.d -d -v -t $p.analysis.d + build_one $p $p.zafl.d.g -d -g -v -t $p.analysis.d.g + build_one $p $p.zafl.c.d.g -d -g -v -t $p.analysis.c.d.g + done } clean_all() { - rm -fr ${PUT}* + rm -fr ${PUT}* ${PUT2}* } verify_output() { - ./$PUT $MYARG TR > $PUT.output.orig + ./$PUT $MYARG > $PUT.output.orig + ./$PUT2 $MYARG > $PUT2.output.orig - for p in $ZAFL_PUT + for p in $ZAFL_PUT do echo "Program under test: $p" ./${p} $MYARG > $p.output @@ -66,7 +74,16 @@ verify_output() if [ ! $? -eq 0 ]; then log_error "output verification failure: $p.output" fi + done + for p in $ZAFL_PUT2 + do + echo "Program under test: $p" + ./${p} $MYARG > $p.output + diff $PUT2.output.orig $p.output + if [ ! $? -eq 0 ]; then + log_error "output verification failure: $p.output" + fi done log_msg "output verified" @@ -74,25 +91,28 @@ verify_output() verify_afl_map() { - for p in $ZAFL_PUT + orig_zafl=$1 + shift + all_configs=$* + for p in $all_configs do echo "Computing trace maps for input $MYARG" afl-showmap -o $p.map -- ./$p $MYARG cut -d':' -f2 $p.map | sort -r | head -n 1 > $p.max_count done - for p in $ZAFL_PUT + for p in $all_configs do - diff $PUT.zafl.max_count $p.max_count >/dev/null 2>&1 + diff $orig_zafl.zafl.max_count $p.max_count >/dev/null 2>&1 if [ $? -eq 0 ]; then - max=$(cat $PUT.zafl.max_count) - log_msg "maximum afl edge value for $PUT.zafl and $p match ($max)" + max=$(cat $orig_zafl.zafl.max_count) + log_msg "maximum afl edge value for $orig_zafl.zafl and $p match ($max)" else - echo -n "Maximum count for $PUT: " - cat $PUT.zafl.max_count + echo -n "Maximum count for $orig_zafl: " + cat $orig_zafl.zafl.max_count echo -n "Maximum count for $p: " cat $p.max_count - log_error "maximum afl edge value does not match for $PUT.zafl and $p" + log_error "maximum afl edge value does not match for $orig_zafl.zafl and $p" fi done } @@ -101,5 +121,6 @@ clean_all check_afl build_all verify_output -verify_afl_map +verify_afl_map $PUT $ZAFL_PUT +verify_afl_map $PUT2 $ZAFL_PUT2 clean_all diff --git a/afl_transforms/tools/zax/test/test_mystrlen2.cpp b/afl_transforms/tools/zax/test/test_mystrlen2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..559b408cc8fa15e8d90327800cb765bdb994d483 --- /dev/null +++ b/afl_transforms/tools/zax/test/test_mystrlen2.cpp @@ -0,0 +1,34 @@ +#include <iostream> + +using namespace std; + +int x = 0; + +volatile int identity(int x) +{ + return x; +} + +size_t my_strlen(char *arg) +{ + int count = 0; + while (*arg!='\0') + { + if (count % 99) + x *= count; + else if (count % 98) + x += count; + + count++; + arg++; + } + + return count; +} + +int main(int argc, char **argv) +{ + if (argc > 1) + cout << "length: " << my_strlen(argv[1]) << endl; + cout << "x: " << x <<endl; +} diff --git a/libzafl b/libzafl index af935c06d97490f3c8aae53aabea895e32850adf..6f6f7350dc73d7305b58353b638be10148667015 160000 --- a/libzafl +++ b/libzafl @@ -1 +1 @@ -Subproject commit af935c06d97490f3c8aae53aabea895e32850adf +Subproject commit 6f6f7350dc73d7305b58353b638be10148667015