diff options
author | Fabian Groffen <grobian@gentoo.org> | 2019-11-29 17:03:14 +0100 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2019-11-30 17:26:39 +0100 |
commit | bf1eba183f9253a9013ce36a7b0a6d72acb90038 (patch) | |
tree | 2d1e920314f164b5130635c7fea4ad6f5f1f668f /tests | |
parent | main: fix memleak for main_overlay in the correct way (diff) | |
download | portage-utils-bf1eba183f9253a9013ce36a7b0a6d72acb90038.tar.gz portage-utils-bf1eba183f9253a9013ce36a7b0a6d72acb90038.tar.bz2 portage-utils-bf1eba183f9253a9013ce36a7b0a6d72acb90038.zip |
tests: allow running all tests using valgrind
use Q_RUN_WITH_VALGRIND to run the tests using valgrind
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/init.sh.in | 10 | ||||
-rwxr-xr-x | tests/qfile/dotest | 16 | ||||
-rwxr-xr-x | tests/valgrind-wrapper/qvalgrind | 21 |
3 files changed, 39 insertions, 8 deletions
diff --git a/tests/init.sh.in b/tests/init.sh.in index 875e2af..8f52086 100644 --- a/tests/init.sh.in +++ b/tests/init.sh.in @@ -31,6 +31,16 @@ export TZ='UTC 0' # create symlinks for applets q -i -q +# inject valgrind wrapper if necessary +if [[ -n ${Q_RUN_WITH_VALGRIND} ]] ; then + chmod 755 "@abs_top_srcdir@/tests/valgrind-wrapper/qvalgrind" + for f in @abs_top_builddir@/q?* ; do + [[ -L ${f} ]] || continue + f=${f##*/} + eval "$f() { "@abs_top_srcdir@/tests/valgrind-wrapper/qvalgrind" $f \"\${@}\" ; }" + done +fi + tret=0 tpassed=0 tfailed=0 diff --git a/tests/qfile/dotest b/tests/qfile/dotest index 7769a51..023630e 100755 --- a/tests/qfile/dotest +++ b/tests/qfile/dotest @@ -6,28 +6,28 @@ export ROOT=${as}/root export Q_VDB=/ tests=( - "q file -Cq /bin/bash /bin/XXXXX" + "qfile -Cq /bin/bash /bin/XXXXX" "app-shells/bash" - "q file -Co /bin/bash /bin/XXXXX" + "qfile -Co /bin/bash /bin/XXXXX" "/bin/XXXXX" - "q file -Co -x bash /bin/bash" + "qfile -Co -x bash /bin/bash" "/bin/bash" - "q file -Co -x app-shells/bash /bin/bash" + "qfile -Co -x app-shells/bash /bin/bash" "/bin/bash" - "q file -Co -x bash:0 /bin/bash" + "qfile -Co -x bash:0 /bin/bash" "/bin/bash" - "q file -Co -x app-shells/bash:0 /bin/bash" + "qfile -Co -x app-shells/bash:0 /bin/bash" "/bin/bash" - "(cd ${ROOT}/bin; q file -RCq bash)" + "(cd ${ROOT}/bin; qfile -RCq bash)" "app-shells/bash" - "(cd ${ROOT}/; q file -Co whatever)" + "(cd ${ROOT}/; qfile -Co whatever)" "whatever" ) diff --git a/tests/valgrind-wrapper/qvalgrind b/tests/valgrind-wrapper/qvalgrind new file mode 100755 index 0000000..679c387 --- /dev/null +++ b/tests/valgrind-wrapper/qvalgrind @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# --errors-for-leak-kinds= drop possible due to Solaris libc/_findbuf +valgrind \ + --leak-check=full \ + --track-fds=yes \ + --malloc-fill=0xdb \ + --free-fill=0xbd \ + --log-file=q-valgrind.log \ + --errors-for-leak-kinds=definite \ + --error-exitcode=234 \ + "${@}" +ret=$? +if [[ ${ret} == 234 ]] ; then + mv q-valgrind.log q-valgrind.$$.log + echo "valgrind log can be found at ${PWD}/q-valgrind.$$.log" > /dev/stderr +else + rm q-valgrind.log +fi + +exit ${ret} |