]> git.saurik.com Git - apt.git/blobdiff - test/integration/framework
build test-binaries by default and add a test target to toplevel
[apt.git] / test / integration / framework
index 013a71ec02cbcf0515ecd449e64ba015f70401e7..ccab010e6bc2a32758a8fb79228c8f3977d01446 100644 (file)
@@ -145,11 +145,13 @@ setupenvironment() {
        echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
        echo 'quiet::NoUpdate "true";' >> aptconfig.conf
        export LC_ALL=C
+       export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
        msgdone "info"
 }
 
 configarchitecture() {
        local CONFFILE=rootdir/etc/apt/apt.conf.d/01multiarch.conf
+       rm -f $CONFFILE
        echo "APT::Architecture \"$1\";" > $CONFFILE
        shift
        while [ -n "$1" ]; do
@@ -218,6 +220,7 @@ buildsimplenativepackage() {
        local DEPENDENCIES="$5"
        local DESCRIPTION="$6"
        local SECTION="${7:-others}"
+       local PRIORITY="${8:-optional}"
        local DISTSECTION
        if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
                DISTSECTION="main"
@@ -240,7 +243,7 @@ echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME}
  -- Joe Sixpack <joe@example.org>  $(date -R)" > ${BUILDDIR}/debian/changelog
        echo "Source: $NAME
 Section: $SECTION
-Priority: optional
+Priority: $PRIORITY
 Maintainer: Joe Sixpack <joe@example.org>
 Standards-Version: 3.9.1
 
@@ -396,52 +399,81 @@ insertpackage() {
        local ARCH="$3"
        local VERSION="$4"
        local DEPENDENCIES="$5"
-       local ARCHS="$ARCH"
-       if [ "$ARCHS" = "all" ]; then
-               ARCHS="$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
-       fi
-       for BUILDARCH in $ARCHS; do
-               local PPATH="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}"
-               mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source
-               touch aptarchive/dists/${RELEASE}/main/source/Sources
-               local FILE="${PPATH}/Packages"
-               echo "Package: $NAME
-Priority: optional
+       local PRIORITY="${6:-optional}"
+       local ARCHS=""
+       for arch in $(echo "$ARCH" | sed -e 's#,#\n#g'); do
+               if [ "$arch" = "all" ]; then
+                       ARCHS="$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
+               else
+                       ARCHS="$arch"
+               fi
+               for BUILDARCH in $ARCHS; do
+                       local PPATH="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}"
+                       mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source
+                       touch aptarchive/dists/${RELEASE}/main/source/Sources
+                       local FILE="${PPATH}/Packages"
+                       echo "Package: $NAME
+Priority: $PRIORITY
 Section: other
 Installed-Size: 42
 Maintainer: Joe Sixpack <joe@example.org>
-Architecture: $ARCH
+Architecture: $arch
 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}
+Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE
+                       test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
+                       echo "Description: 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
+               done
        done
 }
 
+insertsource() {
+       local RELEASE="$1"
+       local NAME="$2"
+       local ARCH="$3"
+       local VERSION="$4"
+       local DEPENDENCIES="$5"
+       local ARCHS=""
+       local SPATH="aptarchive/dists/${RELEASE}/main/source"
+       mkdir -p $SPATH
+       local FILE="${SPATH}/Sources"
+       echo "Package: $NAME
+Binary: $NAME
+Version: $VERSION
+Maintainer: Joe Sixpack <joe@example.org>
+Architecture: $ARCH" >> $FILE
+       test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
+       echo "Files:
+ d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc
+ d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz" >> $FILE
+}
+
 insertinstalledpackage() {
        local NAME="$1"
        local ARCH="$2"
        local VERSION="$3"
        local DEPENDENCIES="$4"
+       local PRIORITY="${5:-optional}"
        local FILE="rootdir/var/lib/dpkg/status"
-       echo "Package: $NAME
+       for arch in $(echo "$ARCH" | sed -e 's#,#\n#g'); do
+               echo "Package: $NAME
 Status: install ok installed
-Priority: optional
+Priority: $PRIORITY
 Section: other
 Installed-Size: 42
 Maintainer: Joe Sixpack <joe@example.org>
-Architecture: $ARCH
+Architecture: $arch
 Version: $VERSION" >> $FILE
-       test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
-       echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+               test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
+               echo "Description: an autogenerated dummy ${NAME}=${VERSION}/installed
  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
+       done
 }
 
 
