]> git.saurik.com Git - apt.git/blobdiff - test/integration/framework
delete Memb on read-error in arfile
[apt.git] / test / integration / framework
index 2ef61ca84cae352b39abe2fccd2a7752c9138d7e..3a02cfb766a341bfc808cf40784cc4f32fb8e6d2 100644 (file)
@@ -1,5 +1,7 @@
 #!/bin/sh -- # no runable script, just for vi
 
+EXIT_CODE=0
+
 # we all like colorful messages
 if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null && \
    expr match "$(readlink -f /proc/$$/fd/2)" '/dev/pts/[0-9]\+' > /dev/null; then
@@ -36,7 +38,11 @@ msgtest() {
 }
 msgpass() { echo "${CPASS}PASS${CNORMAL}" >&2; }
 msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
-msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; }
+msgfail() {
+       if [ $# -gt 0 ]; then echo "${CFAIL}FAIL: $*${CNORMAL}" >&2;
+       else echo "${CFAIL}FAIL${CNORMAL}" >&2; fi
+       EXIT_CODE=$((EXIT_CODE+1));
+}
 
 # enable / disable Debugging
 MSGLEVEL=${MSGLEVEL:-3}
@@ -54,9 +60,9 @@ if [ $MSGLEVEL -le 2 ]; then
        msgpass() { echo -n " ${CPASS}P${CNORMAL}" >&2; }
        msgskip() { echo -n " ${CWARNING}S${CNORMAL}" >&2; }
        if [ -n "$CFAIL" ]; then
-               msgfail() { echo -n " ${CFAIL}FAIL${CNORMAL}" >&2; }
+               msgfail() { echo -n " ${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
        else
-               msgfail() { echo -n " ###FAILED###" >&2; }
+               msgfail() { echo -n " ###FAILED###" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
        fi
 fi
 if [ $MSGLEVEL -le 3 ]; then
@@ -112,10 +118,26 @@ gdb() {
        echo "gdb: run »$*«"
        APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which gdb) ${BUILDDIRECTORY}/$1
 }
+http() {
+       LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/methods/http
+}
+
+exitwithstatus() {
+        # error if we about to overflow, but ...
+        #   "255 failures ought to be enough for everybody"
+        if [ $EXIT_CODE -gt 255 ]; then
+            msgdie "Total failure count $EXIT_CODE too big"
+        fi
+        exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
+}
 
 addtrap() {
-       CURRENTTRAP="$CURRENTTRAP $1"
-       trap "$CURRENTTRAP exit;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+       if [ "$1" = 'prefix' ]; then
+               CURRENTTRAP="$2 $CURRENTTRAP"
+       else
+               CURRENTTRAP="$CURRENTTRAP $1"
+       fi
+       trap "$CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
 }
 
 setupenvironment() {
@@ -124,8 +146,7 @@ setupenvironment() {
        msgninfo "Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
        BUILDDIRECTORY="${TESTDIRECTORY}/../../build/bin"
        test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
-       local OLDWORKINGDIRECTORY=$(pwd)
-       addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY;"
+       addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY;"
        cd $TMPWORKINGDIRECTORY
        mkdir rootdir aptarchive keys
        cd rootdir
@@ -472,6 +493,7 @@ insertpackage() {
        local VERSION="$4"
        local DEPENDENCIES="$5"
        local PRIORITY="${6:-optional}"
+       local DESCRIPTION="${7}"
        local ARCHS=""
        for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do
                if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
@@ -493,11 +515,16 @@ Maintainer: Joe Sixpack <joe@example.org>" >> $FILE
                        echo "Version: $VERSION
 Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE
                        test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
-                       echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+                       echo -n 'Description: ' >> $FILE
+                       if [ -z "$DESCRIPTION" ]; then
+                               echo "an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
  If you find such a package installed on your system,
  YOU did something horribly wrong! They are autogenerated
- und used only by testcases for APT and surf no other propose…
-" >> $FILE
+ und used only by testcases for APT and surf no other propose…" >> $FILE
+                       else
+                               echo "$DESCRIPTION" >> $FILE
+                       fi
+                       echo >> $FILE
                done
        done
 }
@@ -672,9 +699,11 @@ setupaptarchive() {
                setupflataptarchive
        fi
        signreleasefiles
-       msgninfo "\tSync APT's cache with the archive… "
-       aptget update -qq
-       msgdone "info"
+       if [ "$1" != '--no-update' ]; then
+               msgninfo "\tSync APT's cache with the archive… "
+               aptget update -qq
+               msgdone "info"
+       fi
 }
 
 signreleasefiles() {
@@ -696,12 +725,20 @@ signreleasefiles() {
 }
 
 changetowebserver() {
-       if which weborf > /dev/null; then
-               weborf -xb aptarchive/ 2>&1 > /dev/null &
+       local LOG='/dev/null'
+       if test -x ${BUILDDIRECTORY}/aptwebserver; then
+               cd aptarchive
+               LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/aptwebserver "$@" >$LOG 2>&1 &
+               addtrap "kill $!;"
+               cd - > /dev/null
+       elif [ $# -gt 0 ]; then
+               msgdie 'Need the aptwebserver when passing arguments for the webserver'
+       elif which weborf > /dev/null; then
+               weborf -xb aptarchive/ >$LOG 2>&1 &
                addtrap "kill $!;"
        elif which gatling > /dev/null; then
                cd aptarchive
-               gatling -p 8080 -F -S 2>&1 > /dev/null &
+               gatling -p 8080 -F -S >$LOG 2>&1 &
                addtrap "kill $!;"
                cd - > /dev/null
        elif which lighttpd > /dev/null; then
@@ -709,11 +746,10 @@ changetowebserver() {
 server.port = 8080
 server.stat-cache-engine = \"disable\"" > lighttpd.conf
                lighttpd -t -f lighttpd.conf >/dev/null || msgdie 'Can not change to webserver: our lighttpd config is invalid'
-               lighttpd -D -f lighttpd.conf 2>/dev/null >/dev/null &
+               lighttpd -D -f lighttpd.conf >$LOG 2>&1 &
                addtrap "kill $!;"
        else
-               msgdie 'You have to install weborf or lighttpd first'
-               return 1
+               msgdie 'You have to build aptwerbserver or install a webserver'
        fi
        local APTARCHIVE="file://$(readlink -f ./aptarchive)"
        for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do