-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathrun_tests
More file actions
executable file
·112 lines (99 loc) · 2.81 KB
/
run_tests
File metadata and controls
executable file
·112 lines (99 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
if [ -z "$PYTHON" ]; then
PYTHON=python3
fi
failed() {
echo "TESTS FAILED!"
exit 1
}
if [ -z "$1" -o "$1" == "unit" ]; then
echo "=== test_unit ==="
$PYTHON -m nose --version || nose_missing=1
if [ -z "$nose_missing" ]; then
$PYTHON -m nose -v || failed
fi
fi
test_roundtrip() {
echo "=== test_roundtrip ==="
for f in tests/pseudoc-roundtrip/*.lst; do
echo $f
$PYTHON ./parse_asm.py --roundtrip --addr-width=2 --inst-indent=1 $f > $f.out || failed
diff -u $f.exp $f.out || failed
done
}
test_dump_c() {
echo "=== test_dump_c ==="
for f in tests/dump-c/*.lst; do
echo $f
$PYTHON ./dump_c.py $f > $f.out || failed
diff -u $f.exp $f.out || failed
done
}
test_xform() {
echo "=== test_xform ==="
pat='*'
if [ ! -z "$1" ]; then
pat="$1"
fi
for f in tests/$pat.lst; do
echo $f
$PYTHON ./apply_xform.py --debug --annotate-calls --funcdb=none --format=none $f || failed
diff -u $f.exp.bb $f.out.bb || failed
if [ -f $f.exp.dot ]; then
diff -u $f.exp.dot $f.out.dot || failed
fi
done
}
test_decomp() {
echo "=== test_decomp ==="
for dir in tests/decomp/*; do
if [ -d $dir ]; then
echo $dir
#dir=$(dirname $f)
rm -f $dir/funcdb.yaml
$PYTHON ./apply_xform.py --log-level=WARNING --script script_decompile --format=c $dir || failed
rm -f $dir/funcdb.yaml
$PYTHON ./apply_xform.py --log-level=ERROR --script script_decompile --format=c \
--no-dead --no-comments --output-suffix=.out.clean $dir || failed
for f in $dir/*.lst; do
diff -u $f.exp $f.out || failed
diff -u $f.exp.clean $f.out.clean || failed
done
fi
done
}
test_cfg2pseudoc() {
echo "=== test_cfg2pseudoc ==="
for f in tests/cfg2pseudoc/*.dot; do
if echo $f | grep -q -E '(0|out)\.dot'; then
continue
fi
echo $f
$PYTHON ./sabl_cfg2pseudoc.py $f > $f.lst || failed
diff -u $f.lst.exp $f.lst || failed
$PYTHON ./apply_xform.py --debug --funcdb=none $f.lst >/dev/null
done
}
# Be sure to remove any older test output, to miss a case when no new output
# is produced.
find tests -name '*.out*' -exec rm {} \;
if [ -z "$1" -o "$1" == "roundtrip" ]; then
test_roundtrip
fi
if [ -z "$1" -o "$1" == "dump_c" ]; then
test_dump_c
fi
if [ -z "$1" -o "$1" == "xform" ]; then
test_xform $2
fi
if [ -z "$1" -o "$1" == "decomp" ]; then
test_decomp
fi
if [ -z "$1" -o "$1" == "cfg2pseudoc" ]; then
test_cfg2pseudoc
fi
echo "TESTS PASSED"
if [ -n "$nose_missing" ]; then
echo
echo "WARNING: unit tests were not run due to missing 'nose' package for python3"
fi