-
Notifications
You must be signed in to change notification settings - Fork 32
/
valgrind-cpp_stl
executable file
·47 lines (36 loc) · 1.27 KB
/
valgrind-cpp_stl
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
#!/bin/sh -e
. ./config
if [ "$#" -ne 2 ]; then
echo "$0 <src_dir> <cpp_test_out_dir>"
exit 1
fi
SRC_DIR="$1"
CPP_TEST_OUT_DIR="$2"
OBJ_DIR="$SRC_DIR/bin"
run_valgrind() {
_attempt_no=$1
shift
_xml_file="$CPP_TEST_OUT_DIR/valgrind-${_attempt_no}.xml"
valgrind --leak-check=full --xml=yes --xml-file="${_xml_file}" "$OBJ_DIR/ks_tests" "$@"
# For some obscure reason, valgrind generates this file as 0600 (owner-readable only).
# This disrupts invocation from Docker pipeline, as after return back from the Docker container
# this will become root-owned and root-only-readable file. We fix it here.
chmod 644 "${_xml_file}"
}
read_next=1
run_attempt=0
set --
while [ -n "${read_next}" ]; do
run_attempt=$((run_attempt+1))
run_valgrind "${run_attempt}" "$@" || :
# if the `aborted_tests-{N}.txt` file is empty, then there were no aborted
# tests and it's the last attempt we need to process
read_next=
while IFS= read -r line; do
read_next=1
set -- "$@" "--run_test=!${line}"
done < "${CPP_TEST_OUT_DIR}/aborted_tests-${run_attempt}.txt"
done
# Currently, aggregate/convert_to_json only processes "valgrind.xml", so we
# make a copy with that name of the last (successful) attempt's log
cp -v "$CPP_TEST_OUT_DIR/valgrind-${run_attempt}.xml" "$CPP_TEST_OUT_DIR/valgrind.xml"