-
Notifications
You must be signed in to change notification settings - Fork 0
/
grind_test.sh
executable file
·55 lines (44 loc) · 1.1 KB
/
grind_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
#!/usr/bin/env bash
main() {
local target="$1"
if [ -z "$target" ]; then
echo "No target specified."
exit 1
fi
local log_file="$2"
if [ -z "$log_file" ]; then
echo "No log file specified."
exit 1
fi
echo valgrind --leak-check=full --track-origins=yes --log-file=\"$log_file\" \"$target\"
if valgrind --leak-check=full --track-origins=yes --log-file="$log_file" "$target"; then
local exit_ok="1"
else
local exit_ok=""
fi
local no_leaks=$(grep -i -e 'in use at exit: 0 bytes' "$log_file")
local no_errors=$(grep -i -e 'ERROR SUMMARY: 0 errors' "$log_file")
local rtld_failed=$(grep -i -e 'dl_rtld_map.*failed' "$log_file")
local is_incons=$(grep -i -e 'Inconsistency' "$log_file")
local is_err=""
if [ -n "$is_incons" ]; then
local is_err="1"
fi
if [ -n "$rtld_assertion" ]; then
local is_err="1"
fi
if [ -z "$no_leaks" ]; then
local is_err="1"
fi
if [ -z "$no_errors" ]; then
local is_err="1"
fi
if [ "$is_err" == "1" ]; then
cat "$log_file"
exit 1;
fi
if [ -z "$exit_ok" ]; then
exit 1;
fi
}
main "$1" "$2"