-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·77 lines (54 loc) · 1.4 KB
/
test.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
#!/bin/zsh
# Build debug (./bin/release/parse)
# make -B
# Build release (./bin/release/parse)
# make -B BUILD=release
# Test debug build
ok=0
time_cmd() {
# /usr/bin/time --format="time: %E mem-peak: %M waits: %w" $*
format='\n\treal: %e s\n\tmem-peak: %M kB'
/usr/bin/time --format="$format" $*
}
for file in sample-files/*.json; do
stderr_output=$(mktemp)
echo -n "(debug) testing with $file: "
time_cmd ./bin/debug/parse $file 1>/dev/null 2>$stderr_output
result=$?
if [ $result -ne 0 ]; then
echo -n "failed ($result) "
ok=1
else
echo -n "OK"
fi
if echo $output | grep -q "AddressSanitizer" ; then
echo -n "AddressSanitizer triggered on $file"
ok=1
fi
cat $stderr_output
echo ""
done
# Test release build
for file in sample-files/*.json; do
stderr_output=$(mktemp)
echo -n "(release) testing with $file: "
time_cmd ./bin/release/parse $file 1>/dev/null 2>$stderr_output
result=$?
if [ $result -ne 0 ]; then
echo -n "failed ($result) "
ok=1
else
echo -n "OK"
fi
cat $stderr_output
echo ""
done
# compare with python JSON.load()
stderr_output=$(mktemp)
echo -n "(release) comparing with python: "
time_cmd python3 <<EOS 1>/dev/null 2>$stderr_output
import json
print(json.load(open("sample-files/large-file.json")))
EOS
cat $stderr_output
exit $ok