]> git.saurik.com Git - apt.git/blobdiff - test/integration/framework
Merge remote-tracking branch 'mvo/debian/sid' into debian/experimental-no-abi-break
[apt.git] / test / integration / framework
index d899bb574ac4c74825fb37eeaa26b432f9a647e3..ca2f9005054d7b4d890a2a4cb654ad406c63d76f 100644 (file)
@@ -99,9 +99,13 @@ aptconfig() { runapt apt-config $*; }
 aptcache() { runapt apt-cache $*; }
 aptcdrom() { runapt apt-cdrom $*; }
 aptget() { runapt apt-get $*; }
+apt() { runapt apt $*; }
 aptftparchive() { runapt apt-ftparchive $*; }
 aptkey() { runapt apt-key $*; }
 aptmark() { runapt apt-mark $*; }
+aptwebserver() {
+  LD_LIBRARY_PATH=${APTWEBSERVERBINDIR} ${APTWEBSERVERBINDIR}/aptwebserver $*;
+}
 dpkg() {
        $(which dpkg) --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log $*
 }
@@ -116,7 +120,7 @@ aptitude() {
 }
 gdb() {
        echo "gdb: run »$*«"
-       APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which gdb) ${BUILDDIRECTORY}/$1
+       APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which gdb) ${BUILDDIRECTORY}/$1 --args $*
 }
 http() {
        LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/methods/http
@@ -154,8 +158,14 @@ setupenvironment() {
        TMPWORKINGDIRECTORY=$(mktemp -d)
        TESTDIRECTORY=$(readlink -f $(dirname $0))
        msgninfo "Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
-       BUILDDIRECTORY="${TESTDIRECTORY}/../../build/bin"
+
+        # allow overriding the default BUILDDIR location
+       BUILDDIRECTORY=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"}
+        METHODSDIR=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}
+        APTWEBSERVERBINDIR=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"}
        test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
+        # -----
+
        addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY;"
        cd $TMPWORKINGDIRECTORY
        mkdir rootdir aptarchive keys
@@ -181,7 +191,7 @@ setupenvironment() {
        echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
        echo "Debug::NoLocking \"true\";" >> aptconfig.conf
        echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
-       echo "Dir::Bin::Methods \"${BUILDDIRECTORY}/methods\";" >> aptconfig.conf
+       echo "Dir::Bin::Methods \"${METHODSDIR}\";" >> aptconfig.conf
        echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
        echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
        echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
@@ -192,6 +202,8 @@ setupenvironment() {
        fi
        echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
        echo 'quiet::NoUpdate "true";' >> aptconfig.conf
+       echo "Acquire::https::CaInfo \"${TESTDIR}/apt.pem\";" > rootdir/etc/apt/apt.conf.d/99https
+        echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir/etc/apt/apt.conf.d/apt-binary
        export LC_ALL=C
        export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
        configcompression '.' 'gz' #'bz2' 'lzma' 'xz'
@@ -278,7 +290,7 @@ setupsimplenativepackage() {
        local VERSION="$3"
        local RELEASE="${4:-unstable}"
        local DEPENDENCIES="$5"
-       local DESCRIPTION="${6:-"Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+       local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
  If you find such a package installed on your system,
  something went horribly wrong! They are autogenerated
  und used only by testcases and surf no other propose…"}"
@@ -328,13 +340,14 @@ buildsimplenativepackage() {
        local VERSION="$3"
        local RELEASE="${4:-unstable}"
        local DEPENDENCIES="$5"
-       local DESCRIPTION="${6:-"Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+       local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
  If you find such a package installed on your system,
  something went horribly wrong! They are autogenerated
  und used only by testcases and surf no other propose…"}"
 
        local SECTION="${7:-others}"
        local PRIORITY="${8:-optional}"
+        local FILE_TREE="$9"
        local DISTSECTION
        if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
                DISTSECTION="main"
@@ -391,9 +404,12 @@ Package: $NAME" >> ${BUILDDIR}/debian/control
                mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
                cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME}
                cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin/${NAME}-${arch}
+                if [ -n "$FILE_TREE" ]; then
+                    cp -ar "$FILE_TREE" ${BUILDDIR}/debian/tmp
+                fi
+
                (cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$arch)
                (cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
-
                dpkg-deb --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/.. 2> /dev/null > /dev/null
                echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist
        done
@@ -521,7 +537,7 @@ insertpackage() {
        local VERSION="$4"
        local DEPENDENCIES="$5"
        local PRIORITY="${6:-optional}"
-       local DESCRIPTION="${7:-"Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+       local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
  If you find such a package installed on your system,
  something went horribly wrong! They are autogenerated
  und used only by testcases and surf no other propose…"}"
@@ -581,7 +597,7 @@ insertinstalledpackage() {
        local DEPENDENCIES="$4"
        local PRIORITY="${5:-optional}"
        local STATUS="${6:-install ok installed}"
-       local DESCRIPTION="${7:-"Description: an autogenerated dummy ${NAME}=${VERSION}/installed
+       local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
  If you find such a package installed on your system,
  something went horribly wrong! They are autogenerated
  und used only by testcases and surf no other propose…"}"
@@ -787,6 +803,22 @@ signreleasefiles() {
        msgdone "info"
 }
 
+webserverconfig() {
+       msgtest "Set webserver config option '${1}' to" "$2"
+       downloadfile "http://localhost:8080/_config/set/${1}/${2}" '/dev/null' >/dev/null
+       local DOWNLOG='download-testfile.log'
+       rm -f "$DOWNLOG"
+       local STATUS="$(mktemp)"
+       addtrap "rm $STATUS;"
+       downloadfile "http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG"
+       if [ "$(cat "$STATUS")" = '200' ]; then
+               msgpass
+       else
+               cat >&2 "$DOWNLOG"
+               msgfail "Statuscode was $(cat "$STATUS")"
+       fi
+}
+
 rewritesourceslist() {
        local APTARCHIVE="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
        for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
@@ -795,10 +827,15 @@ rewritesourceslist() {
 }
 
 changetowebserver() {
+       if [ "$1" != '--no-rewrite' ]; then
+               rewritesourceslist 'http://localhost:8080/'
+       else
+               shift
+       fi
        local LOG='/dev/null'
-       if test -x ${BUILDDIRECTORY}/aptwebserver; then
+       if test -x ${APTWEBSERVERBINDIR}/aptwebserver; then
                cd aptarchive
-               LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/aptwebserver -o aptwebserver::fork=1 "$@" >$LOG 2>&1
+               aptwebserver -o aptwebserver::fork=1 "$@" >$LOG 2>&1
                local PID="$(cat aptwebserver.pid)"
                if [ -z "$PID" ]; then
                        msgdie 'Could not fork aptwebserver successfully'
@@ -808,9 +845,6 @@ changetowebserver() {
        else
                msgdie 'You have to build aptwerbserver or install a webserver'
        fi
-       if [ "$1" != '--no-rewrite' ]; then
-               rewritesourceslist 'http://localhost:8080/'
-       fi
 }
 
 changetohttpswebserver() {
@@ -822,6 +856,7 @@ changetohttpswebserver() {
        fi
        echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid
 cert = ${TESTDIRECTORY}/apt.pem
+output = /dev/null
 
 [https]
 accept = 4433
@@ -916,11 +951,20 @@ testempty() {
 }
 
 testequal() {
+       local MSG='Test of equality of'
+       if [ "$1" = '--nomsg' ]; then
+               MSG=''
+               shift
+       fi
+
        local COMPAREFILE=$(mktemp)
        addtrap "rm $COMPAREFILE;"
        echo "$1" > $COMPAREFILE
        shift
-       msgtest "Test for equality of" "$*"
+
+       if [ -n "$MSG" ]; then
+               msgtest "$MSG" "$*"
+       fi
        $* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
 }