]> git.saurik.com Git - apt.git/commitdiff
tests: allow to run (selfbuilt) dpkg under gdb
authorDavid Kalnischkies <david@kalnischkies.de>
Sun, 6 Sep 2015 10:35:17 +0000 (12:35 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Mon, 14 Sep 2015 13:22:18 +0000 (15:22 +0200)
Git-Dch: Ignore

test/integration/framework

index f7febafbc43dec4b9c667028c4477870d8dc7587..2e997d7f9a33b0d62aac5708ef4618c4d9a81e94 100644 (file)
@@ -199,10 +199,14 @@ gdb() {
        aptmark) CMD="apt-mark";;
        apthelper) CMD="apt-helper";;
        aptftparchive) CMD="apt-ftparchive";;
+       dpkg) shift; runapt ${TMPWORKINGDIRECTORY}/rootdir/usr/bin/gdb-dpkg "$@"; return;;
        *) CMD="$1";;
        esac
        shift
-       runapt command gdb --quiet -ex run "${BUILDDIRECTORY}/$CMD" --args "${BUILDDIRECTORY}/$CMD" "$@"
+       if [ "${CMD##*/}" = "$CMD" ]; then
+               CMD="${BUILDDIRECTORY}/${CMD}"
+       fi
+       runapt command gdb --quiet -ex run "$CMD" --args "$CMD" "$@"
 }
 
 exitwithstatus() {
@@ -322,11 +326,25 @@ if [ -r "${TMPWORKINGDIRECTORY}/noopchroot.so" ]; then
                export LD_PRELOAD="${TMPWORKINGDIRECTORY}/noopchroot.so"
        fi
 fi
-exec fakeroot dpkg --root="${TMPWORKINGDIRECTORY}/rootdir" \\
+exec fakeroot ${DPKG:-dpkg} --root="${TMPWORKINGDIRECTORY}/rootdir" \\
+       --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log \\
+       --force-not-root --force-bad-path "\$@"
+EOF
+       cat << EOF > "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/gdb-dpkg"
+#!/bin/sh
+set -e
+if [ -r "${TMPWORKINGDIRECTORY}/noopchroot.so" ]; then
+       if [ -n "\$LD_PRELOAD" ]; then
+               export LD_PRELOAD="${TMPWORKINGDIRECTORY}/noopchroot.so \${LD_PRELOAD}"
+       else
+               export LD_PRELOAD="${TMPWORKINGDIRECTORY}/noopchroot.so"
+       fi
+fi
+exec fakeroot gdb --quiet -ex run "${DPKG:-dpkg}" --args "${DPKG:-dpkg}" --root="${TMPWORKINGDIRECTORY}/rootdir" \\
        --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log \\
        --force-not-root --force-bad-path "\$@"
 EOF
-       chmod +x "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
+       chmod +x "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/gdb-dpkg"
        echo "Dir::Bin::dpkg \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg\";" > rootdir/etc/apt/apt.conf.d/99dpkg
 
        {
@@ -1285,7 +1303,7 @@ testempty() {
        msggroup 'testempty'
        msgtest "Test for no output of" "$*"
        local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
-       if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
+       if ("$@" >$COMPAREFILE 2>&1 || true) && test ! -s $COMPAREFILE; then
                msgpass
        else
                msgfailoutput '' "$COMPAREFILE" "$@"