-
Notifications
You must be signed in to change notification settings - Fork 5
/
run_tests.sh
executable file
·84 lines (64 loc) · 2.08 KB
/
run_tests.sh
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
#!/bin/sh
OK_TXT="\e[1;32mOK\e[1;0m"
FAIL_TXT="\e[1;31mFAIL\e[1;0m"
SAMPLES=(indirect-calls indirect-calls-vtable loop-intensive loop mini-vm multiple singleblock hex multi-small-calls)
MODES=(pie nopie)
# Checking for processor trace support
if ! which perf 1>/dev/null 2>/dev/null;then
echo "Error: No perf binary detected. Please install perf"
exit 1
fi
if ! perf list | grep "intel_pt//" 1>/dev/null;then
echo "Error: No support for intel processor trace"
exit 1
fi
# Building the samples
echo "Building samples..."
./samples/clean.sh
./samples/build.sh
echo "Starting tests"
for folder in "${SAMPLES[@]}"
do
for mode in "${MODES[@]}"
do
rm -f trace.bin
rm -f trace.out
rm -f perf.data
# Collecting trace
echo "Testing $folder ($mode)"
PROG_PATH="./samples/$folder/prog.$mode"
./scripts/pt_trace.sh $PROG_PATH 2>/dev/null 1>/dev/null
if [ ! -f ./perf.data ]; then
echo "Error: Could not generate trace for program '$PROG_PATH'"
continue
fi
# Testing the extractor
OUTPUT=$(./wakare-extractor -binary $PROG_PATH 2>&1)
if [ $? -ne 0 ]; then
echo -e "[$FAIL_TXT] Extractor"
echo "$OUTPUT"
continue
fi
rm perf.data
echo -e "[$OK_TXT] Extractor"
# Testing the converter in text mode
OUTPUT=$(./wakare-converter -mode text 2>&1)
if [ $? -ne 0 ]; then
echo -e "[$FAIL_TXT] Converter (txt)"
echo "$OUTPUT"
continue
fi
echo -e "[$OK_TXT] Converter (txt)"
mv trace.out "./samples/$folder/trace_$mode.txt"
# Testing the converter in sqlite mode
OUTPUT=$(./wakare-converter -mode sqlite 2>&1)
if [ $? -ne 0 ]; then
echo -e "[$FAIL_TXT] Converter (sqlite)"
echo "$OUTPUT"
continue
fi
echo -e "[$OK_TXT] Converter (sqlite)"
mv trace.out "./samples/$folder/trace_$mode.db"
mv trace.bin "./samples/$folder/trace_$mode.bin"
done
done