This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.sh
executable file
·59 lines (44 loc) · 1.46 KB
/
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
#!/usr/bin/env bash
set -e
compile() {
flags=($(./configure 2>&1 |
grep -- '--' |
awk '{print $1}' |
grep -v -e install -e config -e help))
for ((length = 1; length <= "${#flags[@]}"; ++length)); do
for ((start = 0; start + length <= "${#flags[@]}"; ++start)); do
_flags=(${flags[@]:start:length})
log "Configuring with ${_flags[*]}..."
./configure ${_flags[@]}
log "Compiling with $CFLAGS..."
make clean
make
log "Running $1..."
eval "$1"
done
done
}
log() {
echo -e "\n * $1\n" >&2
}
main() {
log_file="${LOGFILE:-valgrind.log}"
tools=(memcheck cachegrind callgrind helgrind drd massif dhat lackey none exp-bbv)
base_cmd='valgrind --trace-children=yes --log-file=valgrind.log --error-exitcode=1'
end_cmd="head -n 1 -- '$log_file' && exit 127"
for tool in "${tools[@]}"; do
log "Trying valgrind tool $tool"
case "$tool" in
memcheck) opt='--leak-check=full --show-leak-kinds=all --track-origins=yes --expensive-definedness-checks=yes' ;;
cachegrind) opt='--branch-sim=yes' ;;
drd) opt='--check-stack-var=yes --free-is-write=yes' ;;
massif) opt='--stacks=yes' ;;
*) opt='' ;;
esac
compile "$base_cmd $opt --tool='$tool' -s ./yafetch || ($end_cmd)"
log 'Cleaning up'
rm -rf ./*.out.*
make clean
done
}
main "$@"