diff options
Diffstat (limited to 'test')
34 files changed, 810 insertions, 100 deletions
diff --git a/test/integration/framework b/test/integration/framework index 05c8fcd2a..a424f1559 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -340,6 +340,7 @@ setupenvironment() { # ----- cd "$TMPWORKINGDIRECTORY" + echo "#x-apt-configure-index \"${SOURCEDIRECTORY}/doc/examples/configure-index\";" > aptconfig.conf mkdir rootdir aptarchive keys cd rootdir mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d @@ -1157,6 +1158,30 @@ setupaptarchive() { fi } +killgpgagent() { + if [ -z "${TMPWORKINGDIRECTORY}" ]; then return; fi + local GPGHOME="${TMPWORKINGDIRECTORY}/signinghome" + if [ -e "${GPGHOME}" ]; then return; fi + # ensure the agent dies quickly as different versions have different suicide heuristics + GNUPGHOME="${GPGHOME}" gpgconf --kill gpg-agent >/dev/null 2>&1 || true + rm -rf "$GPGHOME" +} +dosigning() { + local KEY="$1" + shift + local GPGHOME="${TMPWORKINGDIRECTORY}/signinghome" + if [ -n "$APT_TEST_SIGNINGHOME" ]; then + GPGHOME="$APT_TEST_SIGNINGHOME" + else + if [ ! -e "$GPGHOME" ]; then + mkdir -p --mode=700 "${GPGHOME}" + addtrap 'prefix' 'killgpgagent;' + fi + fi + testsuccess aptkey --quiet --keyring ${KEY}.pub --secret-keyring ${KEY}.sec --readonly \ + --homedir "${GPGHOME}" adv --batch --yes --digest-algo "${APT_TESTS_DIGEST_ALGO:-SHA512}" \ + "$@" +} signreleasefiles() { local SIGNERS="${1:-Joe Sixpack}" local REPODIR="${2:-aptarchive}" @@ -1177,7 +1202,7 @@ signreleasefiles() { # FIXME: This should be the full name, but we can't encode the space properly currently SIGUSERS="${SIGUSERS} -u ${SIGNER#* }" if [ "${SIGNER}" = 'Rex Expired' ]; then - # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time + # the key is expired, so gpg doesn't allow one to sign with and the --faked-system-time # option doesn't exist anymore (and using faketime would add a new obscure dependency) # therefore we 'temporary' make the key not expired and restore a backup after signing cp "${REXKEY}.sec" "$SECEXPIREBAK" @@ -1208,21 +1233,20 @@ signreleasefiles() { mv "${KEY}.new.pub" "${KEY}.pub" mv "${KEY}.new.sec" "${KEY}.sec" fi - local GPG="aptkey --quiet --keyring ${KEY}.pub --secret-keyring ${KEY}.sec --readonly adv --batch --yes --digest-algo ${APT_TESTS_DIGEST_ALGO:-SHA512}" for RELEASE in $(find "${REPODIR}/" -name Release); do # we might have set a specific date for the Release file, so copy it local DATE="$(stat --format "%y" "${RELEASE}")" if [ "$APT_DONT_SIGN" = 'Release.gpg' ]; then rm -f "${RELEASE}.gpg" else - testsuccess $GPG "$@" $SIGUSERS --armor --detach-sign --sign --output "${RELEASE}.gpg" "${RELEASE}" + dosigning "$KEY" "$@" $SIGUSERS --armor --detach-sign --sign --output "${RELEASE}.gpg" "${RELEASE}" touch -d "$DATE" "${RELEASE}.gpg" fi local INRELEASE="${RELEASE%/*}/InRelease" if [ "$APT_DONT_SIGN" = 'InRelease' ]; then rm -f "$INRELEASE" else - testsuccess $GPG "$@" $SIGUSERS --clearsign --output "$INRELEASE" "$RELEASE" + dosigning "$KEY" "$@" $SIGUSERS --clearsign --output "$INRELEASE" "$RELEASE" touch -d "$DATE" "${INRELEASE}" fi done @@ -1404,12 +1428,12 @@ checkdiff() { local TMPFILE2="${TMPWORKINGDIRECTORY}/rootdir/tmp/checkdiff.2.tmp" touch "$TMPFILE1" "$TMPFILE2" if [ "$1" != '-' ]; then - sed -e '/^profiling:/ d' < "$1" >"$TMPFILE1" + sed -e '/^profiling:/ d' -e '/\.\.\.profiling:/{N;s#\.\.\.profiling:.*\n#...#g}' < "$1" >"$TMPFILE1" else TMPFILE1='-' fi if [ "$2" != '-' ]; then - sed -e '/^profiling:/ d' < "$2" >"$TMPFILE2" + sed -e '/^profiling:/ d' -e '/\.\.\.profiling:/{N;s#\.\.\.profiling:.*\n#...#g}' < "$2" >"$TMPFILE2" else TMPFILE2='-' fi diff --git a/test/integration/run-tests b/test/integration/run-tests index 7c0b74ce2..80f1fc61d 100755 --- a/test/integration/run-tests +++ b/test/integration/run-tests @@ -107,6 +107,17 @@ if [ -n "$APT_TEST_JOBS" ]; then fi exec $parallel -j "$APT_TEST_JOBS" "./$(basename "$0")" -- $(echo "$TESTLIST") fi + +APT_TEST_SIGNINGHOME="$(mktemp --directory --tmpdir 'apt-key-signinghome.XXXXXXXXXX')" +removesigninghome() { + if [ -z "$APT_TEST_SIGNINGHOME" ]; then return; fi + GNUPGHOME="${APT_TEST_SIGNINGHOME}" gpgconf --kill gpg-agent >/dev/null 2>&1 || true + rm -rf -- "$APT_TEST_SIGNINGHOME" +} +trap "exit 1" 0 HUP INT ILL ABRT FPE SEGV PIPE TERM +trap "removesigninghome" 0 QUIT +export APT_TEST_SIGNINGHOME + TOTAL="$(echo "$TESTLIST" | wc -l)" if [ "$MSGLEVEL" -le 1 ]; then printf "${CTEST}Running testcases${CRESET}: " diff --git a/test/integration/test-00-commands-have-help b/test/integration/test-00-commands-have-help index 699cdef15..2d8fa1105 100755 --- a/test/integration/test-00-commands-have-help +++ b/test/integration/test-00-commands-have-help @@ -63,3 +63,26 @@ testsuccess aptget moo moo moo testsuccess aptget moo moo moo -q=2 testsuccess aptget moo moo moo moo testsuccess aptget moo moo moo moo -q=2 + +export SOURCE_DATE_EPOCH=moo +testwarningmsg 'W: Environment variable SOURCE_DATE_EPOCH was ignored as it has an invalid value: "moo"' apt moo +testmoo() { + export SOURCE_DATE_EPOCH="$(date -d "$1" +'%s')" + testsuccess aptget moo + cp rootdir/tmp/testsuccess.output moo.output + testsuccess grep "$2" moo.output + testsuccessequal "$2" apt moo -qqq + unset SOURCE_DATE_EPOCH +} +testmoo '@0' 'Have you mooed today?' +# the year 0 is too early for 32bit architectures +testmoo '2000-12-25' 'Happy package management day!' +testmoo '1930-02-18' "It's a Bird ... It's a Plane ... It's Super Cow!" +testmoo '1966-11-07' 'Whoever needs milk, bows to the animal.' +testmoo '1988-03-29' 'Have you mooed today?' +testmoo '1993-08-16' 'Three moos for Debian!' +testmoo '1998-04-01' 'Have you smashed some milk today?' +testmoo '@1484822790' 'Have you mooed today?' +testmoo '@1484822791' 'Have you mooed today?' +testmoo '@1484822792' 'Have you mooed today?' +testmoo '@1484822793' 'Have you mooed today?' diff --git a/test/integration/test-apt-cdrom b/test/integration/test-apt-cdrom index 212f0baa4..01680c461 100755 --- a/test/integration/test-apt-cdrom +++ b/test/integration/test-apt-cdrom @@ -112,7 +112,7 @@ Conf testing:i386 (0.8.15 stable [i386])' aptget install testing:i386 -s rm -f testing_0.8.15_amd64.deb rm -f testing_0.8.15.dsc - testsuccess aptget source testing --dsc-only -d + testsuccess aptget source testing --dsc-only testsuccess test -s testing_0.8.15.dsc rm -f testing_0.8.15.dsc cd - >/dev/null diff --git a/test/integration/test-apt-cli-update b/test/integration/test-apt-cli-update index b423072c3..cc8d051d2 100755 --- a/test/integration/test-apt-cli-update +++ b/test/integration/test-apt-cli-update @@ -15,6 +15,7 @@ setupaptarchive --no-update testfailuremsg 'E: The update command takes no arguments' apt update arguments +testempty apt update -qq -o pkgCacheFile::Generate=false testsuccessequal "1 package can be upgraded. Run 'apt list --upgradable' to see it." apt update -qq cp dpkg.status rootdir/var/lib/dpkg/status diff --git a/test/integration/test-apt-ftparchive-by-hash b/test/integration/test-apt-ftparchive-by-hash index 75fb0cf2c..ccfc62734 100755 --- a/test/integration/test-apt-ftparchive-by-hash +++ b/test/integration/test-apt-ftparchive-by-hash @@ -23,7 +23,7 @@ confighashes 'SHA256' 'SHA512' # enable by-hash in apt-ftparchive echo 'APT::FTPArchive::DoByHash "1";' >> aptconfig.conf -# build one pacakge +# build one package buildsimplenativepackage 'foo' 'i386' '1' 'unstable' buildaptarchivefromincoming diff --git a/test/integration/test-apt-ftparchive-cachedb b/test/integration/test-apt-ftparchive-cachedb index 1a06ff343..73d762cc8 100755 --- a/test/integration/test-apt-ftparchive-cachedb +++ b/test/integration/test-apt-ftparchive-cachedb @@ -64,7 +64,7 @@ Tree "dists/test" { }; EOF -# build one pacakge +# build one package buildsimplenativepackage 'foo' 'i386' '1' 'test' mv incoming/* aptarchive/pool/main/ diff --git a/test/integration/test-apt-ftparchive-cachedb-lp1274466 b/test/integration/test-apt-ftparchive-cachedb-lp1274466 index 3a5527230..b0bcae8ec 100755 --- a/test/integration/test-apt-ftparchive-cachedb-lp1274466 +++ b/test/integration/test-apt-ftparchive-cachedb-lp1274466 @@ -16,7 +16,7 @@ if command -v db_dump-5 >/dev/null 2>&1; then db_dump=db_dump-5 fi -# gather the db and the deb, ensure mtime is not modfied as its saved in the DB +# gather the db and the deb, ensure mtime is not modified as its saved in the DB cp -p "$TESTDIR/deb-lp1274466-cachedb.deb" foo_1_i386.deb cp -p "$TESTDIR/cachedb-lp1274466-old-format.db" old-format.db diff --git a/test/integration/test-apt-get-autoremove b/test/integration/test-apt-get-autoremove index 8af864acb..6f3452fbd 100755 --- a/test/integration/test-apt-get-autoremove +++ b/test/integration/test-apt-get-autoremove @@ -46,6 +46,47 @@ Reading state information... 1 package was automatically installed and is no longer required. Use '$AUTOREMOVE' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small +testequal "Reading package lists... +Building dependency tree... +Reading state information... +Calculating upgrade... +The following package was automatically installed and is no longer required: + po-debconf +Use '$AUTOREMOVE' to remove it. +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget upgrade -s +testsuccessequal 'Reading package lists... +Building dependency tree... +Reading state information... +The following packages will be REMOVED: + po-debconf +0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv po-debconf [1.0.16]' aptget install -s --autoremove +testsuccessequal 'Reading package lists... +Building dependency tree... +Reading state information... +Calculating upgrade... +The following packages will be REMOVED: + po-debconf +0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv po-debconf [1.0.16]' aptget upgrade -s --autoremove +echo 'APT::Get::AutomaticRemove "true";' > rootdir/etc/apt/apt.conf.d/autoremoval +testsuccessequal 'Reading package lists... +Building dependency tree... +Reading state information... +The following packages will be REMOVED: + po-debconf +0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv po-debconf [1.0.16]' aptget install -s +testequal "Reading package lists... +Building dependency tree... +Reading state information... +Calculating upgrade... +The following package was automatically installed and is no longer required: + po-debconf +Use '$AUTOREMOVE' to remove it. +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget upgrade -s +rm -f rootdir/etc/apt/apt.conf.d/autoremoval + testdpkginstalled 'po-debconf' echo 'APT::NeverAutoRemove { "^po-debconf$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove diff --git a/test/integration/test-apt-get-build-dep b/test/integration/test-apt-get-build-dep index 6a3a2b6c2..403de8f35 100755 --- a/test/integration/test-apt-get-build-dep +++ b/test/integration/test-apt-get-build-dep @@ -8,6 +8,7 @@ setupenvironment configarchitecture 'i386' insertpackage 'stable' 'build-essential' 'i386' '1' +insertpackage 'stable' 'build-essential2' 'i386' '1' insertpackage 'stable' 'build-depends' 'i386' '1' insertpackage 'stable' 'build-depends-arch' 'i386' '1' insertpackage 'stable' 'build-depends-indep' 'i386' '1' @@ -56,6 +57,67 @@ testsuccessequal "Note, using file './foobar.dsc' to get the build dependencies Reading package lists... Building dependency tree... The following packages will be REMOVED: + build-conflicts build-conflicts-arch build-conflicts-indep +The following NEW packages will be installed: + build-depends build-depends-arch build-depends-indep build-essential2 +0 upgraded, 4 newly installed, 3 to remove and 0 not upgraded. +Remv build-conflicts [1] +Remv build-conflicts-arch [1] +Remv build-conflicts-indep [1] +Inst build-depends (1 stable [i386]) +Inst build-depends-arch (1 stable [i386]) +Inst build-depends-indep (1 stable [i386]) +Inst build-essential2 (1 stable [i386]) +Conf build-depends (1 stable [i386]) +Conf build-depends-arch (1 stable [i386]) +Conf build-depends-indep (1 stable [i386]) +Conf build-essential2 (1 stable [i386])" aptget build-dep --simulate ./foobar.dsc -o APT::Build-Essential="build-essential2" + +testsuccessequal "Note, using file './foobar.dsc' to get the build dependencies +Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + build-conflicts build-conflicts-arch build-conflicts-indep +The following NEW packages will be installed: + build-depends build-depends-arch build-depends-indep +0 upgraded, 3 newly installed, 3 to remove and 0 not upgraded. +Remv build-conflicts [1] +Remv build-conflicts-arch [1] +Remv build-conflicts-indep [1] +Inst build-depends (1 stable [i386]) +Inst build-depends-arch (1 stable [i386]) +Inst build-depends-indep (1 stable [i386]) +Conf build-depends (1 stable [i386]) +Conf build-depends-arch (1 stable [i386]) +Conf build-depends-indep (1 stable [i386])" aptget build-dep --simulate ./foobar.dsc -o APT::Build-Essential="," + +testsuccessequal "Note, using file './foobar.dsc' to get the build dependencies +Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + build-conflicts build-conflicts-arch build-conflicts-indep +The following NEW packages will be installed: + build-depends build-depends-arch build-depends-indep build-essential + build-essential2 +0 upgraded, 5 newly installed, 3 to remove and 0 not upgraded. +Remv build-conflicts [1] +Remv build-conflicts-arch [1] +Remv build-conflicts-indep [1] +Inst build-depends (1 stable [i386]) +Inst build-depends-arch (1 stable [i386]) +Inst build-depends-indep (1 stable [i386]) +Inst build-essential (1 stable [i386]) +Inst build-essential2 (1 stable [i386]) +Conf build-depends (1 stable [i386]) +Conf build-depends-arch (1 stable [i386]) +Conf build-depends-indep (1 stable [i386]) +Conf build-essential (1 stable [i386]) +Conf build-essential2 (1 stable [i386])" aptget build-dep --simulate ./foobar.dsc -o APT::Build-Essential::="build-essential2" + +testsuccessequal "Note, using file './foobar.dsc' to get the build dependencies +Reading package lists... +Building dependency tree... +The following packages will be REMOVED: build-conflicts build-conflicts-arch The following NEW packages will be installed: build-depends build-depends-arch build-essential @@ -68,3 +130,20 @@ Inst build-essential (1 stable [i386]) Conf build-depends (1 stable [i386]) Conf build-depends-arch (1 stable [i386]) Conf build-essential (1 stable [i386])" aptget build-dep --simulate ./foobar.dsc --arch-only + +testsuccessequal "Note, using file './foobar.dsc' to get the build dependencies +Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + build-conflicts build-conflicts-indep +The following NEW packages will be installed: + build-depends build-depends-indep build-essential +0 upgraded, 3 newly installed, 2 to remove and 0 not upgraded. +Remv build-conflicts [1] +Remv build-conflicts-indep [1] +Inst build-depends (1 stable [i386]) +Inst build-depends-indep (1 stable [i386]) +Inst build-essential (1 stable [i386]) +Conf build-depends (1 stable [i386]) +Conf build-depends-indep (1 stable [i386]) +Conf build-essential (1 stable [i386])" aptget build-dep --simulate ./foobar.dsc --indep-only diff --git a/test/integration/test-apt-get-build-dep-file b/test/integration/test-apt-get-build-dep-file index ed850fa40..07de8bb30 100755 --- a/test/integration/test-apt-get-build-dep-file +++ b/test/integration/test-apt-get-build-dep-file @@ -39,7 +39,8 @@ Files: EOF test2vcardbuilddep() { - testsuccessequal "Note, using file './2vcard_0.5-3.dsc' to get the build dependencies + local name="$1" + testsuccessequal "Note, using file './$name' to get the build dependencies Reading package lists... Building dependency tree... The following packages will be REMOVED: @@ -51,14 +52,16 @@ Remv build-conflict [1] Inst build-essential (1 stable [i386]) Inst debhelper (7 stable [i386]) Conf build-essential (1 stable [i386]) -Conf debhelper (7 stable [i386])" aptget build-dep -s ./2vcard_0.5-3.dsc -testfailure aptget build-dep --simulate 2vcard_0.5-3.dsc +Conf debhelper (7 stable [i386])" aptget build-dep -s ./$name +testfailure aptget build-dep --simulate $name cd downloaded -testsuccess aptget build-dep --simulate ../2vcard_0.5-3.dsc -testsuccess aptget build-dep --simulate "$(readlink -f ../2vcard_0.5-3.dsc)" +testsuccess aptget build-dep --simulate ../$name +testsuccess aptget build-dep --simulate "$(readlink -f ../$name)" cd .. } -test2vcardbuilddep +test2vcardbuilddep "2vcard_0.5-3.dsc" +cp "2vcard_0.5-3.dsc" "2VCard_0.5-3.dsc" +test2vcardbuilddep "2VCard_0.5-3.dsc" msgmsg 'Test with' 'signed dsc' cat > 2vcard_0.5-3.dsc <<EOF @@ -93,7 +96,9 @@ z2UAn1oXgTai6opwhVfkxrlmJ+iRxzuc =4eRd -----END PGP SIGNATURE----- EOF -test2vcardbuilddep +test2vcardbuilddep "2vcard_0.5-3.dsc" +cp "2vcard_0.5-3.dsc" "2VCard_0.5-3.dsc" +test2vcardbuilddep "2VCard_0.5-3.dsc" msgmsg 'Test with' 'unpacked source dir' diff --git a/test/integration/test-apt-keep-downloaded-pkgs b/test/integration/test-apt-keep-downloaded-pkgs index 4cc7fbb04..c5f62954c 100755 --- a/test/integration/test-apt-keep-downloaded-pkgs +++ b/test/integration/test-apt-keep-downloaded-pkgs @@ -15,14 +15,25 @@ buildsimplenativepackage 'pkg4' 'all' '1.0' 'stable' # local (file) installs setupaptarchive +# a file:// "download" is not a real download and hence passes +testsuccess aptget install pkg1 --no-download --download-only -y +testfailure test -f rootdir/var/cache/apt/archives/pkg1_1.0_all.deb +testsuccess test -f aptarchive/pool/pkg1_1.0_all.deb + # ensure that install from local sources does not remove debs testsuccess aptget install pkg1 -o APT::Keep-Downloaded-Packages=false testsuccess test -f aptarchive/pool/pkg1_1.0_all.deb +testfailure test -f rootdir/var/cache/apt/archives/pkg1_1.0_all.deb # now switch to http and downloading debs changetowebserver testsuccess aptget update +# see if no-download really doesn't download the package +testfailuremsg 'E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?' aptget install pkg2 --no-download -y +testsuccess test -f aptarchive/pool/pkg2_1.0_all.deb +testfailure test -f rootdir/var/cache/apt/archives/pkg2_1.0_all.deb + # ensure that the downloaded pkg is kept with "keep=true" testsuccess aptget install pkg2 -o APT::Keep-Downloaded-Packages=true testsuccess test -f aptarchive/pool/pkg2_1.0_all.deb @@ -40,4 +51,4 @@ testfailure test -f rootdir/var/cache/apt/archives/pkg3_1.0_all.deb # ensure that install from the download dir does not delete packages mv aptarchive/pool/pkg4_1.0_all.deb rootdir/var/cache/apt/archives testsuccess aptget install $(pwd)/rootdir/var/cache/apt/archives/pkg4_1.0_all.deb -o APT::Keep-Downloaded-Packages=false -testsuccess test -f $(pwd)/rootdir/var/cache/apt/archives/pkg4_1.0_all.deb
\ No newline at end of file +testsuccess test -f $(pwd)/rootdir/var/cache/apt/archives/pkg4_1.0_all.deb diff --git a/test/integration/test-apt-source-and-build-dep b/test/integration/test-apt-source-and-build-dep index 5fa87d57d..7f7457217 100755 --- a/test/integration/test-apt-source-and-build-dep +++ b/test/integration/test-apt-source-and-build-dep @@ -28,7 +28,7 @@ insertsource 'stable' 'foo' 'all' '0.5' insertpackage 'stable' 'foo' 'all' '1.0' insertsource 'stable' 'foo' 'all' '1.0' -# this packages exists only as sources, add two versions to ensure that +# these packages exists only as sources, add two versions to ensure that # apt will pick the higher version number (bts #731853) insertsource 'wheezy' 'foo' 'all' '0.0.1' insertsource 'wheezy' 'foo' 'all' '0.1' diff --git a/test/integration/test-apt-update-expected-size b/test/integration/test-apt-update-expected-size index f7b825d98..710d05d18 100755 --- a/test/integration/test-apt-update-expected-size +++ b/test/integration/test-apt-update-expected-size @@ -25,6 +25,7 @@ test_inreleasetoobig() { rm -f update.output # ensure the failed InRelease file got renamed testsuccess ls rootdir/var/lib/apt/lists/partial/*InRelease.FAILED + testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED } test_packagestoobig() { @@ -40,6 +41,8 @@ test_packagestoobig() { NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)" testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages.gz Writing more data than expected ($NEW_SIZE > $SIZE) E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0 + testsuccess ls rootdir/var/lib/apt/lists/partial/*Packages*.FAILED + testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED } methodtest() { @@ -51,6 +54,7 @@ methodtest() { rm -rf rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good # normal update works fine testsuccess aptget update + touch rootdir/var/lib/apt/lists/partial/Old.FAILED mv rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good # starting fresh works diff --git a/test/integration/test-bug-632221-cross-dependency-satisfaction b/test/integration/test-bug-632221-cross-dependency-satisfaction index 066e29d99..d52652cad 100755 --- a/test/integration/test-bug-632221-cross-dependency-satisfaction +++ b/test/integration/test-bug-632221-cross-dependency-satisfaction @@ -21,7 +21,7 @@ insertpackage 'unstable' 'foreigner' 'amd64,armel' '1.0' 'Multi-Arch: foreign' insertpackage 'unstable' 'arm-stuff' 'armel' '1.0' insertpackage 'unstable' 'linux-stuff' 'amd64,armel' '1.0' -insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner, libfwibble-dev, arm-stuff [any-armel] | linux-stuff [ linux-any]' +insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner, libfwibble-dev, arm-stuff [eabi-any-any-arm gnueabi-any-arm] | linux-stuff [ linux-any]' insertsource 'unstable' 'forbidden-no' 'any' '1' 'Build-Depends: amdboot:any' insertsource 'unstable' 'forbidden-same' 'any' '1' 'Build-Depends: libc6:any' diff --git a/test/integration/test-bug-686346-package-missing-architecture b/test/integration/test-bug-686346-package-missing-architecture index 8f9536a09..d28600a4f 100755 --- a/test/integration/test-bug-686346-package-missing-architecture +++ b/test/integration/test-bug-686346-package-missing-architecture @@ -69,7 +69,7 @@ insertinstalledpackage 'pkgb' 'amd64' '2' testequalor2 "Reading package lists... Building dependency tree... Reading state information... -You might want to run 'apt-get -f install' to correct these. +You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: pkgb : Conflicts: pkgb:none but 1 is installed pkgb:none : Conflicts: pkgb but 2 is installed @@ -77,10 +77,10 @@ The following packages have unmet dependencies: Conflicts: pkgb but 2 is installed pkgg : Conflicts: pkgb but 2 is installed Conflicts: pkgb:none but 1 is installed -E: Unmet dependencies. Try using -f." "Reading package lists... +E: Unmet dependencies. Try using --fix-broken." "Reading package lists... Building dependency tree... Reading state information... -You might want to run 'apt-get -f install' to correct these. +You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: pkgb : Conflicts: pkgb:none but 1 is installed pkgb:none : Conflicts: pkgb but 2 is installed @@ -88,7 +88,7 @@ The following packages have unmet dependencies: Conflicts: pkgb:none but 1 is installed pkgg : Conflicts: pkgb but 2 is installed Conflicts: pkgb:none but 1 is installed -E: Unmet dependencies. Try using -f." aptget check +E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution)." aptget check # check that dependencies are generated for none-packages rm rootdir/var/lib/dpkg/status diff --git a/test/integration/test-bug-738785-switch-protocol b/test/integration/test-bug-738785-switch-protocol index 690e8727e..471d12e53 100755 --- a/test/integration/test-bug-738785-switch-protocol +++ b/test/integration/test-bug-738785-switch-protocol @@ -47,4 +47,4 @@ cd - >/dev/null # check that downgrades from https to http are not allowed webserverconfig 'aptwebserver::support::http' 'true' sed -i -e "s#:${APTHTTPPORT}/redirectme#:${APTHTTPSPORT}/downgrademe#" -e 's# http:# https:#' rootdir/etc/apt/sources.list.d/* -testfailure aptget update --allow-insecure-repositories -o Acquire::https::Timeout=1 +testfailure aptget update --allow-insecure-repositories -o Acquire::https::Timeout=1 -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::https=1 diff --git a/test/integration/test-bug-770291-reinstall b/test/integration/test-bug-770291-reinstall index 389fb1814..a1caf25f8 100755 --- a/test/integration/test-bug-770291-reinstall +++ b/test/integration/test-bug-770291-reinstall @@ -56,7 +56,7 @@ Conf dependsb (1 unstable [i386]) Conf dependsa (1 unstable [i386])' aptget install --reinstall dependsa dependsb -s # there is a chance dpkg can actually do these, BUT this depends on the maintainerscripts (not) present -# which is very very risky to depend on (and apt doesn't know about that anyhow). +# which is very risky to depend on (and apt doesn't know about that anyhow). testfailure aptget install --reinstall predependsa predependsb -s -o Debug::pkgPackageManager=1 testsuccess grep "^E: Couldn't configure predependsa:i386, probably a dependency cycle.$" rootdir/tmp/testfailure.output @@ -89,7 +89,7 @@ Conf dependsb (1 unstable [i386]) Conf dependsa (1 unstable [i386])' aptget install dependsa dependsb -s # there is a chance dpkg can actually do these, BUT this depends on the maintainerscripts (not) present -# which is very very risky to depend on (and apt doesn't know about that anyhow). +# which is very risky to depend on (and apt doesn't know about that anyhow). testfailure aptget install predependsa predependsb -s -o Debug::pkgPackageManager=1 testsuccess grep "^E: Couldn't configure predependsa:i386, probably a dependency cycle.$" rootdir/tmp/testfailure.output diff --git a/test/integration/test-bug-lp1694697-build-dep-architecture-limited-alternative b/test/integration/test-bug-lp1694697-build-dep-architecture-limited-alternative new file mode 100755 index 000000000..7f8e4ad3d --- /dev/null +++ b/test/integration/test-bug-lp1694697-build-dep-architecture-limited-alternative @@ -0,0 +1,58 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" + +setupenvironment +configarchitecture 'i386' + + +insertpackage 'stable' 'build-depends' 'i386' '1' +insertpackage 'stable' 'foo' 'i386' '1' +insertinstalledpackage 'build-essential' 'i386' '1' + +setupaptarchive + +# This used to be interpreted as build-depends | foo +cat > foobar.dsc <<EOF +Format: 3.0 (native) +Source: foobar +Binary: foobar +Architecture: all +Version: 1 +Maintainer: Joe Sixpack <joe@example.org> +Build-Depends: build-depends [i386] | build-depends [amd64], foo +Standards-Version: 3.9.8 +EOF +testsuccessequal "Note, using file './foobar.dsc' to get the build dependencies +Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + build-depends foo +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst build-depends (1 stable [i386]) +Inst foo (1 stable [i386]) +Conf build-depends (1 stable [i386]) +Conf foo (1 stable [i386])" aptget build-dep --simulate ./foobar.dsc + + +# This caused a segmentation fault +cat > foobar.dsc <<EOF +Format: 3.0 (native) +Source: foobar +Binary: foobar +Architecture: all +Version: 1 +Maintainer: Joe Sixpack <joe@example.org> +Build-Depends: build-depends [i386] | build-depends [amd64] +Standards-Version: 3.9.8 +EOF +testsuccessequal "Note, using file './foobar.dsc' to get the build dependencies +Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + build-depends +0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Inst build-depends (1 stable [i386]) +Conf build-depends (1 stable [i386])" aptget build-dep --simulate ./foobar.dsc diff --git a/test/integration/test-cve-2013-1051-InRelease-parsing b/test/integration/test-cve-2013-1051-InRelease-parsing index 3cc012e35..6238057c3 100755 --- a/test/integration/test-cve-2013-1051-InRelease-parsing +++ b/test/integration/test-cve-2013-1051-InRelease-parsing @@ -45,8 +45,10 @@ touch -d '+1hour' aptarchive/dists/stable/InRelease # part of the InRelease listcurrentlistsdirectory | sed '/_InRelease/ d' > listsdir.lst msgtest 'apt-get update should ignore unsigned data in the' 'InRelease' -testsuccessequal "Get:1 http://localhost:${APTHTTPPORT} stable InRelease [$(stat -c%s aptarchive/dists/stable/InRelease) B] -Reading package lists..." --nomsg aptget update +testwarningequal "Get:1 http://localhost:${APTHTTPPORT} stable InRelease [$(stat -c%s aptarchive/dists/stable/InRelease) B] +Reading package lists... +W: Clearsigned file '${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_dists_stable_InRelease' contains unsigned lines. +W: Clearsigned file '${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_stable_InRelease' contains unsigned lines." --nomsg aptget update testfileequal './listsdir.lst' "$(listcurrentlistsdirectory | sed '/_InRelease/ d')" # ensure there is no package diff --git a/test/integration/test-external-dependency-solver-protocol b/test/integration/test-external-dependency-solver-protocol index d126cd84b..2c451d5f9 100755 --- a/test/integration/test-external-dependency-solver-protocol +++ b/test/integration/test-external-dependency-solver-protocol @@ -148,7 +148,16 @@ testsuccess aptget upgrade -s --solver apt testfailure aptget install awesome badstuff -s testfailure aptget install awesome badstuff -s --solver apt testsuccess grep 'ERR_UNSOLVABLE' rootdir/tmp/testfailure.output - +msgtest 'A resolving error is format as' 'valid parseable EDSP error' +if dpkg-checkbuilddeps -d 'dctrl-tools' /dev/null >/dev/null 2>&1; then + if apthelper cat-file rootdir/var/log/apt/edsp.last.xz | aptinternalsolver > solver.result 2>&1; then + testsuccess --nomsg grep-dctrl -FError ERR -- solver.result + else + msgfail + fi +else + msgskip 'dctrl-tools not installed' +fi configarchitecture 'armel' testfailure aptget install --solver apt awesomecoolstuff:i386 -s msgtest 'An invalid EDSP file generates a' 'hard error' diff --git a/test/integration/test-parse-all-archs-into-cache b/test/integration/test-parse-all-archs-into-cache index 65222f0fe..7485431db 100755 --- a/test/integration/test-parse-all-archs-into-cache +++ b/test/integration/test-parse-all-archs-into-cache @@ -22,10 +22,10 @@ setupaptarchive testfailureequal "Reading package lists... Building dependency tree... -You might want to run 'apt-get -f install' to correct these. +You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: foo:amd64 : Depends: libfoo1:amd64 but it is not installable -E: Unmet dependencies. Try using -f." aptget check -s +E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution)." aptget check -s insertinstalledpackage 'libfoo1' 'amd64' '1' 'Multi-Arch: same' diff --git a/test/integration/test-pdiff-usage b/test/integration/test-pdiff-usage index 59a3fd8af..430551fa4 100755 --- a/test/integration/test-pdiff-usage +++ b/test/integration/test-pdiff-usage @@ -210,7 +210,7 @@ Filename: pool/futurestuff_1.0_i386.deb Size: 202200 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050 Description: some cool and shiny future stuff - This package will appear in the next next mirror update + This package will appear in the next^2 mirror update Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages compressfile 'aptarchive/Packages' diff --git a/test/integration/test-releasefile-valid-until b/test/integration/test-releasefile-valid-until index f64c6329d..b18dde2b6 100755 --- a/test/integration/test-releasefile-valid-until +++ b/test/integration/test-releasefile-valid-until @@ -48,7 +48,7 @@ runtest 'rejected' 'bad Max-Valid (bad Until, bad Min-Valid) <' 'now - 7 days' ' runtest 'rejected' 'bad Max-Valid (bad Until, bad Min-Valid) >' 'now - 7 days' 'now - 2 days' -o Acquire::Max-ValidTime=12096 -o Acquire::Min-ValidTime=241920 sed -i -e 's#\(deb\(-src\)\?\) #\1 [check-valid-until=no] #' rootdir/etc/apt/sources.list.d/* -runtest 'accepted' 'bad Until but overriden by sources option' 'now - 7 days' 'now - 4 days' +runtest 'accepted' 'bad Until but overridden by sources option' 'now - 7 days' 'now - 4 days' sed -i -e 's#\(deb\(-src\)\?\) \[check-valid-until=no\] #\1 [valid-until-max=86400] #' rootdir/etc/apt/sources.list.d/* runtest 'rejected' 'bad Max-Valid (good Until) via sources option' 'now - 7 days' 'now + 4 days' diff --git a/test/integration/test-releasefile-verification b/test/integration/test-releasefile-verification index e043fa8b5..36a90f9d5 100755 --- a/test/integration/test-releasefile-verification +++ b/test/integration/test-releasefile-verification @@ -383,7 +383,7 @@ runtest3() { done } -# diable some protection by default and ensure we still do the verification +# disable some protection by default and ensure we still do the verification # correctly cat > rootdir/etc/apt/apt.conf.d/weaken-security <<EOF Acquire::AllowInsecureRepositories "1"; diff --git a/test/integration/test-sourceslist-trusted-options b/test/integration/test-sourceslist-trusted-options index 94de11ef7..1eee3b09a 100755 --- a/test/integration/test-sourceslist-trusted-options +++ b/test/integration/test-sourceslist-trusted-options @@ -26,7 +26,7 @@ foo/stable 1 amd64 testsuccess test -s foo_1_amd64.deb -o -s foo_2_amd64.deb rm -f foo_1.dsc foo_2.dsc - testsuccess aptget source foo --dsc-only -d "$@" + testsuccess aptget source foo --dsc-only "$@" testsuccess test -s foo_1.dsc -o -s foo_2.dsc cd - >/dev/null } @@ -48,7 +48,7 @@ E: Some packages could not be authenticated' testfailure test -s foo_1_amd64.deb -o -s foo_2_amd64.deb rm -f foo_1.dsc foo_2.dsc - testfailure aptget source foo --dsc-only -d "$@" + testfailure aptget source foo --dsc-only "$@" testequal "$WARNING" tail -n 3 ../rootdir/tmp/testfailure.output testfailure test -s foo_1.dsc -o -s foo_2.dsc cd - >/dev/null diff --git a/test/integration/test-ubuntu-bug-1651923-requote-https-uri b/test/integration/test-ubuntu-bug-1651923-requote-https-uri new file mode 100755 index 000000000..cf56a6af4 --- /dev/null +++ b/test/integration/test-ubuntu-bug-1651923-requote-https-uri @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" + +setupenvironment +configarchitecture "i386" + +mkdir "aptarchive/target with space" +echo 'alright' > "aptarchive/target with space/working" +changetohttpswebserver +webserverconfig 'aptwebserver::redirect::replace::/targetwithoutspace/' '/target%20with%20space/' +webserverconfig 'aptwebserver::redirect::replace::/targetwithoutspace2/' '/target with space/' + +testsuccess downloadfile "http://localhost:${APTHTTPPORT}/targetwithoutspace/working" httpfile1 +testsuccess downloadfile "http://localhost:${APTHTTPPORT}/targetwithoutspace2/working" httpfile2 +testsuccess downloadfile "https://localhost:${APTHTTPSPORT}/targetwithoutspace/working" httpsfile1 +testsuccess downloadfile "https://localhost:${APTHTTPSPORT}/targetwithoutspace2/working" httpsfile2 diff --git a/test/libapt/CMakeLists.txt b/test/libapt/CMakeLists.txt index f7cd5b2f6..86c0b28b5 100644 --- a/test/libapt/CMakeLists.txt +++ b/test/libapt/CMakeLists.txt @@ -22,6 +22,9 @@ if(NOT GTEST_FOUND AND EXISTS ${GTEST_ROOT}) endif() if(GTEST_FOUND) + # Definition of the C++ files used to build the test binary - note that this + # is expanded at CMake time, so you have to rerun cmake if you add or remove + # a file (you can just run cmake . in the build directory) file(GLOB files gtest_runner.cc *-helpers.cc *_test.cc) add_executable(libapt_test ${files}) target_include_directories(libapt_test PRIVATE ${GTEST_INCLUDE_DIRS}) diff --git a/test/libapt/cachefilter_test.cc b/test/libapt/cachefilter_test.cc index 28924b758..08812e0dc 100644 --- a/test/libapt/cachefilter_test.cc +++ b/test/libapt/cachefilter_test.cc @@ -1,6 +1,7 @@ #include <config.h> #include <apt-pkg/cachefilter.h> +#include <apt-pkg/fileutl.h> #include <string> @@ -9,17 +10,22 @@ TEST(CacheFilterTest, ArchitectureSpecification) { { - SCOPED_TRACE("Pattern is any-armhf"); - APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-armhf"); - EXPECT_TRUE(ams("armhf")); - EXPECT_FALSE(ams("armel")); - EXPECT_TRUE(ams("linux-armhf")); - EXPECT_FALSE(ams("linux-armel")); - EXPECT_TRUE(ams("kfreebsd-armhf")); - EXPECT_TRUE(ams("gnu-linux-armhf")); - EXPECT_FALSE(ams("gnu-linux-armel")); - EXPECT_TRUE(ams("gnu-kfreebsd-armhf")); - EXPECT_TRUE(ams("musl-linux-armhf")); + SCOPED_TRACE("Pattern is *"); + // * should be treated like any + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("*"); + EXPECT_TRUE(ams("sparc")); + EXPECT_TRUE(ams("amd64")); + EXPECT_TRUE(ams("kfreebsd-amd64")); + } + { + SCOPED_TRACE("Pattern is any-i386"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-i386"); + EXPECT_TRUE(ams("i386")); + EXPECT_FALSE(ams("amd64")); + EXPECT_TRUE(ams("linux-i386")); + EXPECT_FALSE(ams("linux-amd64")); + EXPECT_TRUE(ams("kfreebsd-i386")); + EXPECT_TRUE(ams("musl-linux-i386")); } { SCOPED_TRACE("Pattern is linux-any"); @@ -29,11 +35,9 @@ TEST(CacheFilterTest, ArchitectureSpecification) EXPECT_TRUE(ams("linux-armhf")); EXPECT_TRUE(ams("linux-armel")); EXPECT_FALSE(ams("kfreebsd-armhf")); - EXPECT_TRUE(ams("gnu-linux-armhf")); - EXPECT_TRUE(ams("gnu-linux-armel")); - EXPECT_FALSE(ams("gnu-kfreebsd-armhf")); EXPECT_TRUE(ams("musl-linux-armhf")); } + if (FileExists(DPKG_DATADIR "/tupletable")) { SCOPED_TRACE("Pattern is gnu-any-any"); APT::CacheFilter::PackageArchitectureMatchesSpecification ams("gnu-any-any"); //really? @@ -42,11 +46,32 @@ TEST(CacheFilterTest, ArchitectureSpecification) EXPECT_TRUE(ams("linux-armhf")); EXPECT_TRUE(ams("linux-armel")); EXPECT_TRUE(ams("kfreebsd-armhf")); - EXPECT_TRUE(ams("gnu-linux-armhf")); - EXPECT_TRUE(ams("gnu-linux-armel")); - EXPECT_TRUE(ams("gnu-kfreebsd-armhf")); EXPECT_FALSE(ams("musl-linux-armhf")); } + if (FileExists(DPKG_DATADIR "/triplettable")) + { + SCOPED_TRACE("Pattern is gnueabi-any-any"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("gnueabi-any-any"); //really? + EXPECT_TRUE(ams("linux-armel")); + EXPECT_TRUE(ams("armel")); + EXPECT_FALSE(ams("armhf")); + EXPECT_FALSE(ams("linux-armhf")); + EXPECT_FALSE(ams("musleabihf-linux-armhf")); + } + if (FileExists(DPKG_DATADIR "/triplettable")) + { + SCOPED_TRACE("Pattern is gnueabihf-any-any"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("gnueabihf-any-any"); //really? + EXPECT_FALSE(ams("linux-armel")); + EXPECT_FALSE(ams("armel")); + EXPECT_TRUE(ams("armhf")); + EXPECT_TRUE(ams("linux-armhf")); + EXPECT_FALSE(ams("musleabihf-linux-armhf")); + } + + // Weird ones - armhf's tuple is actually eabihf-gnu-linux-arm + // armel's tuple is actually eabi-gnu-linux-arm + // x32's tuple is actually x32-gnu-linux-amd64 { SCOPED_TRACE("Architecture is armhf"); APT::CacheFilter::PackageArchitectureMatchesSpecification ams("armhf", false); @@ -54,13 +79,41 @@ TEST(CacheFilterTest, ArchitectureSpecification) EXPECT_FALSE(ams("armel")); EXPECT_TRUE(ams("linux-any")); EXPECT_FALSE(ams("kfreebsd-any")); - EXPECT_TRUE(ams("any-armhf")); - EXPECT_FALSE(ams("any-armel")); + EXPECT_TRUE(ams("any-arm")); EXPECT_TRUE(ams("linux-armhf")); EXPECT_FALSE(ams("kfreebsd-armhf")); - EXPECT_TRUE(ams("gnu-linux-armhf")); - EXPECT_FALSE(ams("gnu-linux-armel")); - EXPECT_FALSE(ams("gnu-kfreebsd-armhf")); EXPECT_FALSE(ams("musl-linux-armhf")); } + { + SCOPED_TRACE("Pattern is any-arm"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-arm"); + EXPECT_TRUE(ams("armhf")); + EXPECT_TRUE(ams("armel")); + EXPECT_TRUE(ams("linux-armhf")); + EXPECT_TRUE(ams("linux-armel")); + EXPECT_TRUE(ams("musl-linux-armhf")); + EXPECT_TRUE(ams("uclibc-linux-armel")); + + EXPECT_FALSE(ams("arm64")); + EXPECT_FALSE(ams("linux-arm64")); + EXPECT_FALSE(ams("kfreebsd-arm64")); + EXPECT_FALSE(ams("musl-linux-arm64")); + } + { + SCOPED_TRACE("Pattern is any-amd64"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-amd64"); + EXPECT_TRUE(ams("amd64")); + EXPECT_TRUE(ams("x32")); + EXPECT_TRUE(ams("linux-amd64")); + EXPECT_TRUE(ams("linux-x32")); + EXPECT_TRUE(ams("kfreebsd-amd64")); + EXPECT_TRUE(ams("musl-linux-amd64")); + EXPECT_TRUE(ams("uclibc-linux-amd64")); + + EXPECT_FALSE(ams("i386")); + EXPECT_FALSE(ams("linux-i386")); + EXPECT_FALSE(ams("kfreebsd-i386")); + EXPECT_FALSE(ams("musl-linux-i386")); + EXPECT_FALSE(ams("uclibc-linux-i386")); + } } diff --git a/test/libapt/commandline_test.cc b/test/libapt/commandline_test.cc index 97725c854..1dc9c6946 100644 --- a/test/libapt/commandline_test.cc +++ b/test/libapt/commandline_test.cc @@ -24,8 +24,16 @@ TEST(CommandLineTest,SaveInConfig) "apt-get", "install", "-sf"); APT_EXPECT_CMD("apt-cache -s apt -so Debug::test=Test", "apt-cache", "-s", "apt", "-so", "Debug::test=Test"); - APT_EXPECT_CMD("apt-cache -s apt -so Debug::test=\"Das ist ein Test\"", + APT_EXPECT_CMD("apt-cache -s apt -so Debug::test='Das ist ein Test'", "apt-cache", "-s", "apt", "-so", "Debug::test=Das ist ein Test"); + APT_EXPECT_CMD("apt-cache -s apt -so Debug::test='Das ist ein Test'", + "apt-cache", "-s", "apt", "-so", "Debug::test=\"Das ist ein Test\""); + APT_EXPECT_CMD("apt-cache -s apt -so Debug::test='Das ist ein Test' foo", + "apt-cache", "-s", "apt", "-so", "\"Debug::test=Das ist ein Test\"", "foo"); + APT_EXPECT_CMD("apt-cache -s apt -so Debug::test='Das ist ein Test' foo", + "apt-cache", "-s", "apt", "-so", "\'Debug::test=Das ist ein Test\'", "foo"); + APT_EXPECT_CMD("apt-cache -s apt -so Debug::test='That is crazy!' foo", + "apt-cache", "-s", "apt", "-so", "\'Debug::test=That \ris\n crazy!\'", "foo"); APT_EXPECT_CMD("apt-cache -s apt --hallo test=1.0", "apt-cache", "-s", "apt", "--hallo", "test=1.0"); #undef APT_EXPECT_CMD diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc index c50ff6ff8..29ff0c9ae 100644 --- a/test/libapt/getlanguages_test.cc +++ b/test/libapt/getlanguages_test.cc @@ -2,6 +2,7 @@ #include <apt-pkg/aptconfiguration.h> #include <apt-pkg/configuration.h> +#include <apt-pkg/error.h> #include <apt-pkg/fileutl.h> #include <algorithm> @@ -214,6 +215,7 @@ TEST(LanguagesTest,TranslationFiles) EXPECT_EQ(1, vec.size()); EXPECT_EQ("none", vec[0]); + _error->PushToStack(); _config->Set("Acquire::Languages", ""); //FIXME: Remove support for this deprecated setting _config->Set("APT::Acquire::Translation", "ast_DE"); @@ -228,6 +230,11 @@ TEST(LanguagesTest,TranslationFiles) EXPECT_EQ(1, vec.size()); EXPECT_EQ("en", vec[0]); + // discard the deprecation warning for APT::Acquire::Translation + if (_error->PendingError()) + _error->MergeWithStack(); + else + _error->RevertToStack(); EXPECT_EQ(0, system(std::string("rm -rf ").append(tempdir).c_str())); _config->Clear(); diff --git a/test/libapt/getlistoffilesindir_test.cc b/test/libapt/getlistoffilesindir_test.cc index 2369c911a..8c5e56b1d 100644 --- a/test/libapt/getlistoffilesindir_test.cc +++ b/test/libapt/getlistoffilesindir_test.cc @@ -1,6 +1,7 @@ #include <config.h> #include <apt-pkg/fileutl.h> +#include <apt-pkg/error.h> #include <string> #include <vector> @@ -49,6 +50,7 @@ TEST(FileUtlTest,GetListOfFilesInDir) createLink(tempdir, "non-existing-file", "brokenlink.list"); // Files with no extension + _error->PushToStack(); std::vector<std::string> files = GetListOfFilesInDir(tempdir, "", true); ASSERT_EQ(2, files.size()); EXPECT_EQ(P("01yet-anothernormalfile"), files[0]); @@ -103,5 +105,10 @@ TEST(FileUtlTest,GetListOfFilesInDir) EXPECT_EQ(P("disabledfile.disabled"), files[3]); EXPECT_EQ(P("disabledfile.list.disabled"), files[4]); + // discard the unknown file extension messages + if (_error->PendingError()) + _error->MergeWithStack(); + else + _error->RevertToStack(); removeDirectory(tempdir); } diff --git a/test/libapt/openmaybeclearsignedfile_test.cc b/test/libapt/openmaybeclearsignedfile_test.cc new file mode 100644 index 000000000..40735812d --- /dev/null +++ b/test/libapt/openmaybeclearsignedfile_test.cc @@ -0,0 +1,342 @@ +#include <config.h> + +#include <apt-pkg/error.h> +#include <apt-pkg/fileutl.h> +#include <apt-pkg/gpgv.h> + +#include <string> + +#include <gtest/gtest.h> + +#include "file-helpers.h" + +/* The test files are created with the 'Joe Sixpack' and 'Marvin Paranoid' + test key included in the integration testing framework */ + +TEST(OpenMaybeClearSignedFileTest,SimpleSignedFile) +{ + std::string tempfile; + FileFd fd; + // Using c++11 raw-strings would be nifty, but travis doesn't support it… + createTemporaryFile("simplesignedfile", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n" +"Hash: SHA512\n" +"\n" +"Test\n" +"-----BEGIN PGP SIGNATURE-----\n" +"\n" +"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n" +"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n" +"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n" +"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n" +"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n" +"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n" +"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n" +"=TB1F\n" +"-----END PGP SIGNATURE-----\n"); + + EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd)); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); + EXPECT_TRUE(fd.IsOpen()); + char buffer[100]; + EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer))); + EXPECT_STREQ(buffer, "Test"); + EXPECT_TRUE(fd.Eof()); +} + +TEST(OpenMaybeClearSignedFileTest,WhitespaceSignedFile) +{ + std::string tempfile; + FileFd fd; + // no raw-string here to protect the whitespace from cleanup + createTemporaryFile("simplesignedfile", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE----- \t \n" +"Hash: SHA512 \n" +" \n" +"Test \n" +"-----BEGIN PGP SIGNATURE----- \n" +" \n" +"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt \n" +"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l \n" +"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg \n" +"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k \n" +"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx \n" +"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns \n" +"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq \n" +"=TB1F \n" +"-----END PGP SIGNATURE-----"); + + EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd)); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); + EXPECT_TRUE(fd.IsOpen()); + char buffer[100]; + EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer))); + EXPECT_STREQ(buffer, "Test"); + EXPECT_TRUE(fd.Eof()); +} + +TEST(OpenMaybeClearSignedFileTest,SignedFileWithContentHeaders) +{ + std::string tempfile; + FileFd fd; + createTemporaryFile("headerssignedfile", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n" +"Version: 0.8.15~exp1\n" +"Hash: SHA512\n" +"Comment: I love you!\n" +"X-Expires: never\n" +"Multilines: no\n" +" yes\n" +" maybe\n" +"\n" +"Test\n" +"-----BEGIN PGP SIGNATURE-----\n" +"\n" +"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n" +"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n" +"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n" +"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n" +"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n" +"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n" +"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n" +"=TB1F\n" +"-----END PGP SIGNATURE-----\n"); + + EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd)); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); + EXPECT_TRUE(fd.IsOpen()); + char buffer[100]; + EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer))); + EXPECT_STREQ(buffer, "Test"); + EXPECT_TRUE(fd.Eof()); +} + +// That isn't how multiple signatures are done +TEST(OpenMaybeClearSignedFileTest,SignedFileWithTwoSignatures) +{ + std::string tempfile; + FileFd fd; + createTemporaryFile("doublesignedfile", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n" +"Hash: SHA512\n" +"\n" +"Test\n" +"-----BEGIN PGP SIGNATURE-----\n" +"\n" +"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n" +"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n" +"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n" +"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n" +"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n" +"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n" +"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n" +"=TB1F\n" +"-----END PGP SIGNATURE-----\n" +"-----BEGIN PGP SIGNATURE-----\n" +"\n" +"iQFHBAEBCgAxFiEE3mauypFRr6GHfsMd6FJdR1KBROIFAlhT/yYTHG1hcnZpbkBl\n" +"eGFtcGxlLm9yZwAKCRDoUl1HUoFE4qq3B/459MSk3xCW30wc5+ul5ZxTSg6eLYPJ\n" +"tfVNYi90/ZxRrYQAN+EWozEIZcxoMYp8Ans3++irkjPbHs4NsesmFKt2W5meFl4V\n" +"oUzYrOh5y5GlDeF7ok5g9atQe8BojjBics+g1IBYcnaMU+ywONmlixa03IPGfxV5\n" +"oTx02Xvlns20i6HRc0WFtft5q1hXo4EIlVc9O0u902SVEEkeuHF3+bCcXrNLPBJA\n" +"+8dxmH5+i89f/kVqURrdHdEuA1tsTNyb2C+lvRONh21H8QRRTU/iUQSzV6vZvof5\n" +"ASc9hsAZRG0xHuRU0F94V/XrkWw8QYAobJ/yxvs4L0EuA4optbSqawDB\n" +"=CP8j\n" +"-----END PGP SIGNATURE-----\n"); + + EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd)); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); + EXPECT_TRUE(fd.IsOpen()); + char buffer[100]; + EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer))); + EXPECT_STREQ(buffer, "Test"); + EXPECT_TRUE(fd.Eof()); +} + +TEST(OpenMaybeClearSignedFileTest,TwoSimpleSignedFile) +{ + std::string tempfile; + FileFd fd; + // read only the first message + createTemporaryFile("twosimplesignedfile", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n" +"Hash: SHA512\n" +"\n" +"Test\n" +"-----BEGIN PGP SIGNATURE-----\n" +"\n" +"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n" +"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n" +"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n" +"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n" +"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n" +"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n" +"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n" +"=TB1F\n" +"-----END PGP SIGNATURE-----\n" +"-----BEGIN PGP SIGNED MESSAGE-----\n" +"Hash: SHA512\n" +"\n" +"Test\n" +"-----BEGIN PGP SIGNATURE-----\n" +"\n" +"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n" +"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n" +"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n" +"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n" +"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n" +"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n" +"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n" +"=TB1F\n" +"-----END PGP SIGNATURE-----"); + + EXPECT_TRUE(_error->empty()); + EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd)); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); + EXPECT_FALSE(_error->empty()); + EXPECT_TRUE(fd.IsOpen()); + char buffer[100]; + EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer))); + EXPECT_STREQ(buffer, "Test"); + EXPECT_TRUE(fd.Eof()); + ASSERT_FALSE(_error->empty()); + + std::string msg; + _error->PopMessage(msg); + EXPECT_EQ("Clearsigned file '" + tempfile + "' contains unsigned lines.", msg); +} + +TEST(OpenMaybeClearSignedFileTest,UnsignedFile) +{ + std::string tempfile; + FileFd fd; + createTemporaryFile("unsignedfile", fd, &tempfile, "Test"); + + EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd)); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); + EXPECT_TRUE(fd.IsOpen()); + char buffer[100]; + EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer))); + EXPECT_STREQ(buffer, "Test"); + EXPECT_TRUE(fd.Eof()); +} + +TEST(OpenMaybeClearSignedFileTest,GarbageTop) +{ + std::string tempfile; + FileFd fd; + createTemporaryFile("garbagetop", fd, &tempfile, "Garbage\n" +"-----BEGIN PGP SIGNED MESSAGE-----\n" +"Hash: SHA512\n" +"\n" +"Test\n" +"-----BEGIN PGP SIGNATURE-----\n" +"\n" +"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n" +"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n" +"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n" +"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n" +"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n" +"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n" +"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n" +"=TB1F\n" +"-----END PGP SIGNATURE-----\n"); + + EXPECT_TRUE(_error->empty()); + EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd)); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); + EXPECT_TRUE(fd.IsOpen()); + char buffer[100]; + EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer))); + EXPECT_STREQ(buffer, "Test"); + EXPECT_TRUE(fd.Eof()); + ASSERT_FALSE(_error->empty()); + ASSERT_FALSE(_error->PendingError()); + + std::string msg; + _error->PopMessage(msg); + EXPECT_EQ("Clearsigned file '" + tempfile + "' does not start with a signed message block.", msg); +} + +TEST(OpenMaybeClearSignedFileTest,GarbageBottom) +{ + std::string tempfile; + FileFd fd; + createTemporaryFile("garbagebottom", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n" +"Hash: SHA512\n" +"\n" +"Test\n" +"-----BEGIN PGP SIGNATURE-----\n" +"\n" +"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n" +"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n" +"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n" +"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n" +"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n" +"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n" +"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n" +"=TB1F\n" +"-----END PGP SIGNATURE-----\n" +"Garbage"); + + EXPECT_TRUE(_error->empty()); + EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd)); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); + EXPECT_TRUE(fd.IsOpen()); + char buffer[100]; + EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer))); + EXPECT_STREQ(buffer, "Test"); + EXPECT_TRUE(fd.Eof()); + ASSERT_FALSE(_error->empty()); + ASSERT_FALSE(_error->PendingError()); + + std::string msg; + _error->PopMessage(msg); + EXPECT_EQ("Clearsigned file '" + tempfile + "' contains unsigned lines.", msg); +} + +TEST(OpenMaybeClearSignedFileTest,BogusNoSig) +{ + std::string tempfile; + FileFd fd; + createTemporaryFile("bogusnosig", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n" +"Hash: SHA512\n" +"\n" +"Test"); + + EXPECT_TRUE(_error->empty()); + EXPECT_FALSE(OpenMaybeClearSignedFile(tempfile, fd)); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); + EXPECT_FALSE(_error->empty()); + EXPECT_FALSE(fd.IsOpen()); + + std::string msg; + _error->PopMessage(msg); + EXPECT_EQ("Splitting of file " + tempfile + " failed as it doesn't contain all expected parts 0 1 0", msg); +} + +TEST(OpenMaybeClearSignedFileTest,BogusSigStart) +{ + std::string tempfile; + FileFd fd; + createTemporaryFile("bogusnosig", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n" +"Hash: SHA512\n" +"\n" +"Test\n" +"-----BEGIN PGP SIGNATURE-----"); + + EXPECT_TRUE(_error->empty()); + EXPECT_FALSE(OpenMaybeClearSignedFile(tempfile, fd)); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); + EXPECT_FALSE(_error->empty()); + EXPECT_FALSE(fd.IsOpen()); + + std::string msg; + _error->PopMessage(msg); + EXPECT_EQ("Signature in file " + tempfile + " wasn't closed", msg); +} diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc index f537542b4..c2781b5d6 100644 --- a/test/libapt/parsedepends_test.cc +++ b/test/libapt/parsedepends_test.cc @@ -9,13 +9,15 @@ #include <gtest/gtest.h> -static void parseDependency(bool const StripMultiArch, bool const ParseArchFlags, bool const ParseRestrictionsList) +static void parseDependency(bool const StripMultiArch, bool const ParseArchFlags, bool const ParseRestrictionsList, std::string Arch) { std::string Package; std::string Version; unsigned int Op = 5; unsigned int Null = 0; - _config->Set("APT::Architecture","amd64"); + // The tests are made for amd64. Specify a different arch here to check if + // they still work. + _config->Set("APT::Architecture",Arch); _config->Set("APT::Build-Profiles","stage1"); const char* Depends = @@ -47,7 +49,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag const char* Start = Depends; const char* End = Depends + strlen(Depends); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); if (StripMultiArch == true) EXPECT_EQ("debhelper", Package); else @@ -55,7 +57,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag EXPECT_EQ("5.0", Version); EXPECT_EQ(Null | pkgCache::Dep::GreaterEq, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); if (StripMultiArch == true) EXPECT_EQ("libdb-dev", Package); else @@ -63,7 +65,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag EXPECT_EQ("", Version); EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); if (StripMultiArch == true) EXPECT_EQ("gettext", Package); else @@ -71,7 +73,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag EXPECT_EQ("0.12", Version); EXPECT_EQ(Null | pkgCache::Dep::LessEq, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); if (StripMultiArch == true) EXPECT_EQ("libcurl4-gnutls-dev", Package); else @@ -79,160 +81,160 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag EXPECT_EQ("", Version); EXPECT_EQ(Null | pkgCache::Dep::Or, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("libcurl3-gnutls-dev", Package); EXPECT_EQ("7.15.5", Version); EXPECT_EQ(Null | pkgCache::Dep::Greater, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("docbook-xml", Package); EXPECT_EQ("", Version); EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("apt", Package); EXPECT_EQ("0.7.25", Version); EXPECT_EQ(Null | pkgCache::Dep::GreaterEq, Op); if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("", Package); // not-for-me } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("only-for-me", Package); EXPECT_EQ("", Version); EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op); } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("any-for-me", Package); EXPECT_EQ("", Version); EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op); } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("not-for-darwin", Package); EXPECT_EQ("", Version); EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op); } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("cpu-for-me", Package); EXPECT_EQ("", Version); EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op); } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("os-for-me", Package); EXPECT_EQ("", Version); EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op); } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("libc-for-me", Package); EXPECT_EQ("", Version); EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op); } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("", Package); // libc-not-for-me } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("", Package); // cpu-not-for-me } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("", Package); // os-not-for-me } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseRestrictionsList == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("", Package); // not-in-stage1 } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseRestrictionsList == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("", Package); // not-stage1-and-not-nodoc } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseRestrictionsList == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("not-stage1-or-not-nodoc", Package); } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } if (ParseRestrictionsList == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); EXPECT_EQ("", Package); // unknown-profile } else { - EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64")); Start = strstr(Start, ","); Start++; } - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); if (StripMultiArch == true) EXPECT_EQ("overlord-dev", Package); else @@ -240,7 +242,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag EXPECT_EQ("7.15.3~", Version); EXPECT_EQ(Null | pkgCache::Dep::Equals | pkgCache::Dep::Or, Op); - debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"); if (StripMultiArch == true) EXPECT_EQ("overlord-dev", Package); else @@ -262,7 +264,8 @@ test: SCOPED_TRACE(std::string("StripMultiArch: ") + (StripMultiArch ? "true" : "false")); SCOPED_TRACE(std::string("ParseArchFlags: ") + (ParseArchFlags ? "true" : "false")); SCOPED_TRACE(std::string("ParseRestrictionsList: ") + (ParseRestrictionsList ? "true" : "false")); - parseDependency(StripMultiArch, ParseArchFlags, ParseRestrictionsList); + parseDependency(StripMultiArch, ParseArchFlags, ParseRestrictionsList, "kfreebsd-i386"); + parseDependency(StripMultiArch, ParseArchFlags, ParseRestrictionsList, "amd64"); } if (StripMultiArch == false) { if (ParseArchFlags == false) |