1 |
commit: bf1eba183f9253a9013ce36a7b0a6d72acb90038 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Nov 29 16:03:14 2019 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Nov 30 16:26:39 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bf1eba18 |
7 |
|
8 |
tests: allow running all tests using valgrind |
9 |
|
10 |
use Q_RUN_WITH_VALGRIND to run the tests using valgrind |
11 |
|
12 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
13 |
|
14 |
tests/init.sh.in | 10 ++++++++++ |
15 |
tests/qfile/dotest | 16 ++++++++-------- |
16 |
tests/valgrind-wrapper/qvalgrind | 21 +++++++++++++++++++++ |
17 |
3 files changed, 39 insertions(+), 8 deletions(-) |
18 |
|
19 |
diff --git a/tests/init.sh.in b/tests/init.sh.in |
20 |
index 875e2af..8f52086 100644 |
21 |
--- a/tests/init.sh.in |
22 |
+++ b/tests/init.sh.in |
23 |
@@ -31,6 +31,16 @@ export TZ='UTC 0' |
24 |
# create symlinks for applets |
25 |
q -i -q |
26 |
|
27 |
+# inject valgrind wrapper if necessary |
28 |
+if [[ -n ${Q_RUN_WITH_VALGRIND} ]] ; then |
29 |
+ chmod 755 "@abs_top_srcdir@/tests/valgrind-wrapper/qvalgrind" |
30 |
+ for f in @abs_top_builddir@/q?* ; do |
31 |
+ [[ -L ${f} ]] || continue |
32 |
+ f=${f##*/} |
33 |
+ eval "$f() { "@abs_top_srcdir@/tests/valgrind-wrapper/qvalgrind" $f \"\${@}\" ; }" |
34 |
+ done |
35 |
+fi |
36 |
+ |
37 |
tret=0 |
38 |
tpassed=0 |
39 |
tfailed=0 |
40 |
|
41 |
diff --git a/tests/qfile/dotest b/tests/qfile/dotest |
42 |
index 7769a51..023630e 100755 |
43 |
--- a/tests/qfile/dotest |
44 |
+++ b/tests/qfile/dotest |
45 |
@@ -6,28 +6,28 @@ export ROOT=${as}/root |
46 |
export Q_VDB=/ |
47 |
|
48 |
tests=( |
49 |
- "q file -Cq /bin/bash /bin/XXXXX" |
50 |
+ "qfile -Cq /bin/bash /bin/XXXXX" |
51 |
"app-shells/bash" |
52 |
|
53 |
- "q file -Co /bin/bash /bin/XXXXX" |
54 |
+ "qfile -Co /bin/bash /bin/XXXXX" |
55 |
"/bin/XXXXX" |
56 |
|
57 |
- "q file -Co -x bash /bin/bash" |
58 |
+ "qfile -Co -x bash /bin/bash" |
59 |
"/bin/bash" |
60 |
|
61 |
- "q file -Co -x app-shells/bash /bin/bash" |
62 |
+ "qfile -Co -x app-shells/bash /bin/bash" |
63 |
"/bin/bash" |
64 |
|
65 |
- "q file -Co -x bash:0 /bin/bash" |
66 |
+ "qfile -Co -x bash:0 /bin/bash" |
67 |
"/bin/bash" |
68 |
|
69 |
- "q file -Co -x app-shells/bash:0 /bin/bash" |
70 |
+ "qfile -Co -x app-shells/bash:0 /bin/bash" |
71 |
"/bin/bash" |
72 |
|
73 |
- "(cd ${ROOT}/bin; q file -RCq bash)" |
74 |
+ "(cd ${ROOT}/bin; qfile -RCq bash)" |
75 |
"app-shells/bash" |
76 |
|
77 |
- "(cd ${ROOT}/; q file -Co whatever)" |
78 |
+ "(cd ${ROOT}/; qfile -Co whatever)" |
79 |
"whatever" |
80 |
) |
81 |
|
82 |
|
83 |
diff --git a/tests/valgrind-wrapper/qvalgrind b/tests/valgrind-wrapper/qvalgrind |
84 |
new file mode 100755 |
85 |
index 0000000..679c387 |
86 |
--- /dev/null |
87 |
+++ b/tests/valgrind-wrapper/qvalgrind |
88 |
@@ -0,0 +1,21 @@ |
89 |
+#!/usr/bin/env bash |
90 |
+ |
91 |
+# --errors-for-leak-kinds= drop possible due to Solaris libc/_findbuf |
92 |
+valgrind \ |
93 |
+ --leak-check=full \ |
94 |
+ --track-fds=yes \ |
95 |
+ --malloc-fill=0xdb \ |
96 |
+ --free-fill=0xbd \ |
97 |
+ --log-file=q-valgrind.log \ |
98 |
+ --errors-for-leak-kinds=definite \ |
99 |
+ --error-exitcode=234 \ |
100 |
+ "${@}" |
101 |
+ret=$? |
102 |
+if [[ ${ret} == 234 ]] ; then |
103 |
+ mv q-valgrind.log q-valgrind.$$.log |
104 |
+ echo "valgrind log can be found at ${PWD}/q-valgrind.$$.log" > /dev/stderr |
105 |
+else |
106 |
+ rm q-valgrind.log |
107 |
+fi |
108 |
+ |
109 |
+exit ${ret} |