Skip to content

Commit

Permalink
Merge pull request #208 from gemesa/tests
Browse files Browse the repository at this point in the history
Fix and improve tests
  • Loading branch information
GoGoOtaku authored Nov 28, 2023
2 parents 576c2c8 + 9e4b950 commit 84fbe8e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
Binary file added support_files/samples/hh6d.golden.exe
Binary file not shown.
11 changes: 10 additions & 1 deletion tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ arch=$(uname -m)
so=$(uname -s) # We use `-s` because `-o` is not supported on Mac OS X
so=${so#*/}
version=$(sed -n 's/^.*VERSION \"\([0-9]\.[0-9]*\)\"/\1/p' $INC_DIR/common.h)
err=0

function test_build
{
Expand All @@ -40,6 +41,7 @@ function test_binary
eval ${onsuccess}
else
eval ${onfailure}
err=1
return # Stop at error
fi
}
Expand All @@ -64,6 +66,7 @@ function test_binary_using_all_formats
eval ${onsuccess}
else
eval ${onfailure}
err=1
break # Stop at 1st error
fi
done
Expand Down Expand Up @@ -109,6 +112,7 @@ function test_binary_output_against_expected_output
eval ${onfailure}
#echo "Showing differences:"
#head -n 5 tmp.diff
err=1
return # Stop at error
fi
}
Expand Down Expand Up @@ -288,18 +292,23 @@ case "$1" in
if [ $# -ne 2 ]
then
echo "missing argument: use $0 pe32 <binary file>"
exit 1
else
test_pe32 $2
exit $err
fi
;;
"pe64")
test_pe64 ;;
test_pe64
exit $err ;;
"regression")
if [ $# -ne 2 ]
then
echo "missing argument: use $0 regression <binary file>"
exit 1
else
test_regression $2
exit $err
fi
;;
*)
Expand Down
7 changes: 4 additions & 3 deletions tests/valgrind_pedis.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

prog="valgrind -q ../src/pedis"
prog="valgrind -q ../src/build/pedis"
samples=../support_files/samples/*

n=0
Expand All @@ -9,13 +9,14 @@ for sample in $samples; do

echo -e "\n$sample"

func=$(../src/readpe -f csv -h optional "$sample" | grep Entry | cut -d, -f2)
func=$(../src/build/readpe -f csv "$sample" | grep Entry | cut -d, -f2)

for format in text csv xml html; do
$prog -f $format -F $func $sample || let err++
$prog -f $format -r $func $sample > /dev/null 2>&1 || let err++
done

let n++
done

echo "$n samples analyzed. $err errors." > /dev/fd/2
exit $err
5 changes: 3 additions & 2 deletions tests/valgrind_pepack.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/bin/bash

prog="valgrind -q ../src/pepack"
prog="valgrind -q ../src/build/pepack"
samples=../support_files/samples/*

n=0
err=0
for sample in $samples; do

echo -e "\n$sample"
$prog $sample || let err++
$prog $sample > /dev/null 2>&1 || let err++
let n++
done

echo "$n samples analyzed. $err errors." > /dev/fd/2
exit $err
5 changes: 3 additions & 2 deletions tests/valgrind_pesec.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

prog="valgrind -q ../src/pesec"
prog="valgrind -q ../src/build/pesec"
samples=../support_files/samples/*

n=0
Expand All @@ -10,10 +10,11 @@ for sample in $samples; do
echo -e "\n$sample"

for format in text csv xml html; do
$prog -f $format $sample || let err++
$prog -f $format $sample > /dev/null 2>&1 || let err++
done

let n++
done

echo "$n samples analyzed. $err errors." > /dev/fd/2
exit $err
19 changes: 10 additions & 9 deletions tests/valgrind_readpe.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

readpe="valgrind -q ../src/readpe"
samples=../support_files/samples/dep.exe
readpe="valgrind -q ../src/build/readpe"
samples=../support_files/samples/*
opts_noarg='-A -H -d -i'
opts_arg[0]='-h dos'
opts_arg[1]='-h coff'
Expand All @@ -14,25 +14,26 @@ for sample in $samples; do
echo $sample

for opt in $opts_noarg; do
$readpe $opt $sample || let err++
$readpe $opt $sample > /dev/null 2>&1 || let err++
done

for format in text csv xml html; do
for opt in $opts_noarg; do
$readpe $opt $sample || let err++
$readpe -f $format $opt $sample > /dev/null 2>&1 || let err++
done
done

for i in 0 1 2; do
$readpe ${opts_arg[i]} $sample
for format in text csv xml html; do
for opt in $opts_noarg; do
$readpe -f $format $opt $sample || let err++
$readpe ${opts_arg[i]} $sample > /dev/null 2>&1 || let err++
for format in text csv xml html; do
for opt in $opts_noarg; do
$readpe -f $format $opt ${opts_arg[i]} $sample > /dev/null 2>&1 || let err++
done
done
done
done
let n++

done

echo "$n samples analyzed. $err errors." > /dev/fd/2
exit $err

0 comments on commit 84fbe8e

Please sign in to comment.