@@ -471,6 +503,10 @@ buildaptarchivefromfiles() {
        generatereleasefiles
 }
 
+# can be overridden by testcases for their pleasure
+getcodenamefromsuite() { echo -n "$1"; }
+getreleaseversionfromsuite() { true; }
+
 generatereleasefiles() {
        msgninfo "\tGenerate Release files… "
        local DATE="${1:-now}"
@@ -479,9 +515,22 @@ generatereleasefiles() {
                        aptftparchive -qq release $dir -o APT::FTPArchive::Release::Patterns::='Translation-*' > $dir/Index
                done
                for dir in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
-                       local CODENAME="$(echo "$dir" | cut -d'/' -f 4)"
-                       aptftparchive -qq release $dir -o APT::FTPArchive::Release::Suite="${CODENAME}" -o APT::FTPArchive::Release::Codename="${CODENAME}" | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
-                       if [ "$CODENAME" = "experimental" -o "$CODENAME" = "experimental2" ]; then
+                       local SUITE="$(echo "$dir" | cut -d'/' -f 4)"
+                       local CODENAME="$(getcodenamefromsuite $SUITE)"
+                       local VERSION="$(getreleaseversionfromsuite $SUITE)"
+                       if [ -z "$VERSION" ]; then
+                               aptftparchive -qq release $dir \
+                                       -o APT::FTPArchive::Release::Suite="${SUITE}" \
+                                       -o APT::FTPArchive::Release::Codename="${CODENAME}" \
+                                               | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
+                       else
+                               aptftparchive -qq release $dir \
+                                       -o APT::FTPArchive::Release::Suite="${SUITE}" \
+                                       -o APT::FTPArchive::Release::Codename="${CODENAME}" \
+                                       -o APT::FTPArchive::Release::Version="${VERSION}" \
+                                               | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
+                       fi
+                       if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
                                sed -i '/^Date: / a\
 NotAutomatic: yes' $dir/Release
                        fi
@@ -563,13 +612,27 @@ changetowebserver() {
        if which weborf > /dev/null; then
                weborf -xb aptarchive/ 2>&1 > /dev/null &
                addtrap "kill $!;"
-               local APTARCHIVE="file://$(readlink -f ./aptarchive)"
-               for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
-                       sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#"
-               done
-               return 0
+       elif which gatling > /dev/null; then
+               cd aptarchive
+               gatling -p 8080 -F -S 2>&1 > /dev/null &
+               addtrap "kill $!;"
+               cd - > /dev/null
+       elif which lighttpd > /dev/null; then
+               echo "server.document-root = \"$(readlink -f ./aptarchive)\"
+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 &
+               addtrap "kill $!;"
+       else
+               msgdie 'You have to install weborf or lighttpd first'
+               return 1
        fi
-       return 1
+       local APTARCHIVE="file://$(readlink -f ./aptarchive)"
+       for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
+               sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#"
+       done
+       return 0
 }
 
 checkdiff() {
@@ -685,7 +748,13 @@ testmarkedauto() {
                while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
        else
                msgtest 'Test for correctly marked as auto-installed' 'no package'
-               echo > $COMPAREFILE
+               echo -n > $COMPAREFILE
        fi
        aptmark showauto 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
 }
+
+pause() {
+       echo "STOPPED execution. Press enter to continue"
+       local IGNORE
+       read IGNORE
+}