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

Add graph tests

parent a7843595
No related branches found
No related tags found
No related merge requests found
PUT=test_mystrlen.exe
MYARG="123456789a"
ZAFL_PUT="$PUT.zafl $PUT.zafl.c $PUT.zafl.g $PUT.zafl.d $PUT.zafl.d.g $PUT.zafl.c.d.g"
log_msg()
{
echo "TEST PASS: $1"
}
log_error()
{
echo "TEST FAIL: $1"
exit 1
}
build_one()
{
orig=$1
zafl=$2
shift
shift
zafl.sh $orig $zafl $@
if [ $? -eq 0 ]; then
log_msg "build $zafl"
else
log_error "build $zafl"
fi
}
build_all()
{
g++ test_mystrlen.cpp -o $PUT
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
}
clean_all()
{
rm -fr ${PUT}*
}
verify_output()
{
./$PUT $MYARG TR > $PUT.output.orig
for p in $ZAFL_PUT
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
log_msg "output verified"
}
verify_afl_map()
{
for p in $ZAFL_PUT
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
do
diff $PUT.zafl.max_count $p.max_count >/dev/null 2>&1
if [ $? -eq 0 ]; then
log_msg "maximum edge counter for $PUT.zafl and $p match"
else
echo -n "Maximum count for $PUT: "
cat $PUT.zafl.max_count
echo -n "Maximum count for $p: "
cat $p.max_count
log_error "maximum edge counter does not match for $PUT.zafl and $p"
fi
done
}
clean_all
build_all
verify_output
verify_afl_map
clean_all
#include <iostream>
using namespace std;
size_t my_strlen(char *arg)
{
auto count = 0;
while (*arg!='\0')
{
count++;
arg++;
}
return count;
}
int main(int argc, char **argv)
{
if (argc > 1)
cout << "length: " << my_strlen(argv[1]) << endl;
}
...@@ -833,6 +833,8 @@ int ZaxBase_t::execute() ...@@ -833,6 +833,8 @@ int ZaxBase_t::execute()
if (m_verbose) if (m_verbose)
{ {
getFileIR()->assembleRegistry();
getFileIR()->setBaseIDS();
cout << "Post transformation CFG for " << f->getName() << ":" << endl; cout << "Post transformation CFG for " << f->getName() << ":" << endl;
auto post_cfg=ControlFlowGraph_t::factory(f); auto post_cfg=ControlFlowGraph_t::factory(f);
cout << *post_cfg << endl; cout << *post_cfg << 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