From d2d68aaf5bc2211e9c488f2603ccb4e5fd591a6d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 4 Jan 2014 15:39:04 +0100 Subject: improve tests --- apt-pkg/sourcelist.cc | 3 ++- test/integration/framework | 13 +++++++++++-- test/integration/test-apt-sources-deb822 | 21 ++++++++++++++++----- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 99cdbe030..35e13b6f5 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -342,7 +342,8 @@ bool pkgSourceList::ParseFileDeb822(string File) // check if there are any options we support const char* option_str[] = { - "arch", "arch+", "arch-", "trusted" }; + "arch", "arch+", "arch-", "trusted", + }; for (unsigned int j=0; j < sizeof(option_str)/sizeof(char*); j++) if (Tags.Exists(option_str[j])) Options[option_str[j]] = Tags.FindS(option_str[j]); diff --git a/test/integration/framework b/test/integration/framework index a28363768..6ada1e9cc 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -948,13 +948,22 @@ testempty() { test -z "$($* 2>&1)" && msgpass || msgfail } -testequal() { +testequalwithmsg() { + local MSG="$1" + shift local COMPAREFILE=$(mktemp) addtrap "rm $COMPAREFILE;" echo "$1" > $COMPAREFILE shift - msgtest "Test for equality of" "$*" + msgtest "$MSG" $* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail +} + +testequal() { + local EXPECTED="$1" + shift + local MSG="Test for equality of $*" + testequalwithmsg "$MSG" "$EXPECTED" $* } testequalor2() { diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index 6e9700bb0..24fb1bdb0 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -7,7 +7,17 @@ TESTDIR=$(readlink -f $(dirname $0)) setupenvironment configarchitecture "i386" -BASE="Type: deb +echo "deb http://ftp.debian.org/debian stable main" > rootdir/etc/apt/sources.list +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 +# that contains a : as well +#Type: meep + +Type: deb URL: http://ftp.debian.org/debian Dist: stable Section: main @@ -17,7 +27,7 @@ Comment: Some random string # simple case echo "$BASE" > rootdir/etc/apt/sources.list -testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : +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 : '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 @@ -25,7 +35,7 @@ testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages. # two sections (we support both "," and " " as seperator) echo "$BASE" | sed s/main/"main,contrib"/ > rootdir/etc/apt/sources.list -testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : +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 : '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 : @@ -37,7 +47,7 @@ echo "$BASE" > rootdir/etc/apt/sources.list echo "" >> rootdir/etc/apt/sources.list echo "$BASE" | sed s/stable/unstable/ >> rootdir/etc/apt/sources.list -testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : +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 : '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 : @@ -49,7 +59,8 @@ testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages. echo "$BASE" > rootdir/etc/apt/sources.list echo "Arch: amd64,armel" >> rootdir/etc/apt/sources.list -testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-amd64/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-amd64_Packages 0 : +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 : '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 + -- cgit v1.2.3