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

Add more graph tests

parent 2160168b
No related branches found
No related tags found
No related merge requests found
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
#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;
}
Subproject commit af935c06d97490f3c8aae53aabea895e32850adf
Subproject commit 6f6f7350dc73d7305b58353b638be10148667015
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