]> git.saurik.com Git - apt.git/blobdiff - test/integration/framework
simple URI rewrite rules config for webserver
[apt.git] / test / integration / framework
index 1c4872c8e148076256af7365bb1be6f51c41ae08..9db4a1017394f0cadec34c49907ca61da27930f9 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,7 @@ msgtest() {
 }
 msgpass() { echo "${CPASS}PASS${CNORMAL}" >&2; }
 msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
-msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; }
+msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
 
 # enable / disable Debugging
 MSGLEVEL=${MSGLEVEL:-3}
@@ -113,9 +115,22 @@ gdb() {
        APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which gdb) ${BUILDDIRECTORY}/$1
 }
 
+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 +139,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
@@ -328,9 +342,15 @@ Package: $NAME" >> ${BUILDDIR}/debian/control
        fi
 
        echo '3.0 (native)' > ${BUILDDIR}/debian/source/format
-       local SRCS="$( (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._+~-]*$')"
-       for SRC in $SRCS; do
+       (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | sed -n 's#^dpkg-source: info: building [^ ]\+ in ##p' \
+               | while read SRC; do
                echo "pool/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist
+#              if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then
+#                      gpg --yes --no-default-keyring --secret-keyring ./keys/joesixpack.sec \
+#                              --keyring ./keys/joesixpack.pub --default-key 'Joe Sixpack' \
+#                              --clearsign -o "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
+#                      mv "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
+#              fi
        done
 
        for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do
@@ -466,6 +486,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
@@ -487,11 +508,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
 }
@@ -666,9 +692,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() {
@@ -690,12 +718,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
@@ -703,11 +739,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