summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/hash.cc70
-rw-r--r--test/integration/framework51
-rwxr-xr-xtest/integration/test-bug-407511-fail-invalid-default-release47
-rwxr-xr-xtest/integration/test-bug-596498-trusted-unsigned-repo47
-rwxr-xr-xtest/integration/test-bug-632221-cross-dependency-satisfaction183
-rwxr-xr-xtest/integration/test-bug-633350-do-not-kill-last-char-in-Release27
-rwxr-xr-xtest/integration/test-handling-broken-orgroups4
-rwxr-xr-xtest/integration/test-release-candidate-switching2
-rwxr-xr-xtest/integration/test-ubuntu-bug-784473-InRelease-one-message-only31
-rwxr-xr-xtest/integration/test-ubuntu-bug-806274-install-suggests81
-rw-r--r--test/libapt/assert.h42
-rw-r--r--test/libapt/getarchitectures_test.cc6
-rw-r--r--test/libapt/getlanguages_test.cc4
-rw-r--r--test/libapt/hashsums_test.cc141
-rw-r--r--test/libapt/makefile6
-rwxr-xr-xtest/libapt/run-tests7
16 files changed, 667 insertions, 82 deletions
diff --git a/test/hash.cc b/test/hash.cc
deleted file mode 100644
index cfdb4ea9d..000000000
--- a/test/hash.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-#include <apt-pkg/md5.h>
-#include <apt-pkg/sha1.h>
-#include <apt-pkg/sha256.h>
-#include <apt-pkg/strutl.h>
-#include <iostream>
-
-using namespace std;
-
-template <class T> void Test(const char *In,const char *Out)
-{
- T Sum;
- Sum.Add(In);
- cout << Sum.Result().Value() << endl;
- if (stringcasecmp(Sum.Result().Value(),Out) != 0)
- abort();
-}
-
-template <class T> void TestMill(const char *Out)
-{
- T Sum;
-
- const unsigned char As[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
- unsigned Count = 1000000;
- for (; Count != 0;)
- {
- if (Count >= 64)
- {
- Sum.Add(As,64);
- Count -= 64;
- }
- else
- {
- Sum.Add(As,Count);
- Count = 0;
- }
- }
-
- cout << Sum.Result().Value() << endl;
- if (stringcasecmp(Sum.Result().Value(),Out) != 0)
- abort();
-}
-
-int main()
-{
- // From FIPS PUB 180-1
- Test<SHA1Summation>("abc","A9993E364706816ABA3E25717850C26C9CD0D89D");
- Test<SHA1Summation>("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "84983E441C3BD26EBAAE4AA1F95129E5E54670F1");
- TestMill<SHA1Summation>("34AA973CD4C4DAA4F61EEB2BDBAD27316534016F");
-
- // MD5 tests from RFC 1321
- Test<MD5Summation>("","d41d8cd98f00b204e9800998ecf8427e");
- Test<MD5Summation>("a","0cc175b9c0f1b6a831c399e269772661");
- Test<MD5Summation>("abc","900150983cd24fb0d6963f7d28e17f72");
- Test<MD5Summation>("message digest","f96b697d7cb7938d525a2f31aaf161d0");
- Test<MD5Summation>("abcdefghijklmnopqrstuvwxyz","c3fcd3d76192e4007dfb496cca67e13b");
- Test<MD5Summation>("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- "d174ab98d277d9f5a5611c2c9f419d9f");
- Test<MD5Summation>("12345678901234567890123456789012345678901234567890123456789012345678901234567890",
- "57edf4a22be3c955ac49da2e2107b67a");
-
- // SHA-256, From FIPS 180-2
- Test<SHA256Summation>("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
-
-
- return 0;
-}
-
-
diff --git a/test/integration/framework b/test/integration/framework
index cc5af798c..fa451cf4f 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -151,6 +151,7 @@ setupenvironment() {
configarchitecture() {
local CONFFILE=rootdir/etc/apt/apt.conf.d/01multiarch.conf
+ rm -f $CONFFILE
echo "APT::Architecture \"$1\";" > $CONFFILE
shift
while [ -n "$1" ]; do
@@ -429,6 +430,27 @@ Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE
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"
@@ -481,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}"
@@ -489,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
@@ -708,3 +747,9 @@ testmarkedauto() {
fi
aptmark showauto 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
}
+
+pause() {
+ echo "STOPPED execution. Press enter to continue"
+ local IGNORE
+ read IGNORE
+}
diff --git a/test/integration/test-bug-407511-fail-invalid-default-release b/test/integration/test-bug-407511-fail-invalid-default-release
new file mode 100755
index 000000000..d0a73af7d
--- /dev/null
+++ b/test/integration/test-bug-407511-fail-invalid-default-release
@@ -0,0 +1,47 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'i386'
+
+insertpackage 'unstable' 'cool' 'all' '1.0-1'
+
+getcodenamefromsuite() {
+ if [ "$SUITE" = 'unstable' ]; then
+ echo -n 'sid'
+ else
+ echo -n "$SUITE"
+ fi
+}
+getreleaseversionfromsuite() {
+ if [ "$SUITE" = 'unstable' ]; then
+ echo -n '42.0'
+ else
+ echo -n '0.8.15'
+ fi
+}
+
+setupaptarchive
+
+passdist() {
+ msgtest "Test that target-release is accepted" $1
+ aptget dist-upgrade -t $1 -qq && msgpass || msgfail
+}
+
+faildist() {
+ msgtest "Test that target-release is refused" $1
+ aptget dist-upgrade -t $1 -qq 2> /dev/null && msgfail || msgpass
+}
+
+passdist unstable
+passdist sid
+faildist sidd
+faildist stable
+passdist 42.0
+passdist 42.*
+passdist 42*
+passdist 4*.0
+faildist 21.0
+faildist 21*
diff --git a/test/integration/test-bug-596498-trusted-unsigned-repo b/test/integration/test-bug-596498-trusted-unsigned-repo
new file mode 100755
index 000000000..6ebc4a3bb
--- /dev/null
+++ b/test/integration/test-bug-596498-trusted-unsigned-repo
@@ -0,0 +1,47 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'i386'
+
+buildsimplenativepackage 'cool' 'i386' '1.0' 'unstable'
+
+setupaptarchive
+
+aptgetupdate() {
+ rm -rf rootdir/var/lib/apt/ rootdir/var/cache/apt/*.bin
+ aptget update -qq
+}
+
+PKGTEXT="$(aptget install cool --assume-no -d | head -n 7)"
+DEBFILE='rootdir/etc/apt/sources.list.d/apt-test-unstable-deb.list'
+
+testequal "$PKGTEXT
+Download complete and in download only mode" aptget install cool --assume-no -d
+
+sed -i -e 's#deb#deb [trusted=no]#' $DEBFILE
+aptgetupdate
+
+testequal "$PKGTEXT
+WARNING: The following packages cannot be authenticated!
+ cool
+Install these packages without verification [y/N]? N
+E: Some packages could not be authenticated" aptget install cool --assume-no -d
+
+find aptarchive/ \( -name 'Release.gpg' -o -name 'InRelease' \) -delete
+sed -i -e 's#deb \[trusted=no\]#deb#' $DEBFILE
+aptgetupdate
+
+testequal "$PKGTEXT
+WARNING: The following packages cannot be authenticated!
+ cool
+Install these packages without verification [y/N]? N
+E: Some packages could not be authenticated" aptget install cool --assume-no -d
+
+sed -i -e 's#deb#deb [trusted=yes]#' $DEBFILE
+aptgetupdate
+
+testequal "$PKGTEXT
+Download complete and in download only mode" aptget install cool --assume-no -d
diff --git a/test/integration/test-bug-632221-cross-dependency-satisfaction b/test/integration/test-bug-632221-cross-dependency-satisfaction
new file mode 100755
index 000000000..58de44843
--- /dev/null
+++ b/test/integration/test-bug-632221-cross-dependency-satisfaction
@@ -0,0 +1,183 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'armel'
+
+insertinstalledpackage 'build-essential' 'all' '11.5'
+
+insertpackage 'unstable' 'doxygen' 'amd64,armel' '1.0'
+insertpackage 'unstable' 'libc6' 'amd64,armel' '1.0' 'Multi-Arch: same'
+insertpackage 'unstable' 'libc6-dev' 'amd64,armel' '1.0' 'Depends: libc6
+Multi-Arch: same'
+insertpackage 'unstable' 'cool' 'amd64,armel' '1.0' 'Multi-Arch: allowed'
+insertpackage 'unstable' 'amdboot' 'amd64' '1.0'
+insertpackage 'unstable' 'foreigner' 'amd64,armel' '1.0' 'Multi-Arch: foreign'
+
+insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ amdboot cool doxygen foreigner libc6 libc6-dev
+0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
+Inst amdboot (1.0 unstable [amd64])
+Inst cool (1.0 unstable [amd64])
+Inst doxygen (1.0 unstable [amd64])
+Inst foreigner (1.0 unstable [amd64])
+Inst libc6 (1.0 unstable [amd64])
+Inst libc6-dev (1.0 unstable [amd64])
+Conf amdboot (1.0 unstable [amd64])
+Conf cool (1.0 unstable [amd64])
+Conf doxygen (1.0 unstable [amd64])
+Conf foreigner (1.0 unstable [amd64])
+Conf libc6 (1.0 unstable [amd64])
+Conf libc6-dev (1.0 unstable [amd64])' aptget build-dep apt -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ amdboot cool doxygen foreigner libc6 libc6:armel libc6-dev libc6-dev:armel
+0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
+Inst amdboot (1.0 unstable [amd64])
+Inst cool (1.0 unstable [amd64])
+Inst doxygen (1.0 unstable [amd64])
+Inst foreigner (1.0 unstable [amd64])
+Inst libc6:armel (1.0 unstable [armel])
+Inst libc6 (1.0 unstable [amd64])
+Inst libc6-dev:armel (1.0 unstable [armel])
+Inst libc6-dev (1.0 unstable [amd64])
+Conf amdboot (1.0 unstable [amd64])
+Conf cool (1.0 unstable [amd64])
+Conf doxygen (1.0 unstable [amd64])
+Conf foreigner (1.0 unstable [amd64])
+Conf libc6 (1.0 unstable [amd64])
+Conf libc6:armel (1.0 unstable [armel])
+Conf libc6-dev (1.0 unstable [amd64])
+Conf libc6-dev:armel (1.0 unstable [armel])' aptget build-dep apt -s -a armel
+
+configarchitecture 'armel' 'amd64'
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ amdboot:amd64 cool doxygen foreigner libc6 libc6-dev
+0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
+Inst amdboot:amd64 (1.0 unstable [amd64])
+Inst cool (1.0 unstable [armel])
+Inst doxygen (1.0 unstable [armel])
+Inst foreigner (1.0 unstable [armel])
+Inst libc6 (1.0 unstable [armel])
+Inst libc6-dev (1.0 unstable [armel])
+Conf amdboot:amd64 (1.0 unstable [amd64])
+Conf cool (1.0 unstable [armel])
+Conf doxygen (1.0 unstable [armel])
+Conf foreigner (1.0 unstable [armel])
+Conf libc6 (1.0 unstable [armel])
+Conf libc6-dev (1.0 unstable [armel])' aptget build-dep apt -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ amdboot:amd64 cool doxygen foreigner libc6:amd64 libc6 libc6-dev:amd64
+ libc6-dev
+0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
+Inst amdboot:amd64 (1.0 unstable [amd64])
+Inst cool (1.0 unstable [armel])
+Inst doxygen (1.0 unstable [armel])
+Inst foreigner (1.0 unstable [armel])
+Inst libc6 (1.0 unstable [armel])
+Inst libc6:amd64 (1.0 unstable [amd64])
+Inst libc6-dev (1.0 unstable [armel])
+Inst libc6-dev:amd64 (1.0 unstable [amd64])
+Conf amdboot:amd64 (1.0 unstable [amd64])
+Conf cool (1.0 unstable [armel])
+Conf doxygen (1.0 unstable [armel])
+Conf foreigner (1.0 unstable [armel])
+Conf libc6:amd64 (1.0 unstable [amd64])
+Conf libc6 (1.0 unstable [armel])
+Conf libc6-dev:amd64 (1.0 unstable [amd64])
+Conf libc6-dev (1.0 unstable [armel])' aptget build-dep apt -s -a amd64
+
+configarchitecture 'amd64' 'armel'
+
+insertinstalledpackage 'cool' 'amd64' '0.5'
+insertinstalledpackage 'foreigner' 'armel' '0.5'
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ amdboot doxygen libc6 libc6-dev
+0 upgraded, 4 newly installed, 0 to remove and 2 not upgraded.
+Inst amdboot (1.0 unstable [amd64])
+Inst doxygen (1.0 unstable [amd64])
+Inst libc6 (1.0 unstable [amd64])
+Inst libc6-dev (1.0 unstable [amd64])
+Conf amdboot (1.0 unstable [amd64])
+Conf doxygen (1.0 unstable [amd64])
+Conf libc6 (1.0 unstable [amd64])
+Conf libc6-dev (1.0 unstable [amd64])' aptget build-dep apt -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ amdboot doxygen libc6 libc6:armel libc6-dev libc6-dev:armel
+0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.
+Inst amdboot (1.0 unstable [amd64])
+Inst doxygen (1.0 unstable [amd64])
+Inst libc6:armel (1.0 unstable [armel])
+Inst libc6 (1.0 unstable [amd64])
+Inst libc6-dev:armel (1.0 unstable [armel])
+Inst libc6-dev (1.0 unstable [amd64])
+Conf amdboot (1.0 unstable [amd64])
+Conf doxygen (1.0 unstable [amd64])
+Conf libc6 (1.0 unstable [amd64])
+Conf libc6:armel (1.0 unstable [armel])
+Conf libc6-dev (1.0 unstable [amd64])
+Conf libc6-dev:armel (1.0 unstable [armel])' aptget build-dep apt -s -a armel
+
+configarchitecture 'armel' 'amd64'
+
+# cool 0.5 is not M-A: allowed, so amd64 is not acceptable
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ cool:amd64
+The following NEW packages will be installed:
+ amdboot:amd64 cool doxygen libc6 libc6-dev
+0 upgraded, 5 newly installed, 1 to remove and 1 not upgraded.
+Remv cool:amd64 [0.5]
+Inst amdboot:amd64 (1.0 unstable [amd64])
+Inst cool (1.0 unstable [armel])
+Inst doxygen (1.0 unstable [armel])
+Inst libc6 (1.0 unstable [armel])
+Inst libc6-dev (1.0 unstable [armel])
+Conf amdboot:amd64 (1.0 unstable [amd64])
+Conf cool (1.0 unstable [armel])
+Conf doxygen (1.0 unstable [armel])
+Conf libc6 (1.0 unstable [armel])
+Conf libc6-dev (1.0 unstable [armel])' aptget build-dep apt -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ amdboot:amd64 doxygen libc6:amd64 libc6 libc6-dev:amd64 libc6-dev
+0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.
+Inst amdboot:amd64 (1.0 unstable [amd64])
+Inst doxygen (1.0 unstable [armel])
+Inst libc6 (1.0 unstable [armel])
+Inst libc6:amd64 (1.0 unstable [amd64])
+Inst libc6-dev (1.0 unstable [armel])
+Inst libc6-dev:amd64 (1.0 unstable [amd64])
+Conf amdboot:amd64 (1.0 unstable [amd64])
+Conf doxygen (1.0 unstable [armel])
+Conf libc6:amd64 (1.0 unstable [amd64])
+Conf libc6 (1.0 unstable [armel])
+Conf libc6-dev:amd64 (1.0 unstable [amd64])
+Conf libc6-dev (1.0 unstable [armel])' aptget build-dep apt -s -a amd64
+
+
diff --git a/test/integration/test-bug-633350-do-not-kill-last-char-in-Release b/test/integration/test-bug-633350-do-not-kill-last-char-in-Release
new file mode 100755
index 000000000..3d3835507
--- /dev/null
+++ b/test/integration/test-bug-633350-do-not-kill-last-char-in-Release
@@ -0,0 +1,27 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64'
+
+insertpackage 'unstable' 'cool' 'amd64' '1.0'
+
+setupaptarchive 2> /dev/null
+
+echo 'NotAutomatic: yes' >> aptarchive/dists/unstable/Release
+
+signreleasefiles
+find aptarchive/dists -name 'InRelease' -delete
+
+rm -rf rootdir/var/lib/apt/lists rootdir/var/cache/apt
+
+OUTPUT="$(aptget update 2>&1)"
+msgtest 'Check that parsing happens without warnings' 'with missing newline'
+if echo "${OUTPUT}" | grep '^W:' > /dev/null; then
+ msgfail
+ echo "${OUTPUT}"
+else
+ msgpass
+fi
diff --git a/test/integration/test-handling-broken-orgroups b/test/integration/test-handling-broken-orgroups
index d88ad0000..20b314074 100755
--- a/test/integration/test-handling-broken-orgroups
+++ b/test/integration/test-handling-broken-orgroups
@@ -58,7 +58,7 @@ The following information may help to resolve the situation:
The following packages have unmet dependencies:
coolstuff-broken : Depends: cool2 but it is not installable or
stuff2 but it is not installable
-E: Broken packages' aptget install coolstuff-broken -s
+E: Unable to correct problems, you have held broken packages.' aptget install coolstuff-broken -s
testequal 'Reading package lists...
Building dependency tree...
@@ -105,4 +105,4 @@ The following information may help to resolve the situation:
The following packages have unmet dependencies:
coolstuff-provided-broken : Depends: cool2 but it is not installable or
stuff-abi-2
-E: Broken packages' aptget install coolstuff-provided-broken -s
+E: Unable to correct problems, you have held broken packages.' aptget install coolstuff-provided-broken -s
diff --git a/test/integration/test-release-candidate-switching b/test/integration/test-release-candidate-switching
index b6dbe99db..0970cb935 100755
--- a/test/integration/test-release-candidate-switching
+++ b/test/integration/test-release-candidate-switching
@@ -416,4 +416,4 @@ The following information may help to resolve the situation:
The following packages have unmet dependencies:
uninstallablepkg : Depends: libmtp8 (>= 10:0.20.1) but it is not going to be installed
Depends: amarok-utils (= 2.3.2-2+exp) but 2.3.1-1+sid is to be installed
-E: Broken packages" aptget install uninstallablepkg/experimental --trivial-only -V -q=0
+E: Unable to correct problems, you have held broken packages." aptget install uninstallablepkg/experimental --trivial-only -V -q=0
diff --git a/test/integration/test-ubuntu-bug-784473-InRelease-one-message-only b/test/integration/test-ubuntu-bug-784473-InRelease-one-message-only
new file mode 100755
index 000000000..d97011914
--- /dev/null
+++ b/test/integration/test-ubuntu-bug-784473-InRelease-one-message-only
@@ -0,0 +1,31 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'i386'
+
+insertpackage 'unstable' 'apt' 'i386' '0.8.11'
+
+setupaptarchive
+
+rm -rf rootdir/var/lib/apt/lists
+
+find aptarchive/ -name 'Release.gpg' -delete
+find aptarchive/ -name 'InRelease' -exec cp {} {}.old \;
+
+for RELEASE in $(find aptarchive/ -name 'InRelease'); do
+ (echo 'Origin: Marvin
+Label: Marvin
+Suite: experimental
+Codename: experimental
+MD5Sum:
+ 65fd410587b6978de2277f2912523f09 9360 Packages
+ d27b294ed172a1fa9dd5a53949914c5d 4076 Packages.bz2
+ 2182897e0a2a0c09e760beaae117a015 2023 Packages.diff/Index
+ 1b895931853981ad8204d2439821b999 4144 Packages.gz'; echo; cat ${RELEASE}.old;) > ${RELEASE}
+done
+aptget update -qq > /dev/null 2> starts-with-unsigned.msg
+sed -i 's#File .*InRelease#File InRelease#' starts-with-unsigned.msg
+testfileequal starts-with-unsigned.msg "W: GPG error: file: unstable InRelease: File InRelease doesn't start with a clearsigned message"
diff --git a/test/integration/test-ubuntu-bug-806274-install-suggests b/test/integration/test-ubuntu-bug-806274-install-suggests
new file mode 100755
index 000000000..fb72f0999
--- /dev/null
+++ b/test/integration/test-ubuntu-bug-806274-install-suggests
@@ -0,0 +1,81 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+
+insertpackage 'unstable' 'apt' 'i386' '0.8.15' 'Depends: foo
+Recommends: bar
+Suggests: baz'
+insertpackage 'unstable' 'foo' 'i386' '1.0'
+insertpackage 'unstable' 'bar' 'i386' '1.0'
+insertpackage 'unstable' 'baz' 'i386' '1.0'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ bar foo
+Suggested packages:
+ baz
+The following NEW packages will be installed:
+ apt bar foo
+0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1.0 unstable [i386])
+Conf foo (1.0 unstable [i386])
+Inst apt (0.8.15 unstable [i386])
+Conf apt (0.8.15 unstable [i386])
+Inst bar (1.0 unstable [i386])
+Conf bar (1.0 unstable [i386])' aptget install apt -s --install-recommends --no-install-suggests
+
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ bar baz foo
+The following NEW packages will be installed:
+ apt bar baz foo
+0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1.0 unstable [i386])
+Conf foo (1.0 unstable [i386])
+Inst apt (0.8.15 unstable [i386])
+Conf apt (0.8.15 unstable [i386])
+Inst bar (1.0 unstable [i386])
+Inst baz (1.0 unstable [i386])
+Conf bar (1.0 unstable [i386])
+Conf baz (1.0 unstable [i386])' aptget install apt -s --install-recommends --install-suggests
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ foo
+Suggested packages:
+ baz
+Recommended packages:
+ bar
+The following NEW packages will be installed:
+ apt foo
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1.0 unstable [i386])
+Conf foo (1.0 unstable [i386])
+Inst apt (0.8.15 unstable [i386])
+Conf apt (0.8.15 unstable [i386])' aptget install apt -s --no-install-recommends --no-install-suggests
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ baz foo
+Recommended packages:
+ bar
+The following NEW packages will be installed:
+ apt baz foo
+0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1.0 unstable [i386])
+Conf foo (1.0 unstable [i386])
+Inst apt (0.8.15 unstable [i386])
+Conf apt (0.8.15 unstable [i386])
+Inst baz (1.0 unstable [i386])
+Conf baz (1.0 unstable [i386])' aptget install apt -s --no-install-recommends --install-suggests
diff --git a/test/libapt/assert.h b/test/libapt/assert.h
index 5da76ae0a..92b662dfa 100644
--- a/test/libapt/assert.h
+++ b/test/libapt/assert.h
@@ -1,9 +1,9 @@
#include <iostream>
-#define equals(x,y) assertEquals(x, y, __LINE__)
+#define equals(x,y) assertEquals(y, x, __LINE__)
template < typename X, typename Y >
-void OutputAssert(X expect, char const* compare, Y get, unsigned long const &line) {
+void OutputAssertEqual(X expect, char const* compare, Y get, unsigned long const &line) {
std::cerr << "Test FAILED: »" << expect << "« " << compare << " »" << get << "« at line " << line << std::endl;
}
@@ -11,11 +11,45 @@ template < typename X, typename Y >
void assertEquals(X expect, Y get, unsigned long const &line) {
if (expect == get)
return;
- OutputAssert(expect, "==", get, line);
+ OutputAssertEqual(expect, "==", get, line);
}
void assertEquals(unsigned int const &expect, int const &get, unsigned long const &line) {
if (get < 0)
- OutputAssert(expect, "==", get, line);
+ OutputAssertEqual(expect, "==", get, line);
assertEquals<unsigned int const&, unsigned int const&>(expect, get, line);
}
+
+void assertEquals(int const &expect, unsigned int const &get, unsigned long const &line) {
+ if (expect < 0)
+ OutputAssertEqual(expect, "==", get, line);
+ assertEquals<unsigned int const&, unsigned int const&>(expect, get, line);
+}
+
+
+#define equalsOr2(x,y,z) assertEqualsOr2(y, z, x, __LINE__)
+
+template < typename X, typename Y >
+void OutputAssertEqualOr2(X expect1, X expect2, char const* compare, Y get, unsigned long const &line) {
+ std::cerr << "Test FAILED: »" << expect1 << "« or »" << expect2 << "« " << compare << " »" << get << "« at line " << line << std::endl;
+}
+
+template < typename X, typename Y >
+void assertEqualsOr2(X expect1, X expect2, Y get, unsigned long const &line) {
+ if (expect1 == get || expect2 == get)
+ return;
+ OutputAssertEqualOr2(expect1, expect2, "==", get, line);
+}
+
+void assertEqualsOr2(unsigned int const &expect1, unsigned int const &expect2, int const &get, unsigned long const &line) {
+ if (get < 0)
+ OutputAssertEqualOr2(expect1, expect2, "==", get, line);
+ assertEqualsOr2<unsigned int const&, unsigned int const&>(expect1, expect2, get, line);
+}
+
+void assertEqualsOr2(int const &expect1, int const &expect2, unsigned int const &get, unsigned long const &line) {
+ if (expect1 < 0 && expect2 < 0)
+ OutputAssertEqualOr2(expect1, expect2, "==", get, line);
+ assertEqualsOr2<unsigned int const&, unsigned int const&>(expect1, expect2, get, line);
+}
+
diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc
index 1500caeed..e3ca7bbc2 100644
--- a/test/libapt/getarchitectures_test.cc
+++ b/test/libapt/getarchitectures_test.cc
@@ -39,6 +39,12 @@ int main(int argc,char *argv[])
_config->Set("APT::Architecture", "armel");
vec = APT::Configuration::getArchitectures(false);
equals(vec.size(), 2);
+ equals(vec[0], "armel");
+ equals(vec[1], "i386");
+
+ _config->Set("APT::Architectures::2", "armel");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 2);
equals(vec[0], "i386");
equals(vec[1], "armel");
diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc
index 707142aef..3d63e0e74 100644
--- a/test/libapt/getlanguages_test.cc
+++ b/test/libapt/getlanguages_test.cc
@@ -138,8 +138,8 @@ int main(int argc,char *argv[])
equals(vec[1], "de");
equals(vec[2], "en");
equals(vec[3], "none");
- equals(vec[4], "pt");
- equals(vec[5], "tr");
+ equalsOr2(vec[4], "pt", "tr");
+ equalsOr2(vec[5], "tr", "pt");
_config->Set("Dir::State::lists", "/non-existing-dir");
_config->Set("Acquire::Languages::1", "none");
diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc
new file mode 100644
index 000000000..ff1536718
--- /dev/null
+++ b/test/libapt/hashsums_test.cc
@@ -0,0 +1,141 @@
+#include <apt-pkg/md5.h>
+#include <apt-pkg/sha1.h>
+#include <apt-pkg/sha2.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/hashes.h>
+#include <iostream>
+
+#include <stdio.h>
+
+#include "assert.h"
+
+template <class T> void Test(const char *In,const char *Out)
+{
+ T Sum;
+ Sum.Add(In);
+ equals(Sum.Result().Value(), Out);
+}
+
+template <class T> void TestMill(const char *Out)
+{
+ T Sum;
+
+ const unsigned char As[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+ unsigned Count = 1000000;
+ for (; Count != 0;)
+ {
+ if (Count >= 64)
+ {
+ Sum.Add(As,64);
+ Count -= 64;
+ }
+ else
+ {
+ Sum.Add(As,Count);
+ Count = 0;
+ }
+ }
+
+ if (stringcasecmp(Sum.Result().Value(), Out) != 0)
+ abort();
+}
+
+int main(int argc, char** argv)
+{
+ // From FIPS PUB 180-1
+ Test<SHA1Summation>("","da39a3ee5e6b4b0d3255bfef95601890afd80709");
+ Test<SHA1Summation>("abc","a9993e364706816aba3e25717850c26c9cd0d89d");
+ Test<SHA1Summation>("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
+ TestMill<SHA1Summation>("34aa973cd4c4daa4f61eeb2bdbad27316534016f");
+
+ // MD5 tests from RFC 1321
+ Test<MD5Summation>("","d41d8cd98f00b204e9800998ecf8427e");
+ Test<MD5Summation>("a","0cc175b9c0f1b6a831c399e269772661");
+ Test<MD5Summation>("abc","900150983cd24fb0d6963f7d28e17f72");
+ Test<MD5Summation>("message digest","f96b697d7cb7938d525a2f31aaf161d0");
+ Test<MD5Summation>("abcdefghijklmnopqrstuvwxyz","c3fcd3d76192e4007dfb496cca67e13b");
+ Test<MD5Summation>("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ "d174ab98d277d9f5a5611c2c9f419d9f");
+ Test<MD5Summation>("12345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "57edf4a22be3c955ac49da2e2107b67a");
+
+ // SHA-256, From FIPS 180-2
+ Test<SHA256Summation>("", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
+ Test<SHA256Summation>("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
+
+ // SHA-512
+ Test<SHA512Summation>("",
+ "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce"
+ "47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e");
+ Test<SHA512Summation>(
+ "abc",
+ "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a"
+ "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f");
+
+
+ Test<MD5Summation>("The quick brown fox jumps over the lazy dog", "9e107d9d372bb6826bd81d3542a419d6");
+ Test<MD5Summation>("The quick brown fox jumps over the lazy dog.", "e4d909c290d0fb1ca068ffaddf22cbd0");
+ Test<SHA1Summation>("The quick brown fox jumps over the lazy dog", "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12");
+ Test<SHA1Summation>("The quick brown fox jumps over the lazy cog", "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3");
+ Test<SHA256Summation>("The quick brown fox jumps over the lazy dog", "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592");
+ Test<SHA256Summation>("The quick brown fox jumps over the lazy dog.", "ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c");
+ Test<SHA512Summation>("The quick brown fox jumps over the lazy dog", "07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb64"
+ "2e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6");
+ Test<SHA512Summation>("The quick brown fox jumps over the lazy dog.", "91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bb"
+ "c6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed");
+
+ FILE* fd = fopen(argv[1], "r");
+ if (fd == NULL) {
+ std::cerr << "Can't open file for 1. testing: " << argv[1] << std::endl;
+ return 1;
+ }
+ {
+ Hashes hashes;
+ hashes.AddFD(fileno(fd));
+ equals(argv[2], hashes.MD5.Result().Value());
+ equals(argv[3], hashes.SHA1.Result().Value());
+ equals(argv[4], hashes.SHA256.Result().Value());
+ equals(argv[5], hashes.SHA512.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_END);
+ unsigned long sz = ftell(fd);
+ fseek(fd, 0L, SEEK_SET);
+ {
+ Hashes hashes;
+ hashes.AddFD(fileno(fd), sz);
+ equals(argv[2], hashes.MD5.Result().Value());
+ equals(argv[3], hashes.SHA1.Result().Value());
+ equals(argv[4], hashes.SHA256.Result().Value());
+ equals(argv[5], hashes.SHA512.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ MD5Summation md5;
+ md5.AddFD(fileno(fd));
+ equals(argv[2], md5.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ SHA1Summation sha1;
+ sha1.AddFD(fileno(fd));
+ equals(argv[3], sha1.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ SHA256Summation sha2;
+ sha2.AddFD(fileno(fd));
+ equals(argv[4], sha2.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ SHA512Summation sha2;
+ sha2.AddFD(fileno(fd));
+ equals(argv[5], sha2.Result().Value());
+ }
+ fclose(fd);
+ return 0;
+}
+
+
diff --git a/test/libapt/makefile b/test/libapt/makefile
index fec928ad2..a8acabd8e 100644
--- a/test/libapt/makefile
+++ b/test/libapt/makefile
@@ -47,6 +47,12 @@ SLIBS = -lapt-pkg
SOURCE = globalerror_test.cc
include $(PROGRAM_H)
+# test the different Hashsum classes
+PROGRAM = HashSums${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = hashsums_test.cc
+include $(PROGRAM_H)
+
# test the strutils stuff
PROGRAM = StrUtil${BASENAME}
SLIBS = -lapt-pkg
diff --git a/test/libapt/run-tests b/test/libapt/run-tests
index 4b71c2097..0eea6d4f8 100755
--- a/test/libapt/run-tests
+++ b/test/libapt/run-tests
@@ -53,6 +53,13 @@ do
"${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \
"${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \
"${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak"
+ elif [ $name = "HashSums${EXT}" ]; then
+ TMP="$(mktemp)"
+ dmesg > $TMP
+ echo -n "Testing with \033[1;35m${name}\033[0m ... "
+ LD_LIBRARY_PATH=${LDPATH} ${testapp} $TMP $(md5sum $TMP | cut -d' ' -f 1) $(sha1sum $TMP | cut -d' ' -f 1) $(sha256sum $TMP | cut -d' ' -f 1) $(sha512sum $TMP | cut -d' ' -f 1) && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m"
+ rm $TMP
+ continue
fi
echo -n "Testing with \033[1;35m${name}\033[0m ... "