diff options
-rw-r--r-- | .gitlab-ci.yml | 4 | ||||
-rw-r--r-- | debian/tests/control | 2 | ||||
-rw-r--r-- | debian/tests/run-tests | 1 | ||||
-rw-r--r-- | test/integration/framework | 63 |
4 files changed, 65 insertions, 5 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index de517c11e..93a577ad2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ test as root: - chmod -R o+rwX $PWD - ./prepare-release travis-ci - sudo -u travis mkdir -p build .ccache - - sudo -u travis env -C build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja .. + - sudo -u travis env -C build cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja .. - sudo -u travis --preserve-env=CCACHE_DIR,CCACHE_BASEDIR ninja -C build - CTEST_OUTPUT_ON_FAILURE=1 ninja -C build test - unbuffer ./test/integration/run-tests -q -j 4 @@ -34,7 +34,7 @@ test as user: - chmod -R o+rwX $PWD - ./prepare-release travis-ci - sudo -u travis mkdir -p build .ccache - - sudo -u travis env -C build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja .. + - sudo -u travis env -C build cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja .. - sudo -u travis --preserve-env=CCACHE_DIR,CCACHE_BASEDIR ninja -C build - sudo -u travis CTEST_OUTPUT_ON_FAILURE=1 ninja -C build test - sudo -u travis unbuffer ./test/integration/run-tests -q -j 4 diff --git a/debian/tests/control b/debian/tests/control index a69965db4..446f0afcc 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -7,4 +7,4 @@ Depends: @, @builddeps@, dpkg (>= 1.20.8), fakeroot, wget, stunnel4, lsof, db-ut gpgv1 | gpgv (<< 2), libfile-fcntllock-perl, python3-apt, aptitude, pkg-config, - valgrind + valgrind, gdb-minimal | gdb diff --git a/debian/tests/run-tests b/debian/tests/run-tests index 495f7edff..ff3359fae 100644 --- a/debian/tests/run-tests +++ b/debian/tests/run-tests @@ -22,4 +22,5 @@ APT_INTEGRATION_TESTS_INTERNAL_PLANNER=/usr/lib/apt/planners/apt \ APT_INTEGRATION_TESTS_BUILD_DIR=/usr/bin \ APT_INTEGRATION_TESTS_FTPARCHIVE_BIN_DIR=/usr/bin \ APT_INTEGRATION_TESTS_LIBRARY_PATH=/dev/null/does/not/exist \ +APT_INTEGRATION_TESTS_ARTIFACTS_DIR="${AUTOPKGTEST_ARTIFACTS}" \ ./test/integration/run-tests -q diff --git a/test/integration/framework b/test/integration/framework index 8c9abfbe4..1f942d162 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -307,6 +307,13 @@ find_project_binary_dir() { export PROJECT_BINARY_DIR fi } +_removetmpworkingdirectory() { + cd / + if [ -n "$TMPWORKINGDIRECTORY" -a -d "$TMPWORKINGDIRECTORY" ]; then + rm -rf "$TMPWORKINGDIRECTORY" + fi + TMPWORKINGDIRECTORY='' +} setupenvironment() { # Next check needs a gnu stat, let's figure that out early. stat=stat @@ -317,8 +324,10 @@ setupenvironment() { if [ -n "$TMPDIR" ] && [ "$(id -u)" = '0' ] && [ "$($stat --format '%a' "$TMPDIR")" != '1777' ]; then unset TMPDIR fi - TMPWORKINGDIRECTORY="$(mktemp -d)" - addtrap "cd /; rm -rf '$(escape_shell "$TMPWORKINGDIRECTORY")';" + if [ -z "$TMPWORKINGDIRECTORY" ]; then + addtrap '_removetmpworkingdirectory;' + TMPWORKINGDIRECTORY="$(mktemp -d)" + fi if [ -n "$TMPDIR_ADD" ]; then TMPWORKINGDIRECTORY="${TMPWORKINGDIRECTORY}/${TMPDIR_ADD}" mkdir -p "$TMPWORKINGDIRECTORY" @@ -361,6 +370,7 @@ setupenvironment() { APTINTERNALSOLVER="${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/solvers/apt"}" APTDUMPSOLVER="${APT_INTEGRATION_TESTS_DUMP_SOLVER:-"${BUILDDIRECTORY}/solvers/dump"}" APTINTERNALPLANNER="${APT_INTEGRATION_TESTS_INTERNAL_PLANNER:-"${BUILDDIRECTORY}/planners/apt"}" + ARTIFACTSDIR="${APT_INTEGRATION_TESTS_ARTIFACTS_DIR:-"${BUILDDIRECTORY}/artifacts"}" test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first" # ----- @@ -1778,6 +1788,52 @@ msgfailoutput() { ls -l fi catfile "$OUTPUT" + if [ "$CMD" != 'echo' ] && tail -n 1 "$OUTPUT" | grep -q '(core dumped)$'; then + local COREDUMP="${TMPWORKINGDIRECTORY}/rootdir/tmp/core.dump" + local COREEXE='' + for CORENAME in 'core' 'core.pid'; do + if [ -s "$CORENAME" ]; then + cp -a ${CORENAME} "$COREDUMP" + elif [ -s "${TMPWORKINGDIRECTORY}/${CORENAME}" ]; then + cp -a "${TMPWORKINGDIRECTORY}/${CORENAME}" "$COREDUMP" + else + continue + fi + break + done + if [ -s "$COREDUMP" ]; then + true # found already as a file + elif dpkg-checkbuilddeps -d 'systemd-coredump' /dev/null >/dev/null 2>&1; then + COREEXE="$(coredumpctl -1 --no-legend list | sed -e 's#^.* \([^ ]\+\)$#\1#')" + coredumpctl -1 dump "$COREEXE" -o "$COREDUMP" 2>/dev/null >&2 || true + else + echo '### core dump not found ###' + cat /proc/sys/kernel/core_pattern + fi + if [ -s "$COREDUMP" ]; then + if [ -z "$COREEXE" ]; then + case "$CMD" in + apt) COREEXE="${BUILDDIRECTORY}/${CMD}";; + aptftparchive) COREEXE="${APTFTPARCHIVEBINDIR}/apt-ftparchive";; + apthelper) COREEXE="${APTHELPERBINDIR}/apt-helper";; + aptwebserver) COREEXE="${APTTESTHELPERSBINDIR}/aptwebserver";; + apt*) COREEXE="${BUILDDIRECTORY}/apt-${CMD##*apt}";; + *) COREEXE="${BUILDDIRECTORY}/${CMD}";; + esac + fi + + if [ -d "${ARTIFACTSDIR}" ]; then + local ARTIFACT_COREDUMP="$(mktemp --suffix=.coredump -p "${ARTIFACTSDIR}" "${COREEXE##*/}-XXXXXX")" + cp -a "$COREDUMP" "$ARTIFACT_COREDUMP" + echo "#### coredump in $ARTIFACT_COREDUMP for $COREEXE ####" + fi + if [ -n "$COREEXE" -a -s "$COREEXE" ] && dpkg-checkbuilddeps -d 'gdb' /dev/null >/dev/null 2>&1; then + echo "#### gdb backtrace ####" + command gdb --batch -n -ex 'set pagination off' --ex 'thread apply all bt full' "$COREEXE" "$COREDUMP" || true + fi + fi + rm -f "$COREDUMP" + fi msgfail "$MSG" } @@ -1801,6 +1857,9 @@ testsuccesswithglobalerror() { if echo 'E: Can not write log (Is /dev/pts mounted?) - posix_openpt (2: No such file or directory)' \ | cmp - "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" >/dev/null 2>&1; then msgpass + elif echo 'E: Can not write log (Is /dev/pts mounted?) - posix_openpt (13: Permission denied)' \ + | cmp - "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" >/dev/null 2>&1; then + msgpass else msgfailoutput 'successful run, but output contains warnings/errors' "$OUTPUT" "$@" fi |