From a3bbbab7ca5f94391b2158cfe9deb85eb335e29a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 16 Jul 2011 16:48:03 +0200 Subject: * apt-pkg/policy.cc: - emit an error on unknown APT::Default-Release value (Closes: #407511) --- test/integration/framework | 23 +++++++++-- .../test-bug-407511-fail-invalid-default-release | 47 ++++++++++++++++++++++ 2 files changed, 67 insertions(+), 3 deletions(-) create mode 100755 test/integration/test-bug-407511-fail-invalid-default-release (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index 96cdb5f5e..702e352a3 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -481,6 +481,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 +493,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 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* -- cgit v1.2.3 From c3182c823bdba037e7f1daaffde8b44155ff4f48 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 25 Jul 2011 13:40:50 +0200 Subject: update the testcase to reflect that native is always on top if it is not in the config provided list of Architectures --- test/libapt/getarchitectures_test.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') 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"); -- cgit v1.2.3 From fce1153321e432ed4a64e9742a8fc1c5558124e4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 25 Jul 2011 13:55:23 +0200 Subject: the order of languages after "none" is not important, so ignore it in tests --- test/libapt/assert.h | 42 ++++++++++++++++++++++++++++++++++++---- test/libapt/getlanguages_test.cc | 4 ++-- 2 files changed, 40 insertions(+), 6 deletions(-) (limited to 'test') 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 -#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(expect, get, line); } + +void assertEquals(int const &expect, unsigned int const &get, unsigned long const &line) { + if (expect < 0) + OutputAssertEqual(expect, "==", get, line); + assertEquals(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(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(expect1, expect2, get, line); +} + 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"); -- cgit v1.2.3 From 234675b71a2caab5c7cc0dc3b32a241683d3b3d2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 25 Jul 2011 14:40:22 +0200 Subject: implement MultiarchCross for build-dep and source (Closes: #632221) --- test/integration/framework | 22 +++ .../test-bug-632221-cross-dependency-satisfaction | 183 +++++++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100755 test/integration/test-bug-632221-cross-dependency-satisfaction (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index 702e352a3..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 +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" 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 + + -- cgit v1.2.3 From a513ace2d2e3b71d607257990893199c6105b072 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 26 Jul 2011 10:49:28 +0200 Subject: * apt-pkg/contrib/strutl.{h,cc}, test/libapt/strutil_test.cc: - add new DeEscapeString() similar to DeQuoteQuotedWord but unescape charackter escapes like \0XXX and \xXX (plus add test) --- test/libapt/makefile | 6 ++++++ test/libapt/strutil_test.cc | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 test/libapt/strutil_test.cc (limited to 'test') diff --git a/test/libapt/makefile b/test/libapt/makefile index 50058262e..fec928ad2 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -46,3 +46,9 @@ PROGRAM = GlobalError${BASENAME} SLIBS = -lapt-pkg SOURCE = globalerror_test.cc include $(PROGRAM_H) + +# test the strutils stuff +PROGRAM = StrUtil${BASENAME} +SLIBS = -lapt-pkg +SOURCE = strutil_test.cc +include $(PROGRAM_H) diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc new file mode 100644 index 000000000..8d81a0c6c --- /dev/null +++ b/test/libapt/strutil_test.cc @@ -0,0 +1,40 @@ +#include + +#include "assert.h" + +int main(int argc,char *argv[]) +{ + string input, output, expected; + + // no input + input = "foobar"; + expected = "foobar"; + output = DeEscapeString(input); + equals(output, expected); + + // hex and octal + input = "foo\\040bar\\x0abaz"; + expected = "foo bar\nbaz"; + output = DeEscapeString(input); + equals(output, expected); + + // at the end + input = "foo\\040"; + expected = "foo "; + output = DeEscapeString(input); + equals(output, expected); + + // double escape + input = "foo\\\\ x"; + expected = "foo\\ x"; + output = DeEscapeString(input); + equals(output, expected); + + // double escape at the end + input = "\\\\foo\\\\"; + expected = "\\foo\\"; + output = DeEscapeString(input); + equals(output, expected); + + return 0; +} -- cgit v1.2.3 From b9dc47069ab90a79ca3b9eae3cc85d38062d57ee Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 26 Jul 2011 11:10:47 +0200 Subject: add another escape test case, fixup octal one (its \0XX instead of \0XXX) --- test/libapt/strutil_test.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc index 8d81a0c6c..af6eb2cc6 100644 --- a/test/libapt/strutil_test.cc +++ b/test/libapt/strutil_test.cc @@ -36,5 +36,11 @@ int main(int argc,char *argv[]) output = DeEscapeString(input); equals(output, expected); + // the string that we actually need it for + input = "/media/Ubuntu\\04011.04\\040amd64"; + expected = "/media/Ubuntu 11.04 amd64"; + output = DeEscapeString(input); + equals(output, expected); + return 0; } -- cgit v1.2.3 From ae6ea526d65eb560b825677e8aac4a3fa15934e4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 27 Jul 2011 23:50:55 +0200 Subject: * apt-pkg/deb/deblistparser.cc: - do not assume that the last char on a line is a \n (Closes: #633350) --- ...est-bug-633350-do-not-kill-last-char-in-Release | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 test/integration/test-bug-633350-do-not-kill-last-char-in-Release (limited to 'test') 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 -- cgit v1.2.3 From e99a544c8c48d8067d008b5c7e4e1d5479529ce2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 29 Jul 2011 16:33:20 +0200 Subject: test/libapt/hashsums_test.cc: add a test for HashString and VerifyFile --- test/libapt/hashsums_test.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc index ff1536718..2cb71cc38 100644 --- a/test/libapt/hashsums_test.cc +++ b/test/libapt/hashsums_test.cc @@ -135,6 +135,21 @@ int main(int argc, char** argv) equals(argv[5], sha2.Result().Value()); } fclose(fd); + + // test HashString code + { + HashString sha2("SHA256", argv[4]); + equals(sha2.VerifyFile(argv[1]), true); + } + { + HashString sha2("SHA512", argv[5]); + equals(sha2.VerifyFile(argv[1]), true); + } + { + HashString sha2("SHA256:"+string(argv[4])); + equals(sha2.VerifyFile(argv[1]), true); + } + return 0; } -- cgit v1.2.3 From 515d18c9b271e4188dd4c59939c3c3cfeaf575a8 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 5 Aug 2011 11:49:59 +0200 Subject: * test/integration/test-hashsum-verification: - add regression test for hashsum verification --- test/integration/test-hashsum-verification | 76 ++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 test/integration/test-hashsum-verification (limited to 'test') diff --git a/test/integration/test-hashsum-verification b/test/integration/test-hashsum-verification new file mode 100755 index 000000000..29420c098 --- /dev/null +++ b/test/integration/test-hashsum-verification @@ -0,0 +1,76 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture "i386" + +buildaptarchive +setupflataptarchive +changetowebserver + +prepare() { + local DATE="${2:-now}" + if [ "$DATE" = 'now' -a "$1" = "${PKGFILE}-new" ]; then + DATE='now + 6 days' + fi + for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do + touch -d 'now - 6 hours' $release + done + rm -rf rootdir/var/cache/apt/archives + rm -f rootdir/var/cache/apt/*.bin + cp $1 aptarchive/Packages + find aptarchive -name 'Release' -delete + cat aptarchive/Packages | gzip > aptarchive/Packages.gz + cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2 + cat aptarchive/Packages | lzma > aptarchive/Packages.lzma + # create Release file with incorret checksums + cat > aptarchive/Release <&1 | grep "Hash Sum mismatch" > /dev/null && msgpass || msgfail + msgtest 'No package from the source available' + [ "$(aptcache show apt 2>&1)" = "E: No packages found" ] && msgpass || msgfail + msgtest 'No Packages file in /var/lib/apt/lists' + [ "$(ls rootdir/var/lib/apt/lists/*Package* 2>/dev/null)" = "" ] && msgpass || msgfail + +} + +runtest + -- cgit v1.2.3 From 3568a640bd363409cdeb1cb69eaa3261c79f2ff2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 5 Aug 2011 12:26:35 +0200 Subject: * apt-pkg/acquire-item.cc: - if no Release.gpg file is found, still load the hashes for verification (closes: #636314) and add test --- test/integration/test-hashsum-verification | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/integration/test-hashsum-verification b/test/integration/test-hashsum-verification index 29420c098..033096ee8 100755 --- a/test/integration/test-hashsum-verification +++ b/test/integration/test-hashsum-verification @@ -70,6 +70,13 @@ runtest() { msgtest 'No Packages file in /var/lib/apt/lists' [ "$(ls rootdir/var/lib/apt/lists/*Package* 2>/dev/null)" = "" ] && msgpass || msgfail + # now with the unsigned Release file + rm -rf rootdir/var/lib/apt/lists + rm aptarchive/InRelease aptarchive/Release.gpg + msgtest 'unsigned apt-get update gets the expected hashsum mismatch' + aptget update 2>&1 | grep "Hash Sum mismatch" > /dev/null && msgpass || msgfail + + } runtest -- cgit v1.2.3 From f7f0d6c7560a8f71707e7852a512469147aa9f84 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 20:53:28 +0200 Subject: cppcheck complains about some possible speed improvements which could be done on the mirco-optimazation level, so lets fix them: (performance) Possible inefficient checking for emptiness. (performance) Prefer prefix ++/-- operators for non-primitive types. --- test/libapt/assert.h | 8 ++++++++ test/libapt/getarchitectures_test.cc | 7 ------- test/libapt/getlanguages_test.cc | 7 ------- test/libapt/getlistoffilesindir_test.cc | 7 ------- test/test_udevcdrom.cc | 2 +- 5 files changed, 9 insertions(+), 22 deletions(-) (limited to 'test') diff --git a/test/libapt/assert.h b/test/libapt/assert.h index 92b662dfa..fae9b6c64 100644 --- a/test/libapt/assert.h +++ b/test/libapt/assert.h @@ -53,3 +53,11 @@ void assertEqualsOr2(int const &expect1, int const &expect2, unsigned int const assertEqualsOr2(expect1, expect2, get, line); } + +// simple helper to quickly output a vectors +template < typename X > +void dumpVector(X vec) { + for (typename X::const_iterator v = vec.begin(); + v != vec.end(); ++v) + std::cout << *v << std::endl; +} diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc index e3ca7bbc2..807469263 100644 --- a/test/libapt/getarchitectures_test.cc +++ b/test/libapt/getarchitectures_test.cc @@ -7,13 +7,6 @@ #include -// simple helper to quickly output a vector of strings -void dumpVector(std::vector vec) { - for (std::vector::const_iterator v = vec.begin(); - v != vec.end(); v++) - std::cout << *v << std::endl; -} - int main(int argc,char *argv[]) { std::vector vec; diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc index 3d63e0e74..f6aa7a697 100644 --- a/test/libapt/getlanguages_test.cc +++ b/test/libapt/getlanguages_test.cc @@ -7,13 +7,6 @@ #include -// simple helper to quickly output a vector of strings -void dumpVector(std::vector vec) { - for (std::vector::const_iterator v = vec.begin(); - v != vec.end(); v++) - std::cout << *v << std::endl; -} - int main(int argc,char *argv[]) { if (argc != 2) { diff --git a/test/libapt/getlistoffilesindir_test.cc b/test/libapt/getlistoffilesindir_test.cc index ed8d2dad6..5ee014cca 100644 --- a/test/libapt/getlistoffilesindir_test.cc +++ b/test/libapt/getlistoffilesindir_test.cc @@ -7,13 +7,6 @@ #include #include -// simple helper to quickly output a vector of strings -void dumpVector(std::vector vec) { - for (std::vector::const_iterator v = vec.begin(); - v != vec.end(); v++) - std::cout << *v << std::endl; -} - #define P(x) string(argv[1]).append("/").append(x) int main(int argc,char *argv[]) diff --git a/test/test_udevcdrom.cc b/test/test_udevcdrom.cc index e65c7a297..577e2d013 100644 --- a/test/test_udevcdrom.cc +++ b/test/test_udevcdrom.cc @@ -10,7 +10,7 @@ int main() vector l; l = c.Scan(); - assert(l.size() > 0); + assert(l.empty() == false); for (i=0;i Date: Fri, 12 Aug 2011 09:58:55 +0200 Subject: cherry pick test/integration/Packages-hashsum-verification addition from lp:~mvo/apt/mvo --- test/integration/Packages-hashsum-verification | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/integration/Packages-hashsum-verification (limited to 'test') diff --git a/test/integration/Packages-hashsum-verification b/test/integration/Packages-hashsum-verification new file mode 100644 index 000000000..29a385f4f --- /dev/null +++ b/test/integration/Packages-hashsum-verification @@ -0,0 +1,18 @@ +Package: apt +Version: 0.7.25.3 +Architecture: i386 +Maintainer: APT Development Team +Installed-Size: 5244 +Replaces: libapt-pkg-dev (<< 0.3.7), libapt-pkg-doc (<< 0.3.7) +Provides: libapt-pkg-libc6.9-6-4.8 +Suggests: aptitude | synaptic | wajig, dpkg-dev, apt-doc, bzip2, lzma, python-apt +Filename: apt.deb +Size: 0 +MD5sum: d41d8cd98f00b204e9800998ecf8427e +Description: Advanced front-end for dpkg + This is Debian's next generation front-end for the dpkg package manager. + It provides the apt-get utility and APT dselect method that provides a + simpler, safer way to install and upgrade packages. + . + APT features complete installation ordering, multiple source capability + and several other unique features, see the Users Guide in apt-doc. -- cgit v1.2.3