From f74a6fa120759d0a1bd4a5aff0dc2c50911b5407 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 15 Jan 2014 18:44:47 +0100 Subject: rework some testcases to not spit out text Rework also uncovers two FIXMEs Git-Dch: Ignore --- test/integration/framework | 22 ++++---- test/integration/test-apt-progress-fd-conffile | 17 +++++-- test/integration/test-apt-sources-deb822 | 70 ++++++++++++++------------ test/integration/test-bug-728500-tempdir | 19 +++++-- 4 files changed, 77 insertions(+), 51 deletions(-) diff --git a/test/integration/framework b/test/integration/framework index 6ada1e9cc..2fe059280 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -948,22 +948,22 @@ testempty() { test -z "$($* 2>&1)" && msgpass || msgfail } -testequalwithmsg() { - local MSG="$1" - shift +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 "$MSG" - $* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail -} -testequal() { - local EXPECTED="$1" - shift - local MSG="Test for equality of $*" - testequalwithmsg "$MSG" "$EXPECTED" $* + if [ -n "$MSG" ]; then + msgtest "$MSG" "$*" + fi + $* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail } testequalor2() { diff --git a/test/integration/test-apt-progress-fd-conffile b/test/integration/test-apt-progress-fd-conffile index 0b42b1b2f..085d5e871 100755 --- a/test/integration/test-apt-progress-fd-conffile +++ b/test/integration/test-apt-progress-fd-conffile @@ -32,12 +32,19 @@ testsuccess aptget install compiz-core=1.0 # fake conffile change echo "meep" >> rootdir/etc/compiz.conf/compiz.conf -# install +# FIXME: Is there really no way to see if dpkg actually prompts? +msgtest 'Test for successful execution of' 'apt-get install compiz-core=2.0' +OUTPUT=$(mktemp) +addtrap "rm $OUTPUT;" exec 3> apt-progress.log -echo n | aptget install compiz-core=2.0 -o APT::Status-Fd=3 -o Dpkg::Use-Pty=false +if aptget install compiz-core=2.0 -o APT::Status-Fd=3 -o Dpkg::Use-Pty=false -o dpkg::options::='--force-confold' >${OUTPUT} 2>&1; then + msgpass +else + echo + cat $OUTPUT + msgfail +fi # and ensure there is a conffile message in the file -msgtest "Conffile prompt in apt-progress.log" +msgtest 'Test status fd for an included' 'pmconffile msg' grep -q "pmconffile:/etc/compiz.conf/compiz.conf" apt-progress.log && msgpass || (cat apt-progress.log && msgfail) - -cat apt-progress.log \ No newline at end of file diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index bacad1ed4..8c022767f 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -5,17 +5,10 @@ TESTDIR=$(readlink -f $(dirname $0)) . $TESTDIR/framework setupenvironment -configarchitecture "i386" +configarchitecture 'i386' -SOURCES="rootdir/etc/apt/sources.list" - -echo "deb http://ftp.debian.org/debian stable main" > $SOURCES -testequalwithmsg "Old style sources.list works" "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : -'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 : -'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 " aptget update --print-uris - - -BASE="# some comment +SOURCES='rootdir/etc/apt/sources.list' +BASE='# some comment # that contains a : as well #Type: meep @@ -24,57 +17,72 @@ URL: http://ftp.debian.org/debian Dist: stable Section: main Comment: Some random string - that can be very long" + that can be very long' -# simple case -echo "$BASE" > $SOURCES -testequalwithmsg "Simple deb822 sources.list works" "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : +msgtest 'Test old-style sources.list' +echo "deb http://ftp.debian.org/debian stable main" > $SOURCES +testequal --nomsg "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 : -'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 " aptget update --print-uris +'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 " aptget update --print-uris -# two sections (we support both "," and " " as seperator) -echo "$BASE" | sed s/main/"main,contrib"/ > $SOURCES +msgtest 'Test simple deb822 sources.list' +echo "$BASE" > $SOURCES +testequal --nomsg "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : +'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 : +'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 " aptget update --print-uris -testequalwithmsg "Two sections deb822 sources.list work" "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : + +msgtest 'Test deb822 with two sections' 'seperated by comma' +echo "$BASE" | sed 's/main/main,contrib/' > $SOURCES +testequal --nomsg "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : 'http://ftp.debian.org/debian/dists/stable/contrib/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_contrib_binary-i386_Packages 0 : 'http://ftp.debian.org/debian/dists/stable/contrib/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_stable_contrib_i18n_Translation-en 0 : 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 : -'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 " aptget update --print-uris +'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 " aptget update --print-uris + +# FIXME: Advertised, but not supported at the moment +#msgtest 'Test deb822 with two sections' 'seperated by space' +#echo "$BASE" | sed 's/main/main contrib/' > $SOURCES +#testequal --nomsg "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : +#'http://ftp.debian.org/debian/dists/stable/contrib/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_contrib_binary-i386_Packages 0 : +#'http://ftp.debian.org/debian/dists/stable/contrib/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_stable_contrib_i18n_Translation-en 0 : +#'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 : +#'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 " aptget update --print-uris -# Two entries + +msgtest 'Test deb822 with' 'two entries' echo "$BASE" > $SOURCES echo "" >> $SOURCES echo "$BASE" | sed s/stable/unstable/ >> $SOURCES - -testequalwithmsg "Multiple entries in deb822 sources.list work" "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : +testequal --nomsg "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 : 'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 'http://ftp.debian.org/debian/dists/unstable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_unstable_main_binary-i386_Packages 0 : 'http://ftp.debian.org/debian/dists/unstable/main/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_unstable_main_i18n_Translation-en 0 : -'http://ftp.debian.org/debian/dists/unstable/InRelease' ftp.debian.org_debian_dists_unstable_InRelease 0 " aptget update --print-uris +'http://ftp.debian.org/debian/dists/unstable/InRelease' ftp.debian.org_debian_dists_unstable_InRelease 0 " aptget update --print-uris -# ARCH option +msgtest 'Test deb822' 'architecture option' echo "$BASE" > $SOURCES echo "Arch: amd64,armel" >> $SOURCES - -testequalwithmsg "Arch: option in deb822 sources.list works" "'http://ftp.debian.org/debian/dists/stable/main/binary-amd64/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-amd64_Packages 0 : +testequal --nomsg "'http://ftp.debian.org/debian/dists/stable/main/binary-amd64/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-amd64_Packages 0 : 'http://ftp.debian.org/debian/dists/stable/main/binary-armel/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-armel_Packages 0 : 'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 : 'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 " aptget update --print-uris -# invalid sources.list file -echo "deb http://ftp.debian.org" > $SOURCES -testequalwithmsg "Invalid sources.list file gives proper error" "E: Malformed line 1 in source list $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list (dist) +msgtest 'Test old-style sources.list file which has' 'malformed dist' +echo "deb http://ftp.debian.org" > $SOURCES +testequal --nomsg "E: Malformed line 1 in source list $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list (dist) E: The list of sources could not be read." aptget update --print-uris + +msgtest 'Test deb822 sources.list file which has' 'malformed URI' echo "Type: deb Dist: stable " > $SOURCES - -testequalwithmsg "Invalid deb822 sources.list file gives proper error" "E: Malformed stanza 0 in source list $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list (URI parse) +testequal --nomsg "E: Malformed stanza 0 in source list $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list (URI parse) E: The list of sources could not be read." aptget update --print-uris diff --git a/test/integration/test-bug-728500-tempdir b/test/integration/test-bug-728500-tempdir index 0606538a1..0451fc1ed 100755 --- a/test/integration/test-bug-728500-tempdir +++ b/test/integration/test-bug-728500-tempdir @@ -7,12 +7,23 @@ TESTDIR=$(readlink -f $(dirname $0)) setupenvironment configarchitecture 'i386' -buildsimplenativepackage 'coolstuff' 'all' '1.0' 'unstable' +insertpackage 'unstable' 'coolstuff' 'all' '1.0' setupaptarchive changetowebserver -msgtest 'Test with incorect TMPDIR' +msgtest 'Test apt-get update with incorrect' 'TMPDIR' + +OUTPUT=$(mktemp) +addtrap "rm $OUTPUT;" export TMPDIR=/does-not-exists -aptget update && msgpass || msgfail -unset TMPDIR \ No newline at end of file +if aptget update >${OUTPUT} 2>&1; then + msgpass +else + echo + cat $OUTPUT + msgfail +fi +unset TMPDIR + +testequal 'coolstuff' aptcache pkgnames -- cgit v1.2.3