From fce726023f703c369ae030684e75ed03c7544d6b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 21 Dec 2007 13:56:19 +0100 Subject: implement AptAuthenticationReliabtlity spec --- ..._apt_auth-test-suit_gpg-package-broken_Packages | 25 ++++++ ...o_apt_auth-test-suit_gpg-package-broken_Release | 13 +++ ...t_auth-test-suit_gpg-package-broken_Release.gpg | 7 ++ ...emvo_apt_auth-test-suit_gpg-package-ok_Packages | 25 ++++++ ...7emvo_apt_auth-test-suit_gpg-package-ok_Release | 13 +++ ...o_apt_auth-test-suit_gpg-package-ok_Release.gpg | 7 ++ test/authReliability/sources.list.failure | 2 + test/pre-upload-check.py | 94 +++++++++++++++++++++- 8 files changed, 183 insertions(+), 3 deletions(-) create mode 100644 test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages create mode 100644 test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release create mode 100644 test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg create mode 100644 test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages create mode 100644 test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release create mode 100644 test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg create mode 100644 test/authReliability/sources.list.failure (limited to 'test') diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages new file mode 100644 index 000000000..3e7265438 --- /dev/null +++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages @@ -0,0 +1,25 @@ +Package: libglib2.0-data +Priority: optional +Section: misc +Installed-Size: 2288 +Maintainer: Ubuntu Desktop Team +Original-Maintainer: Loic Minier +Architecture: all +Source: glib2.0 +Version: 2.13.6-1ubuntu1 +Replaces: libglib1.3, libglib1.3-data +Depends: libglib2.0-0 (>= 2.13.6-1ubuntu1) +Conflicts: libglib1.3-data +Filename: ./libglib2.0-data_2.13.6-1ubuntu1_all.deb +Size: 958 +MD5sum: 803fc5e2e31a4345b3e9c771e1eae49f +SHA1: 75b2c62b21bae60c58e694dd40ed6d4df946e304 +SHA256: 142d8466eac252f06bc957d76fe1bb87f86f2d3512b99c8d4b08c1ad79fbe59e +Description: Common files for GLib library + GLib is a library containing many useful C routines for things such + as trees, hashes, lists, and strings. It is a useful general-purpose + C library used by projects such as GTK+, GIMP, and GNOME. + . + This package is needed for the runtime libraries to display messages in + languages other than English. + diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release new file mode 100644 index 000000000..7ecd4cd19 --- /dev/null +++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release @@ -0,0 +1,13 @@ +Date: Fri, 27 Jul 2007 14:39:41 UTC +MD5Sum: + 4672dadea6a144839f823c9f3d5fd44b 934 Packages + 82ebcf09a8d78a2b9cf7759349da4936 603 Packages.gz + d41d8cd98f00b204e9800998ecf8427e 0 Release +SHA1: + fa0f294aa30789529371066b10e9497be1284d26 934 Packages + f4032808663b2810d87b4a4dab6f5ae4a1e8fa8e 603 Packages.gz + da39a3ee5e6b4b0d3255bfef95601890afd80709 0 Release +SHA256: + 92c9b605480dc74e6be79c0ddc24738bfcbd6dd3148af531acd68717de528049 934 Packages + 659ccc0d07ff21f0247f9fa5abe149221c90d5e17da52c7afddb035b93c23d39 603 Packages.gz + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 Release diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg new file mode 100644 index 000000000..85c356e6f --- /dev/null +++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg @@ -0,0 +1,7 @@ +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQBGqgOwliSD4VZixzQRAs6jAJ9p7Aiob9gzkUNCtoW8UPrBo0E/YwCdEaz0 +CQJszU6fRYX5jGWXSWzfc5c= +=ugH0 +-----END PGP SIGNATURE----- diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages new file mode 100644 index 000000000..3e7265438 --- /dev/null +++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages @@ -0,0 +1,25 @@ +Package: libglib2.0-data +Priority: optional +Section: misc +Installed-Size: 2288 +Maintainer: Ubuntu Desktop Team +Original-Maintainer: Loic Minier +Architecture: all +Source: glib2.0 +Version: 2.13.6-1ubuntu1 +Replaces: libglib1.3, libglib1.3-data +Depends: libglib2.0-0 (>= 2.13.6-1ubuntu1) +Conflicts: libglib1.3-data +Filename: ./libglib2.0-data_2.13.6-1ubuntu1_all.deb +Size: 958 +MD5sum: 803fc5e2e31a4345b3e9c771e1eae49f +SHA1: 75b2c62b21bae60c58e694dd40ed6d4df946e304 +SHA256: 142d8466eac252f06bc957d76fe1bb87f86f2d3512b99c8d4b08c1ad79fbe59e +Description: Common files for GLib library + GLib is a library containing many useful C routines for things such + as trees, hashes, lists, and strings. It is a useful general-purpose + C library used by projects such as GTK+, GIMP, and GNOME. + . + This package is needed for the runtime libraries to display messages in + languages other than English. + diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release new file mode 100644 index 000000000..7ecd4cd19 --- /dev/null +++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release @@ -0,0 +1,13 @@ +Date: Fri, 27 Jul 2007 14:39:41 UTC +MD5Sum: + 4672dadea6a144839f823c9f3d5fd44b 934 Packages + 82ebcf09a8d78a2b9cf7759349da4936 603 Packages.gz + d41d8cd98f00b204e9800998ecf8427e 0 Release +SHA1: + fa0f294aa30789529371066b10e9497be1284d26 934 Packages + f4032808663b2810d87b4a4dab6f5ae4a1e8fa8e 603 Packages.gz + da39a3ee5e6b4b0d3255bfef95601890afd80709 0 Release +SHA256: + 92c9b605480dc74e6be79c0ddc24738bfcbd6dd3148af531acd68717de528049 934 Packages + 659ccc0d07ff21f0247f9fa5abe149221c90d5e17da52c7afddb035b93c23d39 603 Packages.gz + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 Release diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg new file mode 100644 index 000000000..85c356e6f --- /dev/null +++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg @@ -0,0 +1,7 @@ +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQBGqgOwliSD4VZixzQRAs6jAJ9p7Aiob9gzkUNCtoW8UPrBo0E/YwCdEaz0 +CQJszU6fRYX5jGWXSWzfc5c= +=ugH0 +-----END PGP SIGNATURE----- diff --git a/test/authReliability/sources.list.failure b/test/authReliability/sources.list.failure new file mode 100644 index 000000000..110f31884 --- /dev/null +++ b/test/authReliability/sources.list.failure @@ -0,0 +1,2 @@ +deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/gpg-package-broken/ / + diff --git a/test/pre-upload-check.py b/test/pre-upload-check.py index 268b3d672..75a726808 100755 --- a/test/pre-upload-check.py +++ b/test/pre-upload-check.py @@ -4,6 +4,8 @@ import sys import os import glob import os.path +import shutil +import time from subprocess import call, PIPE import unittest @@ -11,7 +13,92 @@ import unittest stdout = os.open("/dev/null",0) #sys.stdout stderr = os.open("/dev/null",0) # sys.stderr -apt_args = [] # ["-o","Debug::pkgAcquire::Auth=true"] +apt_args = [] +#apt_args = ["-o","Debug::pkgAcquire::Auth=true"] + +class testAptAuthenticationReliability(unittest.TestCase): + """ + test if the spec https://wiki.ubuntu.com/AptAuthenticationReliability + is properly implemented + """ + apt = "../bin/apt-get" + + def setUp(self): + pass + def testRepositorySigFailure(self): + """ + test if a repository that used to be authenticated and fails on + apt-get update refuses to update and uses the old state + """ + # copy valid signatures into lists (those are ok, even + # if the name is "-broken-" ... + for f in glob.glob("./authReliability/lists/*"): + shutil.copy(f,"/var/lib/apt/lists") + # ensure we do *not* get a I-M-S hit + os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (0,0)) + res = call([self.apt, + "update", + "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure" + ] + apt_args, + stdout=stdout, stderr=stderr) + self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"), + "The gpg file disappeared, this should not happen") + self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"), + "The Packages file disappeared, this should not happen") + # the same with i-m-s hit this time + for f in glob.glob("./authReliability/lists/*"): + shutil.copy(f,"/var/lib/apt/lists") + os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (time.time(),time.time())) + res = call([self.apt, + "update", + "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure" + ] + apt_args, + stdout=stdout, stderr=stderr) + self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"), + "The gpg file disappeared, this should not happen") + self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"), + "The Packages file disappeared, this should not happen") + def testRepositorySigGood(self): + """ + test that a regular repository with good data stays good + """ + res = call([self.apt, + "update", + "-o","Dir::Etc::sourcelist=./authReliability/sources.list.good" + ] + apt_args, + stdout=stdout, stderr=stderr) + self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg"), + "The gpg file disappeared, this should not happen") + self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages"), + "The Packages file disappeared, this should not happen") + # test good is still good after non I-M-S hit and a previous files in lists/ + for f in glob.glob("./authReliability/lists/*"): + shutil.copy(f,"/var/lib/apt/lists") + # ensure we do *not* get a I-M-S hit + os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (0,0)) + res = call([self.apt, + "update", + "-o","Dir::Etc::sourcelist=./authReliability/sources.list.good" + ] + apt_args, + stdout=stdout, stderr=stderr) + self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg"), + "The gpg file disappeared, this should not happen") + self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages"), + "The Packages file disappeared, this should not happen") + # test good is still good after I-M-S hit + for f in glob.glob("./authReliability/lists/*"): + shutil.copy(f,"/var/lib/apt/lists") + # ensure we do get a I-M-S hit + os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (time.time(),time.time())) + res = call([self.apt, + "update", + "-o","Dir::Etc::sourcelist=./authReliability/sources.list.good" + ] + apt_args, + stdout=stdout, stderr=stderr) + self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg"), + "The gpg file disappeared, this should not happen") + self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages"), + "The Packages file disappeared, this should not happen") class testAuthentication(unittest.TestCase): @@ -149,6 +236,7 @@ if __name__ == "__main__": if len(sys.argv) > 1 and sys.argv[1] == "-v": stdout = sys.stdout stderr = sys.stderr + + # run only one for now + #unittest.main(defaultTest="testAptAuthenticationReliability") unittest.main() - - -- cgit v1.2.3 From f3224a73ec718a5f4e4404cd716e4b7c2702bb8b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 2 Jan 2008 13:50:56 +0100 Subject: test/authReliability/sources.list.good: - add missing file to make the test/pre-upload-check.py work again apt-pkg/acquire-item.cc: - fix auth-reliable code when file:// uris are used test/pre-upload-check.py: - use the standard apt, not "../bin/apt-get" by default - make the error messages more useful on test-failure --- test/authReliability/sources.list.good | 2 ++ test/pre-upload-check.py | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 test/authReliability/sources.list.good (limited to 'test') diff --git a/test/authReliability/sources.list.good b/test/authReliability/sources.list.good new file mode 100644 index 000000000..2e9a4458a --- /dev/null +++ b/test/authReliability/sources.list.good @@ -0,0 +1,2 @@ +deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/gpg-package-ok/ / + diff --git a/test/pre-upload-check.py b/test/pre-upload-check.py index 75a726808..ca44ec726 100755 --- a/test/pre-upload-check.py +++ b/test/pre-upload-check.py @@ -21,7 +21,8 @@ class testAptAuthenticationReliability(unittest.TestCase): test if the spec https://wiki.ubuntu.com/AptAuthenticationReliability is properly implemented """ - apt = "../bin/apt-get" + #apt = "../bin/apt-get" + apt = "apt-get" def setUp(self): pass @@ -68,7 +69,7 @@ class testAptAuthenticationReliability(unittest.TestCase): ] + apt_args, stdout=stdout, stderr=stderr) self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg"), - "The gpg file disappeared, this should not happen") + "The gpg file disappeared after a regular download, this should not happen") self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages"), "The Packages file disappeared, this should not happen") # test good is still good after non I-M-S hit and a previous files in lists/ @@ -82,7 +83,7 @@ class testAptAuthenticationReliability(unittest.TestCase): ] + apt_args, stdout=stdout, stderr=stderr) self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg"), - "The gpg file disappeared, this should not happen") + "The gpg file disappeared after a I-M-S hit, this should not happen") self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages"), "The Packages file disappeared, this should not happen") # test good is still good after I-M-S hit -- cgit v1.2.3 From 5d149bfc7f34bc39e0edf8d9d98786cadefeeedf Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 4 Feb 2008 14:15:17 +0100 Subject: add APT::Update::Auth-Failure script --- test/pre-upload-check.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/pre-upload-check.py b/test/pre-upload-check.py index ca44ec726..de43122ce 100755 --- a/test/pre-upload-check.py +++ b/test/pre-upload-check.py @@ -25,7 +25,8 @@ class testAptAuthenticationReliability(unittest.TestCase): apt = "apt-get" def setUp(self): - pass + if os.path.exists("/tmp/autFailure"): + os.unlink("/tmp/authFailure"); def testRepositorySigFailure(self): """ test if a repository that used to be authenticated and fails on @@ -39,26 +40,33 @@ class testAptAuthenticationReliability(unittest.TestCase): os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (0,0)) res = call([self.apt, "update", - "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure" + "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure", + "-o",'APT::Update::Auth-Failure::=touch /tmp/authFailure', ] + apt_args, stdout=stdout, stderr=stderr) self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"), "The gpg file disappeared, this should not happen") self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"), "The Packages file disappeared, this should not happen") + self.assert_(os.path.exists("/tmp/authFailure"), + "The APT::Update::Auth-Failure script did not run") + os.unlink("/tmp/authFailure"); # the same with i-m-s hit this time for f in glob.glob("./authReliability/lists/*"): shutil.copy(f,"/var/lib/apt/lists") os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (time.time(),time.time())) res = call([self.apt, "update", - "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure" + "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure", + "-o",'APT::Update::Auth-Failure::=touch /tmp/authFailure', ] + apt_args, stdout=stdout, stderr=stderr) self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"), "The gpg file disappeared, this should not happen") self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"), "The Packages file disappeared, this should not happen") + self.assert_(os.path.exists("/tmp/authFailure"), + "The APT::Update::Auth-Failure script did not run") def testRepositorySigGood(self): """ test that a regular repository with good data stays good @@ -239,5 +247,5 @@ if __name__ == "__main__": stderr = sys.stderr # run only one for now - #unittest.main(defaultTest="testAptAuthenticationReliability") - unittest.main() + unittest.main(defaultTest="testAptAuthenticationReliability") + #unittest.main() -- cgit v1.2.3 From d54385388a0773fada9e44c5d1cf020488047884 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 8 Feb 2008 14:30:39 +0100 Subject: make the test-suit more reliable --- test/pre-upload-check.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/pre-upload-check.py b/test/pre-upload-check.py index de43122ce..9c2e1916c 100755 --- a/test/pre-upload-check.py +++ b/test/pre-upload-check.py @@ -27,6 +27,8 @@ class testAptAuthenticationReliability(unittest.TestCase): def setUp(self): if os.path.exists("/tmp/autFailure"): os.unlink("/tmp/authFailure"); + if os.path.exists("/tmp/autFailure2"): + os.unlink("/tmp/authFailure2"); def testRepositorySigFailure(self): """ test if a repository that used to be authenticated and fails on @@ -49,8 +51,7 @@ class testAptAuthenticationReliability(unittest.TestCase): self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"), "The Packages file disappeared, this should not happen") self.assert_(os.path.exists("/tmp/authFailure"), - "The APT::Update::Auth-Failure script did not run") - os.unlink("/tmp/authFailure"); + "The APT::Update::Auth-Failure script did not run (1)") # the same with i-m-s hit this time for f in glob.glob("./authReliability/lists/*"): shutil.copy(f,"/var/lib/apt/lists") @@ -58,15 +59,15 @@ class testAptAuthenticationReliability(unittest.TestCase): res = call([self.apt, "update", "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure", - "-o",'APT::Update::Auth-Failure::=touch /tmp/authFailure', + "-o",'APT::Update::Auth-Failure::=touch /tmp/authFailure2', ] + apt_args, stdout=stdout, stderr=stderr) self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"), "The gpg file disappeared, this should not happen") self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"), "The Packages file disappeared, this should not happen") - self.assert_(os.path.exists("/tmp/authFailure"), - "The APT::Update::Auth-Failure script did not run") + self.assert_(os.path.exists("/tmp/authFailure2"), + "The APT::Update::Auth-Failure script did not run (2)") def testRepositorySigGood(self): """ test that a regular repository with good data stays good -- cgit v1.2.3 From 2bb255740bf18b5e0524fe833523303abb5c9051 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 12 Mar 2010 19:41:30 +0100 Subject: * apt-pkg/deb/dpkgpm.cc: - if available store the Commandline in the history * apt-pkg/contrib/cmndline.cc: - save Commandline in Commandline::AsString for logging --- test/libapt/commandlineasstring_test.cc | 39 +++++++++++++++++++++++++++++++++ test/libapt/makefile | 6 +++++ 2 files changed, 45 insertions(+) create mode 100644 test/libapt/commandlineasstring_test.cc (limited to 'test') diff --git a/test/libapt/commandlineasstring_test.cc b/test/libapt/commandlineasstring_test.cc new file mode 100644 index 000000000..a38957d7e --- /dev/null +++ b/test/libapt/commandlineasstring_test.cc @@ -0,0 +1,39 @@ +#include +#include + +#include + +#include "assert.h" + +class CLT: public CommandLine { + + public: + std::string static AsString(const char * const * const argv, + unsigned int const argc) { + std::string const static conf = "Commandline::AsString"; + _config->Clear(conf); + SaveInConfig(argc, argv); + return _config->Find(conf); + } +}; + +#define CMD(y,z) equals(CLT::AsString(argv, y), z); + +int main() { + { + const char* const argv[] = {"apt-get", "install", "-sf"}; + CMD(3, "apt-get install -sf"); + } + { + const char* const argv[] = {"apt-cache", "-s", "apt", "-so", "Debug::test=Test"}; + CMD(5, "apt-cache -s apt -so Debug::test=Test"); + } + { + const char* const argv[] = {"apt-cache", "-s", "apt", "-so", "Debug::test=Das ist ein Test"}; + CMD(5, "apt-cache -s apt -so Debug::test=\"Das ist ein Test\""); + } + { + const char* const argv[] = {"apt-cache", "-s", "apt", "--hallo", "test=1.0"}; + CMD(5, "apt-cache -s apt --hallo test=1.0"); + } +} diff --git a/test/libapt/makefile b/test/libapt/makefile index 08f581e6d..cb76d5ee6 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -23,3 +23,9 @@ PROGRAM = GetListOfFilesInDir${BASENAME} SLIBS = -lapt-pkg SOURCE = getlistoffilesindir_test.cc include $(PROGRAM_H) + +# Program for testing CommandLine reconstruction +PROGRAM = commandlineasstring${BASENAME} +SLIBS = -lapt-pkg +SOURCE = commandlineasstring_test.cc +include $(PROGRAM_H) -- cgit v1.2.3 From ea5624c3d04c35f5a269b6f7431c135330c9b9b5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 13 Mar 2010 14:11:22 +0100 Subject: * apt-pkg/deb/debversion.cc: - consider absent of debian revision equivalent to 0 (Closes: #573592) This moves the existing testcase for version comparison to "my" directory, adds a few more tests (e.g. the tests used in cupt) and rewrites the testcases runner: The runner does now call dpkg --compare-versions to check what dpkg thinks about the comparison - all done in less code ;) --- test/libapt/compareversion_test.cc | 123 ++++++++++++++++++++ test/libapt/makefile | 6 + test/makefile | 7 -- test/versions.lst | 64 +++++++++- test/versiontest.cc | 233 ------------------------------------- 5 files changed, 189 insertions(+), 244 deletions(-) create mode 100644 test/libapt/compareversion_test.cc delete mode 100644 test/versiontest.cc (limited to 'test') diff --git a/test/libapt/compareversion_test.cc b/test/libapt/compareversion_test.cc new file mode 100644 index 000000000..b6213e84c --- /dev/null +++ b/test/libapt/compareversion_test.cc @@ -0,0 +1,123 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + Version Test - Simple program to run through a file and comare versions. + + Each version is compared and the result is checked against an expected + result in the file. The format of the file is + a b Res + Where Res is -1, 1, 0. dpkg -D=1 --compare-versions a "<" b can be + used to determine what Res should be. # at the start of the line + is a comment and blank lines are skipped + + The runner will also call dpkg --compare-versions to check if APT and + dpkg have (still) the same idea. + + ##################################################################### */ + /*}}}*/ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace std; + +bool callDPkg(const char *val, const char *ref, const char &op) { + pid_t Process = ExecFork(); + if (Process == 0) + { + const char * args[6]; + args[0] = "/usr/bin/dpkg"; + args[1] = "--compare-versions"; + args[2] = val; + args[3] = (op == 1) ? ">>" : ( (op == 0) ? "=" : "<<"); + args[4] = ref; + args[5] = 0; + execv(args[0], (char**) args); + exit(1); + } + int Ret; + waitpid(Process, &Ret, 0); + return WIFEXITED(Ret) == true && WEXITSTATUS(Ret) == 0; +} + +void assertVersion(int const &CurLine, string const &A, string const &B, int const &Expected) { + int Res = debVS.CmpVersion(A.c_str(), B.c_str()); + bool const dpkg = callDPkg(A.c_str(),B.c_str(), Expected); + Res = (Res < 0) ? -1 : ( (Res > 0) ? 1 : Res); + + if (Res != Expected) + _error->Error("Comparison failed on line %u. '%s' '%s' '%s' %i != %i",CurLine,A.c_str(),((Expected == 1) ? "<<" : ( (Expected == 0) ? "=" : ">>")) ,B.c_str(),Res,Expected); + if (dpkg == false) + _error->Error("DPkg differ with line: %u. '%s' '%s' '%s' == false",CurLine,A.c_str(),((Expected == 1) ? "<<" : ( (Expected == 0) ? "=" : ">>")),B.c_str()); +} + +bool RunTest(const char *File) +{ + ifstream F(File,ios::in); + if (!F != 0) + return false; + + char Buffer[300]; + int CurLine = 0; + + while (1) + { + F.getline(Buffer,sizeof(Buffer)); + CurLine++; + if (F.eof() != 0) + return true; + if (!F != 0) + return _error->Error("Line %u in %s is too long",CurLine,File); + + // Comment + if (Buffer[0] == '#' || Buffer[0] == 0) + continue; + + // First version + char *I; + char *Start = Buffer; + for (I = Buffer; *I != 0 && *I != ' '; I++); + string A(Start, I - Start); + + if (*I == 0) + return _error->Error("Invalid line %u",CurLine); + + // Second version + I++; + Start = I; + for (I = Start; *I != 0 && *I != ' '; I++); + string B(Start,I - Start); + + if (*I == 0 || I[1] == 0) + return _error->Error("Invalid line %u",CurLine); + + // Result + I++; + int const Expected = atoi(I); + assertVersion(CurLine, A, B, Expected); + // Check the reverse as well + assertVersion(CurLine, B, A, Expected*-1); + } +} + +int main(int argc, char *argv[]) +{ + if (argc <= 1) + RunTest("../versions.lst"); + else + RunTest(argv[1]); + + // Print any errors or warnings found + _error->DumpErrors(); + return 0; +} diff --git a/test/libapt/makefile b/test/libapt/makefile index cb76d5ee6..98bdb3348 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -29,3 +29,9 @@ PROGRAM = commandlineasstring${BASENAME} SLIBS = -lapt-pkg SOURCE = commandlineasstring_test.cc include $(PROGRAM_H) + +# Program for testing debians version comparing +PROGRAM = compareversion${BASENAME} +SLIBS = -lapt-pkg +SOURCE = compareversion_test.cc +include $(PROGRAM_H) diff --git a/test/makefile b/test/makefile index fb9123d0a..b8c104eae 100644 --- a/test/makefile +++ b/test/makefile @@ -24,13 +24,6 @@ LIB_MAKES = apt-pkg/makefile apt-inst/makefile SOURCE = scratch.cc include $(PROGRAM_H) -# Version compare tester -PROGRAM=versiontest -SLIBS = -lapt-pkg -LIB_MAKES = apt-pkg/makefile -SOURCE = versiontest.cc -include $(PROGRAM_H) - # Version compare tester PROGRAM=testextract SLIBS = -lapt-pkg -lapt-inst diff --git a/test/versions.lst b/test/versions.lst index efc19c4f0..517214151 100644 --- a/test/versions.lst +++ b/test/versions.lst @@ -10,10 +10,11 @@ 1.3 1.2.2 1 # Important attributes -- . -1 -p - -1 -a - -1 -z - -1 +# disabled as dpkg --compare-versions doesn't like them… +#- . -1 +#p - -1 +#a - -1 +#z - -1 a . -1 z . -1 @@ -22,6 +23,10 @@ z . -1 1:1.25-4 1:1.25-8 -1 0:1.18.36 1.18.36 0 +# native version +1.18.36 1.18.35 1 +0:1.18.36 1.18.35 1 + # Funky, but allowed, characters in upstream version 9:1.18.36:5.4-20 10:0.5.1-22 -1 9:1.18.36:5.4-20 9:1.18.36:5.5-1 -1 @@ -49,3 +54,54 @@ III-alpha9.8 III-alpha9.8-1.5 -1 # #205960 3.0~rc1-1 3.0-1 -1 + +# #573592 - debian policy 5.6.12 +1.0 1.0-0 0 +0.2 1.0-0 -1 +1.0 1.0-0+b1 -1 +1.0 1.0-0~ 1 + +# if a version includes a dash +# it should be the debrev dash - policy says so… +0:0-0-0 0-0 1 + +# do we like strange versions? Yes we like strange versions… +0 0 0 +0 00 0 + +# "steal" the testcases from cupt +1.2.3 1.2.3 0 # identical +4.4.3-2 4.4.3-2 0 # identical +1:2ab:5 1:2ab:5 0 # this is correct... +7:1-a:b-5 7:1-a:b-5 0 # and this +57:1.2.3abYZ+~-4-5 57:1.2.3abYZ+~-4-5 0 # and those too +1.2.3 0:1.2.3 0 # zero epoch +1.2.3 1.2.3-0 0 # zero revision +009 9 0 # zeroes... +009ab5 9ab5 0 # there as well +1.2.3 1.2.3-1 -1 # added non-zero revision +1.2.3 1.2.4 -1 # just bigger +1.2.4 1.2.3 1 # order doesn't matter +1.2.24 1.2.3 1 # bigger, eh? +0.10.0 0.8.7 1 # bigger, eh? +3.2 2.3 1 # major number rocks +1.3.2a 1.3.2 1 # letters rock +0.5.0~git 0.5.0~git2 -1 # numbers rock +2a 21 -1 # but not in all places +1.3.2a 1.3.2b -1 # but there is another letter +1:1.2.3 1.2.4 1 # epoch rocks +1:1.2.3 1:1.2.4 -1 # bigger anyway +1.2a+~bCd3 1.2a++ -1 # tilde doesn't rock +1.2a+~bCd3 1.2a+~ 1 # but first is longer! +5:2 304-2 1 # epoch rocks +5:2 304:2 -1 # so big epoch? +25:2 3:2 1 # 25 > 3, obviously +1:2:123 1:12:3 -1 # 12 > 2 +1.2-5 1.2-3-5 -1 # 1.2 < 1.2-3 +5.10.0 5.005 1 # preceding zeroes don't matters +3a9.8 3.10.2 -1 # letters are before all letter symbols +3a9.8 3~10 1 # but after the tilde +1.4+OOo3.0.0~ 1.4+OOo3.0.0-4 -1 # another tilde check +2.4.7-1 2.4.7-z -1 # revision comparing +1.002-1+b2 1.00 1 # whatever... +2.2.4-47978_Debian_lenny 2.2.4-47978_Debian_lenny 0 # and underscore... diff --git a/test/versiontest.cc b/test/versiontest.cc deleted file mode 100644 index 4ede4b280..000000000 --- a/test/versiontest.cc +++ /dev/null @@ -1,233 +0,0 @@ -// -*- mode: cpp; mode: fold -*- -// Description /*{{{*/ -// $Id: versiontest.cc,v 1.5 2003/08/18 15:55:19 mdz Exp $ -/* ###################################################################### - - Version Test - Simple program to run through a file and comare versions. - - Each version is compared and the result is checked against an expected - result in the file. The format of the file is - a b Res - Where Res is -1, 1, 0. dpkg -D=1 --compare-versions a "<" b can be - used to determine what Res should be. # at the start of the line - is a comment and blank lines are skipped - - ##################################################################### */ - /*}}}*/ -#include -#include -#include -#include -#include -#include - -using namespace std; - - static int verrevcmp(const char *val, const char *ref) -{ - int vc, rc; - long vl, rl; - const char *vp, *rp; - - if (!val) - val = ""; - if (!ref) - ref = ""; - for (;;) - { - vp = val; - while (*vp && !isdigit(*vp)) - vp++; - rp = ref; - while (*rp && !isdigit(*rp)) - rp++; - for (;;) - { - vc= val == vp ? 0 : *val++; - rc= ref == rp ? 0 : *ref++; - if (!rc && !vc) - break; - if (vc && !isalpha(vc)) - vc += 256; /* assumes ASCII character set */ - if (rc && !isalpha(rc)) - rc += 256; - if (vc != rc) - return vc - rc; - } - val = vp; - ref = rp; - vl = 0; - if (isdigit(*vp)) - vl = strtol(val,(char**)&val,10); - rl = 0; - if (isdigit(*rp)) - rl = strtol(ref,(char**)&ref,10); - if (vl != rl) - return vl - rl; - if (!*val && !*ref) - return 0; - if (!*val) - return -1; - if (!*ref) - return +1; - } -} - -#if 0 -static int verrevcmp(const char *val, const char *ref) -{ - int vc, rc; - long vl, rl; - const char *vp, *rp; - - if (!val) val= ""; - if (!ref) ref= ""; - for (;;) - { - vp= val; while (*vp && !isdigit(*vp) && *vp != '~') vp++; - rp= ref; while (*rp && !isdigit(*rp) && *rp != '~') rp++; - for (;;) - { - vc= val == vp ? 0 : *val++; - rc= ref == rp ? 0 : *ref++; - if (!rc && !vc) break; - if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ - if (rc && !isalpha(rc)) rc += 256; - if (vc != rc) return vc - rc; - } - - val= vp; - ref= rp; - if (*vp == '~') val++; - if (*rp == '~') ref++; - vl=0; if (isdigit(*val)) vl= strtol(val,(char**)&val,10); - rl=0; if (isdigit(*ref)) rl= strtol(ref,(char**)&ref,10); - if (vl == 0 && rl == 0) - { - if (*vp == '~' && *rp != '~') return -1; - if (*vp != '~' && *rp == '~') return +1; - } - if (*vp == '~') - vl *= -1; - if (*rp == '~') - rl *= -1; - if (vl != rl) return vl - rl; - if (!*val && !*ref) return 0; - if (!*val) - { - if (*ref == '~') - return +1; - else - return -1; - } - - if (!*ref) - { - if (*val == '~') - return -1; - else - return +1; - } - } -} -#endif - -bool RunTest(const char *File) -{ - ifstream F(File,ios::in); - if (!F != 0) - return false; - - char Buffer[300]; - int CurLine = 0; - - while (1) - { - F.getline(Buffer,sizeof(Buffer)); - CurLine++; - if (F.eof() != 0) - return true; - if (!F != 0) - return _error->Error("Line %u in %s is too long",CurLine,File); - - // Comment - if (Buffer[0] == '#' || Buffer[0] == 0) - continue; - - // First version - char *I; - char *Start = Buffer; - for (I = Buffer; *I != 0 && *I != ' '; I++); - string A(Start, I - Start); - - if (*I == 0) - return _error->Error("Invalid line %u",CurLine); - - // Second version - I++; - Start = I; - for (I = Start; *I != 0 && *I != ' '; I++); - string B(Start,I - Start); - - if (*I == 0 || I[1] == 0) - return _error->Error("Invalid line %u",CurLine); - - // Result - I++; - int Expected = atoi(I); - int Res = debVS.CmpVersion(A.c_str(), B.c_str()); - int Res2 = verrevcmp(A.c_str(),B.c_str()); - cout << "'" << A << "' ? '" << B << "' = " << Res << " (= " << Expected << ") " << Res2 << endl; - - if (Res < 0) - Res = -1; - else if (Res > 0) - Res = 1; - - if (Res != Expected) - _error->Error("Comparison failed on line %u. '%s' ? '%s' %i != %i",CurLine,A.c_str(),B.c_str(),Res,Expected); - - // Check the reverse as well - Expected = -1*Expected; - Res = debVS.CmpVersion(B.c_str(), A.c_str()); - Res2 = verrevcmp(B.c_str(),A.c_str()); - - cout << "'" << B << "' ? '" << A << "' = " << Res << " (= " << Expected << ") " << Res2 << endl; - - if (Res < 0) - Res = -1; - else if (Res > 0) - Res = 1; - - if (Res != Expected) - _error->Error("Comparison failed on line %u. '%s' ? '%s' %i != %i",CurLine,B.c_str(),A.c_str(),Res,Expected); - } -} - -int main(int argc, char *argv[]) -{ - if (argc <= 1) - { - cerr << "You must specify a test file" << endl; - return 0; - } - - RunTest(argv[1]); - - // Print any errors or warnings found - if (_error->empty() == false) - { - string Err; - while (_error->empty() == false) - { - - bool Type = _error->PopMessage(Err); - if (Type == true) - cout << "E: " << Err << endl; - else - cout << "W: " << Err << endl; - } - - return 0; - } -} -- cgit v1.2.3 From a722b2c5c935768efbdd5b23eed7ce32ccd60908 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 9 Apr 2010 15:38:48 +0200 Subject: * apt-pkg/acquire-item.cc: - Acquire::ForceHash to force method for expected hash - display MD5Sum in --print-uris if not forced to use another method instead of displaying the strongest available (Closes: #576420) --- test/makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/makefile b/test/makefile index b8c104eae..52adb96a2 100644 --- a/test/makefile +++ b/test/makefile @@ -68,7 +68,7 @@ SOURCE = test_udevcdrom.cc include $(PROGRAM_H) # Program for checking rpm versions -PROGRAM=rpmver -SLIBS = -lapt-pkg -lrpm -SOURCE = rpmver.cc -include $(PROGRAM_H) +#PROGRAM=rpmver +#SLIBS = -lapt-pkg -lrpm +#SOURCE = rpmver.cc +#include $(PROGRAM_H) -- cgit v1.2.3 From 3152f4aa4a97ad06ef1073aabe137f999f787ee1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 28 May 2010 23:11:36 +0200 Subject: * apt-pkg/aptconfiguration.cc: - remove duplicate architectures in getArchitectures() --- test/libapt/getarchitectures_test.cc | 61 ++++++++++++++++++++++++++++++++++++ test/libapt/makefile | 5 +++ 2 files changed, 66 insertions(+) create mode 100644 test/libapt/getarchitectures_test.cc (limited to 'test') diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc new file mode 100644 index 000000000..1500caeed --- /dev/null +++ b/test/libapt/getarchitectures_test.cc @@ -0,0 +1,61 @@ +#include +#include + +#include "assert.h" +#include +#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; +} + +int main(int argc,char *argv[]) +{ + std::vector vec; + + _config->Set("APT::Architectures::1", "i386"); + _config->Set("APT::Architectures::2", "amd64"); + vec = APT::Configuration::getArchitectures(false); + equals(vec.size(), 2); + equals(vec[0], "i386"); + equals(vec[1], "amd64"); + + _config->Set("APT::Architecture", "i386"); + vec = APT::Configuration::getArchitectures(false); + equals(vec.size(), 2); + equals(vec[0], "i386"); + equals(vec[1], "amd64"); + + _config->Set("APT::Architectures::2", ""); + vec = APT::Configuration::getArchitectures(false); + equals(vec.size(), 1); + equals(vec[0], "i386"); + + _config->Set("APT::Architecture", "armel"); + vec = APT::Configuration::getArchitectures(false); + equals(vec.size(), 2); + equals(vec[0], "i386"); + equals(vec[1], "armel"); + + _config->Set("APT::Architectures::2", "amd64"); + _config->Set("APT::Architectures::3", "i386"); + _config->Set("APT::Architectures::4", "armel"); + _config->Set("APT::Architectures::5", "i386"); + _config->Set("APT::Architectures::6", "amd64"); + _config->Set("APT::Architectures::7", "armel"); + _config->Set("APT::Architectures::8", "armel"); + _config->Set("APT::Architectures::9", "amd64"); + _config->Set("APT::Architectures::10", "amd64"); + vec = APT::Configuration::getArchitectures(false); + equals(vec.size(), 3); + equals(vec[0], "i386"); + equals(vec[1], "amd64"); + equals(vec[2], "armel"); + + return 0; +} diff --git a/test/libapt/makefile b/test/libapt/makefile index 98bdb3348..ee3401b35 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -12,6 +12,11 @@ SLIBS = -lapt-pkg SOURCE = getlanguages_test.cc include $(PROGRAM_H) +PROGRAM = getArchitectures${BASENAME} +SLIBS = -lapt-pkg +SOURCE = getarchitectures_test.cc +include $(PROGRAM_H) + # Program for testing ParseDepends PROGRAM = ParseDepends${BASENAME} SLIBS = -lapt-pkg -- cgit v1.2.3 From 8fa7eefb8a320e8fa4a26c4718fa606d4d27a56f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 28 May 2010 23:40:08 +0200 Subject: create the bin-test directory automatic in the runner --- test/libapt/run-tests.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/libapt/run-tests.sh b/test/libapt/run-tests.sh index f9df1af5f..cb7769e4a 100755 --- a/test/libapt/run-tests.sh +++ b/test/libapt/run-tests.sh @@ -2,6 +2,7 @@ set -e echo "Compiling the tests ..." +test -d '../../build/obj/test/libapt/' || mkdir -p '../../build/obj/test/libapt/' make echo "Running all testcases ..." LDPATH=$(pwd)/../../build/bin -- cgit v1.2.3 From 1ddb859611d2e0f3d9ea12085001810f689e8c99 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 8 Jun 2010 19:27:49 +0200 Subject: * apt-pkg/indexrecords.cc: - backport forgotten Valid-Until patch from the obsolete experimental branch to prevent replay attacks better, thanks to Thomas Viehmann for the initial patch! (Closes: #499897) --- test/pre-upload-check.py | 14 ++++++++++++++ test/testsources.list/sources.list.all-validuntil-broken | 1 + 2 files changed, 15 insertions(+) create mode 100644 test/testsources.list/sources.list.all-validuntil-broken (limited to 'test') diff --git a/test/pre-upload-check.py b/test/pre-upload-check.py index 268b3d672..e2dfecbd3 100755 --- a/test/pre-upload-check.py +++ b/test/pre-upload-check.py @@ -95,6 +95,20 @@ class testAuthentication(unittest.TestCase): self.assert_(len(glob.glob("/var/lib/apt/lists/partial/*")) == 0, "partial/ dir has leftover files: %s" % glob.glob("/var/lib/apt/lists/partial/*")) + def testValid(self): + for f in glob.glob("testsources.list/sources.list*validuntil*"): + self._cleanup() + (prefix, testtype, result) = f.split("-") + expected_res = self._expectedRes(result) + cmd = ["update"] + res = call([self.apt,"-o","Dir::Etc::sourcelist=./%s" % f]+cmd+apt_args, + stdout=stdout, stderr=stderr) + self.assert_(res == expected_res, + "test '%s' failed (got %s expected %s" % (f,res,expected_res)) + if expected_res == 0: + self.assert_(len(glob.glob("/var/lib/apt/lists/partial/*")) == 0, + "partial/ dir has leftover files: %s" % glob.glob("/var/lib/apt/lists/partial/*")) + class testLocalRepositories(unittest.TestCase): " test local repository regressions " diff --git a/test/testsources.list/sources.list.all-validuntil-broken b/test/testsources.list/sources.list.all-validuntil-broken new file mode 100644 index 000000000..bab59bb81 --- /dev/null +++ b/test/testsources.list/sources.list.all-validuntil-broken @@ -0,0 +1 @@ +deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/all-validuntil-broken/ / -- cgit v1.2.3 From 31e1187be48846395cb3b57f0e9a731261a1484c Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 10 Jun 2010 15:19:10 +0200 Subject: * Add test/test-indexes.sh: - Test behaviour of index retrieval and usage, in particular with uncompressed and gzip compressed indexes. --- test/test-indexes.sh | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100755 test/test-indexes.sh (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh new file mode 100755 index 000000000..d3f5e7cd3 --- /dev/null +++ b/test/test-indexes.sh @@ -0,0 +1,106 @@ +#!/bin/sh -e + +# Test behaviour of index retrieval and usage, in particular with uncompressed +# and gzip compressed indexes. +# Author: Martin Pitt +# (C) 2010 Canonical Ltd. + +BUILDDIR=$(readlink -f $(dirname $0)/../build) + +TEST_SOURCE="deb http://ftp.debian.org/debian unstable contrib" +TEST_SOURCE_KEYID=55BE302B +GPG_KEYSERVER=gpg-keyserver.de +# should be a small package with dependencies satisfiable in TEST_SOURCE, i. e. +# ideally no depends at all +TEST_PKG="python-psyco-doc" + +export LD_LIBRARY_PATH=$BUILDDIR/bin + +OPTS="-o RootDir=. -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true" +DEBUG="" +#DEBUG="-o Debug::pkgCacheGen=true" +#DEBUG="-o Debug::pkgAcquire=true" +APT_GET="$BUILDDIR/bin/apt-get $OPTS $DEBUG" +APT_CACHE="$BUILDDIR/bin/apt-cache $OPTS $DEBUG" + +[ -x "$BUILDDIR/bin/apt-get" ] || { + echo "please build the tree first" >&2 + exit 1 +} + +echo "---- building sandbox----" +WORKDIR=$(mktemp -d) +trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM +cd $WORKDIR + +rm -fr etc var +rm -f home +ln -s /home home +mkdir -p etc/apt/preferences.d etc/apt/trusted.gpg.d var/cache/apt/archives/partial var/lib/apt/lists/partial var/lib/dpkg +cp /etc/apt/trusted.gpg etc/apt +touch var/lib/dpkg/status +echo "$TEST_SOURCE" > etc/apt/sources.list + +# get keyring +gpg --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $TEST_SOURCE_KEYID + +echo "---- uncompressed update ----" +$APT_GET update +test -e var/lib/apt/lists/*_Packages +! test -e var/lib/apt/lists/*_Packages.gz + +echo "---- uncompressed cache ----" +$APT_CACHE show $TEST_PKG | grep -q ^Version: +# again (with cache) +$APT_CACHE show $TEST_PKG | grep -q ^Version: +rm var/cache/apt/*.bin +$APT_CACHE policy $TEST_PKG | grep -q '500 http://' +# again (with cache) +$APT_CACHE policy $TEST_PKG | grep -q '500 http://' + +echo "---- uncompressed install ----" +$APT_GET install -d $TEST_PKG +test -e var/cache/apt/archives/$TEST_PKG*.deb +$APT_GET clean +! test -e var/cache/apt/archives/$TEST_PKG*.deb + +echo "----- uncompressed update with preexisting indexes, no pdiff ----" +$APT_GET -o Acquire::PDiffs=false update +test -e var/lib/apt/lists/*_Packages +! test -e var/lib/apt/lists/*_Packages.gz + +echo "----- uncompressed update with preexisting indexes, with pdiff ----" +$APT_GET -o Acquire::PDiffs=true update +test -e var/lib/apt/lists/*_Packages +! test -e var/lib/apt/lists/*_Packages.gz + +echo "----- compressed update ----" +find var/lib/apt/lists/ -type f | xargs -r rm +$APT_GET -o Acquire::GzipIndexes=true update +! test -e var/lib/apt/lists/*_Packages +test -e var/lib/apt/lists/*_Packages.gz + +echo "---- compressed cache ----" +$APT_CACHE show $TEST_PKG | grep -q ^Version: +# again (with cache) +$APT_CACHE show $TEST_PKG | grep -q ^Version: +rm var/cache/apt/*.bin +$APT_CACHE policy $TEST_PKG | grep -q '500 http://' +# again (with cache) +$APT_CACHE policy $TEST_PKG | grep -q '500 http://' + +echo "---- compressed install ----" +$APT_GET install -d $TEST_PKG +! test -e var/cache/apt/archives/$TEST_PKG*.deb + +echo "----- compressed update with preexisting indexes, no pdiff ----" +$APT_GET -o Acquire::PDiffs=false -o Acquire::GzipIndexes=true update +! test -e var/lib/apt/lists/*_Packages +test -e var/lib/apt/lists/*_Packages.gz + +echo "----- compressed update with preexisting indexes, with pdiff ----" +$APT_GET -o Acquire::PDiffs=true -o Acquire::GzipIndexes=true update +! test -e var/lib/apt/lists/*_Packages +test -e var/lib/apt/lists/*_Packages.gz + +echo "---- ALL TESTS PASSED ----" -- cgit v1.2.3 From f4782b42840c1f86c40a59690698ccf6920e990a Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Fri, 11 Jun 2010 18:22:48 +0200 Subject: test-indexes.sh: Add source related tests, which uncovers two regressions --- test/test-indexes.sh | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index d3f5e7cd3..e82633022 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -7,7 +7,7 @@ BUILDDIR=$(readlink -f $(dirname $0)/../build) -TEST_SOURCE="deb http://ftp.debian.org/debian unstable contrib" +TEST_SOURCE="http://ftp.debian.org/debian unstable contrib" TEST_SOURCE_KEYID=55BE302B GPG_KEYSERVER=gpg-keyserver.de # should be a small package with dependencies satisfiable in TEST_SOURCE, i. e. @@ -39,7 +39,8 @@ ln -s /home home mkdir -p etc/apt/preferences.d etc/apt/trusted.gpg.d var/cache/apt/archives/partial var/lib/apt/lists/partial var/lib/dpkg cp /etc/apt/trusted.gpg etc/apt touch var/lib/dpkg/status -echo "$TEST_SOURCE" > etc/apt/sources.list +echo "deb $TEST_SOURCE" > etc/apt/sources.list +echo "deb-src $TEST_SOURCE" >> etc/apt/sources.list # get keyring gpg --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $TEST_SOURCE_KEYID @@ -47,7 +48,9 @@ gpg --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --tru echo "---- uncompressed update ----" $APT_GET update test -e var/lib/apt/lists/*_Packages +test -e var/lib/apt/lists/*_Sources ! test -e var/lib/apt/lists/*_Packages.gz +! test -e var/lib/apt/lists/*_Sources.gz echo "---- uncompressed cache ----" $APT_CACHE show $TEST_PKG | grep -q ^Version: @@ -58,27 +61,45 @@ $APT_CACHE policy $TEST_PKG | grep -q '500 http://' # again (with cache) $APT_CACHE policy $TEST_PKG | grep -q '500 http://' +TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print $2}'` +rm var/cache/apt/*.bin +$APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: +# again (with cache) +$APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: + echo "---- uncompressed install ----" $APT_GET install -d $TEST_PKG test -e var/cache/apt/archives/$TEST_PKG*.deb $APT_GET clean ! test -e var/cache/apt/archives/$TEST_PKG*.deb +echo "---- uncompressed get source ----" +$APT_GET source $TEST_PKG +test -f $TEST_SRC_*.dsc +test -d $TEST_SRC-* +rm -r $TEST_SRC* + echo "----- uncompressed update with preexisting indexes, no pdiff ----" $APT_GET -o Acquire::PDiffs=false update test -e var/lib/apt/lists/*_Packages +test -e var/lib/apt/lists/*_Sources ! test -e var/lib/apt/lists/*_Packages.gz +! test -e var/lib/apt/lists/*_Sources.gz echo "----- uncompressed update with preexisting indexes, with pdiff ----" $APT_GET -o Acquire::PDiffs=true update test -e var/lib/apt/lists/*_Packages +test -e var/lib/apt/lists/*_Sources ! test -e var/lib/apt/lists/*_Packages.gz +! test -e var/lib/apt/lists/*_Sources.gz echo "----- compressed update ----" find var/lib/apt/lists/ -type f | xargs -r rm $APT_GET -o Acquire::GzipIndexes=true update ! test -e var/lib/apt/lists/*_Packages +! test -e var/lib/apt/lists/*_Sources test -e var/lib/apt/lists/*_Packages.gz +test -e var/lib/apt/lists/*_Sources.gz echo "---- compressed cache ----" $APT_CACHE show $TEST_PKG | grep -q ^Version: @@ -89,18 +110,34 @@ $APT_CACHE policy $TEST_PKG | grep -q '500 http://' # again (with cache) $APT_CACHE policy $TEST_PKG | grep -q '500 http://' +TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print $2}'` +rm var/cache/apt/*.bin +$APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: +# again (with cache) +$APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: + echo "---- compressed install ----" $APT_GET install -d $TEST_PKG ! test -e var/cache/apt/archives/$TEST_PKG*.deb +echo "---- compressed get source ----" +$APT_GET source $TEST_PKG +test -f $TEST_SRC_*.dsc +test -d $TEST_SRC-* +rm -r $TEST_SRC* + echo "----- compressed update with preexisting indexes, no pdiff ----" $APT_GET -o Acquire::PDiffs=false -o Acquire::GzipIndexes=true update ! test -e var/lib/apt/lists/*_Packages +! test -e var/lib/apt/lists/*_Sources test -e var/lib/apt/lists/*_Packages.gz +test -e var/lib/apt/lists/*_Sources.gz echo "----- compressed update with preexisting indexes, with pdiff ----" $APT_GET -o Acquire::PDiffs=true -o Acquire::GzipIndexes=true update ! test -e var/lib/apt/lists/*_Packages +! test -e var/lib/apt/lists/*_Sources test -e var/lib/apt/lists/*_Packages.gz +test -e var/lib/apt/lists/*_Sources.gz echo "---- ALL TESTS PASSED ----" -- cgit v1.2.3 From 8d48388ebfb69ab21a50d068275d2f6b7abffb87 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Tue, 15 Jun 2010 13:17:33 +0200 Subject: test/test-indexes.sh: Stop hardcoding archive gpg key ID, get it from first failed apt-get update output --- test/test-indexes.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index e82633022..58b9cff72 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -8,7 +8,6 @@ BUILDDIR=$(readlink -f $(dirname $0)/../build) TEST_SOURCE="http://ftp.debian.org/debian unstable contrib" -TEST_SOURCE_KEYID=55BE302B GPG_KEYSERVER=gpg-keyserver.de # should be a small package with dependencies satisfiable in TEST_SOURCE, i. e. # ideally no depends at all @@ -42,11 +41,15 @@ touch var/lib/dpkg/status echo "deb $TEST_SOURCE" > etc/apt/sources.list echo "deb-src $TEST_SOURCE" >> etc/apt/sources.list -# get keyring -gpg --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $TEST_SOURCE_KEYID - echo "---- uncompressed update ----" +# first attempt should fail, no trusted GPG key +out=$($APT_GET update 2>&1) +echo "$out" | grep -q NO_PUBKEY +key=$(echo "$out" | sed -n '/NO_PUBKEY/ { s/^.*NO_PUBKEY \([[:alnum:]]\+\)$/\1/; p}') +# get keyring +gpg --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $key $APT_GET update + test -e var/lib/apt/lists/*_Packages test -e var/lib/apt/lists/*_Sources ! test -e var/lib/apt/lists/*_Packages.gz -- cgit v1.2.3 From 8d60bef0c235f86772686df1499ae5e9593437e2 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 17 Jun 2010 11:17:13 +0200 Subject: test-indexes.sh: More verbose failures on wrong/missing indexes --- test/test-indexes.sh | 53 +++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index 58b9cff72..d79e9e7e4 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -27,6 +27,28 @@ APT_CACHE="$BUILDDIR/bin/apt-cache $OPTS $DEBUG" exit 1 } +# if $1 == "compressed", check that we have compressed indexes, otherwise +# uncompressed ones +check_indexes() { + local F + if [ "$1" = "compressed" ]; then + ! test -e var/lib/apt/lists/*_Packages || F=1 + ! test -e var/lib/apt/lists/*_Sources || F=1 + test -e var/lib/apt/lists/*_Packages.gz || F=1 + test -e var/lib/apt/lists/*_Sources.gz || F=1 + else + test -e var/lib/apt/lists/*_Packages || F=1 + test -e var/lib/apt/lists/*_Sources || F=1 + ! test -e var/lib/apt/lists/*_Packages.gz || F=1 + ! test -e var/lib/apt/lists/*_Sources.gz || F=1 + fi + + if [ -n "$F" ]; then + ls -l var/lib/apt/lists/ + exit 1 + fi +} + echo "---- building sandbox----" WORKDIR=$(mktemp -d) trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM @@ -49,11 +71,7 @@ key=$(echo "$out" | sed -n '/NO_PUBKEY/ { s/^.*NO_PUBKEY \([[:alnum:]]\+\)$/\1/; # get keyring gpg --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $key $APT_GET update - -test -e var/lib/apt/lists/*_Packages -test -e var/lib/apt/lists/*_Sources -! test -e var/lib/apt/lists/*_Packages.gz -! test -e var/lib/apt/lists/*_Sources.gz +check_indexes echo "---- uncompressed cache ----" $APT_CACHE show $TEST_PKG | grep -q ^Version: @@ -84,25 +102,16 @@ rm -r $TEST_SRC* echo "----- uncompressed update with preexisting indexes, no pdiff ----" $APT_GET -o Acquire::PDiffs=false update -test -e var/lib/apt/lists/*_Packages -test -e var/lib/apt/lists/*_Sources -! test -e var/lib/apt/lists/*_Packages.gz -! test -e var/lib/apt/lists/*_Sources.gz +check_indexes echo "----- uncompressed update with preexisting indexes, with pdiff ----" $APT_GET -o Acquire::PDiffs=true update -test -e var/lib/apt/lists/*_Packages -test -e var/lib/apt/lists/*_Sources -! test -e var/lib/apt/lists/*_Packages.gz -! test -e var/lib/apt/lists/*_Sources.gz +check_indexes echo "----- compressed update ----" find var/lib/apt/lists/ -type f | xargs -r rm $APT_GET -o Acquire::GzipIndexes=true update -! test -e var/lib/apt/lists/*_Packages -! test -e var/lib/apt/lists/*_Sources -test -e var/lib/apt/lists/*_Packages.gz -test -e var/lib/apt/lists/*_Sources.gz +check_indexes compressed echo "---- compressed cache ----" $APT_CACHE show $TEST_PKG | grep -q ^Version: @@ -131,16 +140,10 @@ rm -r $TEST_SRC* echo "----- compressed update with preexisting indexes, no pdiff ----" $APT_GET -o Acquire::PDiffs=false -o Acquire::GzipIndexes=true update -! test -e var/lib/apt/lists/*_Packages -! test -e var/lib/apt/lists/*_Sources -test -e var/lib/apt/lists/*_Packages.gz -test -e var/lib/apt/lists/*_Sources.gz +check_indexes compressed echo "----- compressed update with preexisting indexes, with pdiff ----" $APT_GET -o Acquire::PDiffs=true -o Acquire::GzipIndexes=true update -! test -e var/lib/apt/lists/*_Packages -! test -e var/lib/apt/lists/*_Sources -test -e var/lib/apt/lists/*_Packages.gz -test -e var/lib/apt/lists/*_Sources.gz +check_indexes compressed echo "---- ALL TESTS PASSED ----" -- cgit v1.2.3 From 2aab191f2a87d4d33a78d76e3c2978689c142190 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 17 Jun 2010 11:47:51 +0200 Subject: test-indexes.sh: Refactor common code into functions --- test/test-indexes.sh | 155 +++++++++++++++++++++++++++------------------------ 1 file changed, 81 insertions(+), 74 deletions(-) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index d79e9e7e4..fdc1a698a 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -15,7 +15,7 @@ TEST_PKG="python-psyco-doc" export LD_LIBRARY_PATH=$BUILDDIR/bin -OPTS="-o RootDir=. -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true" +OPTS="-qq -o RootDir=. -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true" DEBUG="" #DEBUG="-o Debug::pkgCacheGen=true" #DEBUG="-o Debug::pkgAcquire=true" @@ -27,9 +27,25 @@ APT_CACHE="$BUILDDIR/bin/apt-cache $OPTS $DEBUG" exit 1 } +check_update() { + echo "--- apt-get update $@ (no trusted keys)" + + rm -f etc/apt/trusted.gpg etc/apt/secring.gpg + touch etc/apt/trusted.gpg etc/apt/secring.gpg + out=$($APT_GET "$@" update 2>&1) + echo "$out" | grep -q NO_PUBKEY + key=$(echo "$out" | sed -n '/NO_PUBKEY/ { s/^.*NO_PUBKEY \([[:alnum:]]\+\)$/\1/; p}') + # get keyring + gpg -q --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $key + + echo "--- apt-get update $@ (with trusted keys)" + $APT_GET "$@" update +} + # if $1 == "compressed", check that we have compressed indexes, otherwise # uncompressed ones check_indexes() { + echo "--- only ${1:-uncompressed} index files present" local F if [ "$1" = "compressed" ]; then ! test -e var/lib/apt/lists/*_Packages || F=1 @@ -44,12 +60,54 @@ check_indexes() { fi if [ -n "$F" ]; then - ls -l var/lib/apt/lists/ + ls -laR var/lib/apt/lists/ exit 1 fi } -echo "---- building sandbox----" +# test apt-cache commands +check_cache() { + echo "--- apt-cache commands" + + $APT_CACHE show $TEST_PKG | grep -q ^Version: + # again (with cache) + $APT_CACHE show $TEST_PKG | grep -q ^Version: + rm var/cache/apt/*.bin + $APT_CACHE policy $TEST_PKG | grep -q '500 http://' + # again (with cache) + $APT_CACHE policy $TEST_PKG | grep -q '500 http://' + + TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print $2}'` + rm var/cache/apt/*.bin + $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: + # again (with cache) + $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: +} + +# test apt-get install +check_install() { + echo "--- apt-get install" + + $APT_GET install -d $TEST_PKG + test -e var/cache/apt/archives/$TEST_PKG*.deb + $APT_GET clean + ! test -e var/cache/apt/archives/$TEST_PKG*.deb +} + +# test apt-get source +check_get_source() { + echo "--- apt-get source" + $APT_GET source $TEST_PKG + test -f $TEST_SRC_*.dsc + test -d $TEST_SRC-* + rm -r $TEST_SRC* +} + +############################################################################ +# main +############################################################################ + +echo "===== building sandbox =====" WORKDIR=$(mktemp -d) trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM cd $WORKDIR @@ -63,87 +121,36 @@ touch var/lib/dpkg/status echo "deb $TEST_SOURCE" > etc/apt/sources.list echo "deb-src $TEST_SOURCE" >> etc/apt/sources.list -echo "---- uncompressed update ----" +echo "===== uncompressed indexes =====" # first attempt should fail, no trusted GPG key -out=$($APT_GET update 2>&1) -echo "$out" | grep -q NO_PUBKEY -key=$(echo "$out" | sed -n '/NO_PUBKEY/ { s/^.*NO_PUBKEY \([[:alnum:]]\+\)$/\1/; p}') -# get keyring -gpg --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $key -$APT_GET update +check_update check_indexes +check_cache +check_install +check_get_source -echo "---- uncompressed cache ----" -$APT_CACHE show $TEST_PKG | grep -q ^Version: -# again (with cache) -$APT_CACHE show $TEST_PKG | grep -q ^Version: -rm var/cache/apt/*.bin -$APT_CACHE policy $TEST_PKG | grep -q '500 http://' -# again (with cache) -$APT_CACHE policy $TEST_PKG | grep -q '500 http://' - -TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print $2}'` -rm var/cache/apt/*.bin -$APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: -# again (with cache) -$APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: - -echo "---- uncompressed install ----" -$APT_GET install -d $TEST_PKG -test -e var/cache/apt/archives/$TEST_PKG*.deb -$APT_GET clean -! test -e var/cache/apt/archives/$TEST_PKG*.deb - -echo "---- uncompressed get source ----" -$APT_GET source $TEST_PKG -test -f $TEST_SRC_*.dsc -test -d $TEST_SRC-* -rm -r $TEST_SRC* - -echo "----- uncompressed update with preexisting indexes, no pdiff ----" -$APT_GET -o Acquire::PDiffs=false update +echo "--- apt-get update with preexisting indexes" +$APT_GET update check_indexes -echo "----- uncompressed update with preexisting indexes, with pdiff ----" +echo "--- apt-get update with preexisting indexes and pdiff mode" $APT_GET -o Acquire::PDiffs=true update check_indexes -echo "----- compressed update ----" +echo "===== compressed indexes =====" find var/lib/apt/lists/ -type f | xargs -r rm -$APT_GET -o Acquire::GzipIndexes=true update +check_update -o Acquire::GzipIndexes=true check_indexes compressed +check_cache +check_install +check_get_source -echo "---- compressed cache ----" -$APT_CACHE show $TEST_PKG | grep -q ^Version: -# again (with cache) -$APT_CACHE show $TEST_PKG | grep -q ^Version: -rm var/cache/apt/*.bin -$APT_CACHE policy $TEST_PKG | grep -q '500 http://' -# again (with cache) -$APT_CACHE policy $TEST_PKG | grep -q '500 http://' - -TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print $2}'` -rm var/cache/apt/*.bin -$APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: -# again (with cache) -$APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: - -echo "---- compressed install ----" -$APT_GET install -d $TEST_PKG -! test -e var/cache/apt/archives/$TEST_PKG*.deb - -echo "---- compressed get source ----" -$APT_GET source $TEST_PKG -test -f $TEST_SRC_*.dsc -test -d $TEST_SRC-* -rm -r $TEST_SRC* - -echo "----- compressed update with preexisting indexes, no pdiff ----" -$APT_GET -o Acquire::PDiffs=false -o Acquire::GzipIndexes=true update -check_indexes compressed +echo "--- apt-get update with preexisting indexes" +check_update -o Acquire::GzipIndexes=true +check_indexes -echo "----- compressed update with preexisting indexes, with pdiff ----" -$APT_GET -o Acquire::PDiffs=true -o Acquire::GzipIndexes=true update -check_indexes compressed +echo "--- apt-get update with preexisting indexes and pdiff mode" +check_update -o Acquire::GzipIndexes=true -o Acquire::PDiffs=true update +check_indexes -echo "---- ALL TESTS PASSED ----" +echo "===== ALL TESTS PASSED =====" -- cgit v1.2.3 From 81563bc11a6491b85d55dbefa9f25f8035ab187e Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 17 Jun 2010 12:18:54 +0200 Subject: test-indexes: Use /etc/apt from temporary work dir, not from system --- test/test-indexes.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index fdc1a698a..452b0cc7a 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -15,7 +15,7 @@ TEST_PKG="python-psyco-doc" export LD_LIBRARY_PATH=$BUILDDIR/bin -OPTS="-qq -o RootDir=. -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true" +OPTS="-qq -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true" DEBUG="" #DEBUG="-o Debug::pkgCacheGen=true" #DEBUG="-o Debug::pkgAcquire=true" @@ -115,12 +115,18 @@ cd $WORKDIR rm -fr etc var rm -f home ln -s /home home -mkdir -p etc/apt/preferences.d etc/apt/trusted.gpg.d var/cache/apt/archives/partial var/lib/apt/lists/partial var/lib/dpkg +mkdir -p etc/apt/preferences.d etc/apt/trusted.gpg.d etc/apt/apt.conf.d var/cache/apt/archives/partial var/lib/apt/lists/partial var/lib/dpkg cp /etc/apt/trusted.gpg etc/apt touch var/lib/dpkg/status echo "deb $TEST_SOURCE" > etc/apt/sources.list echo "deb-src $TEST_SOURCE" >> etc/apt/sources.list +# specifying -o RootDir at the command line does not work for +# etc/apt/apt.conf.d/ since it is parsed after pkgInitConfig(); $APT_CONFIG is +# checked first, so this works +echo 'RootDir ".";' > apt_config +export APT_CONFIG=`pwd`/apt_config + echo "===== uncompressed indexes =====" # first attempt should fail, no trusted GPG key check_update -- cgit v1.2.3 From 08abac551a4bd4a26be4935d6f0707855f166da0 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 17 Jun 2010 13:18:19 +0200 Subject: test-indexes.sh: Actually test for non/pre-existing indexes in compressed mode --- test/test-indexes.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index 452b0cc7a..514e82534 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -32,6 +32,7 @@ check_update() { rm -f etc/apt/trusted.gpg etc/apt/secring.gpg touch etc/apt/trusted.gpg etc/apt/secring.gpg + find var/lib/apt/lists/ -type f | xargs -r rm out=$($APT_GET "$@" update 2>&1) echo "$out" | grep -q NO_PUBKEY key=$(echo "$out" | sed -n '/NO_PUBKEY/ { s/^.*NO_PUBKEY \([[:alnum:]]\+\)$/\1/; p}') @@ -39,6 +40,7 @@ check_update() { gpg -q --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $key echo "--- apt-get update $@ (with trusted keys)" + find var/lib/apt/lists/ -type f | xargs -r rm $APT_GET "$@" update } @@ -144,7 +146,6 @@ $APT_GET -o Acquire::PDiffs=true update check_indexes echo "===== compressed indexes =====" -find var/lib/apt/lists/ -type f | xargs -r rm check_update -o Acquire::GzipIndexes=true check_indexes compressed check_cache @@ -152,11 +153,11 @@ check_install check_get_source echo "--- apt-get update with preexisting indexes" -check_update -o Acquire::GzipIndexes=true +$APT_GET -o Acquire::GzipIndexes=true update check_indexes echo "--- apt-get update with preexisting indexes and pdiff mode" -check_update -o Acquire::GzipIndexes=true -o Acquire::PDiffs=true update +$APT_GET -o Acquire::GzipIndexes=true -o Acquire::PDiffs=true update check_indexes echo "===== ALL TESTS PASSED =====" -- cgit v1.2.3 From 321798bedb529edf914f2c884e4d38363c908315 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 17 Jun 2010 13:35:23 +0200 Subject: test-indexes.sh: fix check_indexes call in compressed mode --- test/test-indexes.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index 514e82534..2c6ccfedf 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -154,10 +154,10 @@ check_get_source echo "--- apt-get update with preexisting indexes" $APT_GET -o Acquire::GzipIndexes=true update -check_indexes +check_indexes compressed echo "--- apt-get update with preexisting indexes and pdiff mode" $APT_GET -o Acquire::GzipIndexes=true -o Acquire::PDiffs=true update -check_indexes +check_indexes compressed echo "===== ALL TESTS PASSED =====" -- cgit v1.2.3 From eee5ab3cb4a20a26468e6a0dc78ca0706b2b4ec6 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 17 Jun 2010 13:38:42 +0200 Subject: test-indexes.sh: Just for paranoia, test that apt-cache is still working after apt-get update with previously existing indexes --- test/test-indexes.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index 2c6ccfedf..84413d2dd 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -140,10 +140,12 @@ check_get_source echo "--- apt-get update with preexisting indexes" $APT_GET update check_indexes +check_cache echo "--- apt-get update with preexisting indexes and pdiff mode" $APT_GET -o Acquire::PDiffs=true update check_indexes +check_cache echo "===== compressed indexes =====" check_update -o Acquire::GzipIndexes=true @@ -155,9 +157,11 @@ check_get_source echo "--- apt-get update with preexisting indexes" $APT_GET -o Acquire::GzipIndexes=true update check_indexes compressed +check_cache echo "--- apt-get update with preexisting indexes and pdiff mode" $APT_GET -o Acquire::GzipIndexes=true -o Acquire::PDiffs=true update check_indexes compressed +check_cache echo "===== ALL TESTS PASSED =====" -- cgit v1.2.3 From 0311890f60a1075222acf066a6405cb452b475d0 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 17 Jun 2010 13:41:48 +0200 Subject: test-indexes.sh: Also test compressed index mode with apt.conf.d file --- test/test-indexes.sh | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index 84413d2dd..ce2c36481 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -33,12 +33,16 @@ check_update() { rm -f etc/apt/trusted.gpg etc/apt/secring.gpg touch etc/apt/trusted.gpg etc/apt/secring.gpg find var/lib/apt/lists/ -type f | xargs -r rm + + # first attempt should fail, no trusted GPG key out=$($APT_GET "$@" update 2>&1) echo "$out" | grep -q NO_PUBKEY key=$(echo "$out" | sed -n '/NO_PUBKEY/ { s/^.*NO_PUBKEY \([[:alnum:]]\+\)$/\1/; p}') + # get keyring gpg -q --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $key + # now it should work echo "--- apt-get update $@ (with trusted keys)" find var/lib/apt/lists/ -type f | xargs -r rm $APT_GET "$@" update @@ -130,7 +134,6 @@ echo 'RootDir ".";' > apt_config export APT_CONFIG=`pwd`/apt_config echo "===== uncompressed indexes =====" -# first attempt should fail, no trusted GPG key check_update check_indexes check_cache @@ -147,7 +150,7 @@ $APT_GET -o Acquire::PDiffs=true update check_indexes check_cache -echo "===== compressed indexes =====" +echo "===== compressed indexes (CLI option) =====" check_update -o Acquire::GzipIndexes=true check_indexes compressed check_cache @@ -164,4 +167,26 @@ $APT_GET -o Acquire::GzipIndexes=true -o Acquire::PDiffs=true update check_indexes compressed check_cache +echo "===== compressed indexes (apt.conf.d option) =====" +cat < etc/apt/apt.conf.d/02compress-indexes +Acquire::GzipIndexes "true"; +Acquire::CompressionTypes::Order:: "gz"; +EOF + +check_update +check_indexes compressed +check_cache +check_install +check_get_source + +echo "--- apt-get update with preexisting indexes" +$APT_GET update +check_indexes compressed +check_cache + +echo "--- apt-get update with preexisting indexes and pdiff mode" +$APT_GET -o Acquire::PDiffs=true update +check_indexes compressed +check_cache + echo "===== ALL TESTS PASSED =====" -- cgit v1.2.3 From 594bfe6a9f11e393469522fdea54444488d6f8a3 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 17 Jun 2010 13:58:39 +0200 Subject: test-indexes.sh: quiesce apt-get source; we know that we cannot verify package signatures --- test/test-indexes.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index ce2c36481..916532183 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -103,7 +103,8 @@ check_install() { # test apt-get source check_get_source() { echo "--- apt-get source" - $APT_GET source $TEST_PKG + # quiesce: it'll complain about not being able to verify the signature + $APT_GET source $TEST_PKG >/dev/null 2>&1 test -f $TEST_SRC_*.dsc test -d $TEST_SRC-* rm -r $TEST_SRC* -- cgit v1.2.3 From c19625e7dc99caea960c91b1ce6dc999ec6f4ed4 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 24 Jun 2010 21:27:59 +0200 Subject: test-indexes.sh: Test handling of local file:// archives --- test/test-indexes.sh | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index 916532183..b0ae4dcd4 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -21,6 +21,7 @@ DEBUG="" #DEBUG="-o Debug::pkgAcquire=true" APT_GET="$BUILDDIR/bin/apt-get $OPTS $DEBUG" APT_CACHE="$BUILDDIR/bin/apt-cache $OPTS $DEBUG" +APT_FTPARCHIVE="$BUILDDIR/bin/apt-ftparchive" [ -x "$BUILDDIR/bin/apt-get" ] || { echo "please build the tree first" >&2 @@ -79,9 +80,9 @@ check_cache() { # again (with cache) $APT_CACHE show $TEST_PKG | grep -q ^Version: rm var/cache/apt/*.bin - $APT_CACHE policy $TEST_PKG | grep -q '500 http://' + $APT_CACHE policy $TEST_PKG | egrep -q '500 (http://|file:/)' # again (with cache) - $APT_CACHE policy $TEST_PKG | grep -q '500 http://' + $APT_CACHE policy $TEST_PKG | egrep -q '500 (http://|file:/)' TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print $2}'` rm var/cache/apt/*.bin @@ -131,7 +132,7 @@ echo "deb-src $TEST_SOURCE" >> etc/apt/sources.list # specifying -o RootDir at the command line does not work for # etc/apt/apt.conf.d/ since it is parsed after pkgInitConfig(); $APT_CONFIG is # checked first, so this works -echo 'RootDir ".";' > apt_config +echo "RootDir \"$WORKDIR\";" > apt_config export APT_CONFIG=`pwd`/apt_config echo "===== uncompressed indexes =====" @@ -190,4 +191,34 @@ $APT_GET -o Acquire::PDiffs=true update check_indexes compressed check_cache +rm etc/apt/apt.conf.d/02compress-indexes + +echo "==== apt-ftparchive ====" +mkdir arch +$APT_GET install -d $TEST_PKG +cp var/cache/apt/archives/$TEST_PKG*.deb arch/ +cd arch +$APT_GET source -d $TEST_PKG >/dev/null 2>&1 +$APT_FTPARCHIVE packages . | gzip -9 > Packages.gz +$APT_FTPARCHIVE sources . | gzip -9 > Sources.gz +cd .. + +echo "deb file://$WORKDIR/arch / +deb-src file://$WORKDIR/arch /" > etc/apt/sources.list +$APT_GET clean + +echo "==== uncompressed indexes from local file:// archive ====" +echo "--- apt-get update" +$APT_GET update +check_indexes +check_cache +check_get_source + +echo "==== compressed indexes from local file:// archive ====" +echo "--- apt-get update" +$APT_GET -o Acquire::GzipIndexes=true update +check_indexes compressed +check_cache +check_get_source + echo "===== ALL TESTS PASSED =====" -- cgit v1.2.3 From 9a3a552a2859040ffc587a4e5d8d96311038e680 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 24 Jun 2010 22:59:48 +0200 Subject: test-indexes.sh: EXFAIL: file:/ URIs currently decompress even with the GzipIndexes option; not a big deal for now --- test/test-indexes.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test-indexes.sh b/test/test-indexes.sh index b0ae4dcd4..dad3e1fb2 100755 --- a/test/test-indexes.sh +++ b/test/test-indexes.sh @@ -217,7 +217,9 @@ check_get_source echo "==== compressed indexes from local file:// archive ====" echo "--- apt-get update" $APT_GET -o Acquire::GzipIndexes=true update -check_indexes compressed +# EXFAIL: file:/ URIs currently decompress even with above option +#check_indexes compressed +check_indexes check_cache check_get_source -- cgit v1.2.3 From c4ba7c44ff03d67ff982bbab26dc48d796041e02 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 25 Jun 2010 19:16:12 +0200 Subject: add a simple stack handling to be able to delay error handling --- test/libapt/globalerror_test.cc | 77 +++++++++++++++++++++++++++++++++++++++++ test/libapt/makefile | 10 ++++-- 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 test/libapt/globalerror_test.cc (limited to 'test') diff --git a/test/libapt/globalerror_test.cc b/test/libapt/globalerror_test.cc new file mode 100644 index 000000000..b2752255f --- /dev/null +++ b/test/libapt/globalerror_test.cc @@ -0,0 +1,77 @@ +#include + +#include "assert.h" +#include + +int main(int argc,char *argv[]) +{ + equals(_error->empty(), true); + equals(_error->PendingError(), false); + equals(_error->Notice("%s Notice", "A"), false); + equals(_error->empty(), true); + equals(_error->empty(GlobalError::DEBUG), false); + equals(_error->PendingError(), false); + equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false); + equals(_error->PendingError(), true); + std::string text; + equals(_error->PopMessage(text), false); + equals(_error->PendingError(), true); + equals(text, "A Notice"); + equals(_error->PopMessage(text), true); + equals(text, "Something horrible happend 2 times"); + equals(_error->empty(GlobalError::DEBUG), true); + equals(_error->PendingError(), false); + equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false); + equals(_error->PendingError(), true); + equals(_error->empty(GlobalError::FATAL), false); + _error->Discard(); + + equals(_error->empty(), true); + equals(_error->PendingError(), false); + equals(_error->Notice("%s Notice", "A"), false); + equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false); + equals(_error->PendingError(), true); + equals(_error->empty(GlobalError::NOTICE), false); + _error->PushToStack(); + equals(_error->empty(GlobalError::NOTICE), true); + equals(_error->PendingError(), false); + equals(_error->Warning("%s Warning", "A"), false); + equals(_error->empty(GlobalError::ERROR), true); + equals(_error->PendingError(), false); + _error->RevertToStack(); + equals(_error->empty(GlobalError::ERROR), false); + equals(_error->PendingError(), true); + equals(_error->PopMessage(text), false); + equals(_error->PendingError(), true); + equals(text, "A Notice"); + equals(_error->PopMessage(text), true); + equals(text, "Something horrible happend 2 times"); + equals(_error->PendingError(), false); + equals(_error->empty(), true); + + equals(_error->Notice("%s Notice", "A"), false); + equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false); + equals(_error->PendingError(), true); + equals(_error->empty(GlobalError::NOTICE), false); + _error->PushToStack(); + equals(_error->empty(GlobalError::NOTICE), true); + equals(_error->PendingError(), false); + equals(_error->Warning("%s Warning", "A"), false); + equals(_error->empty(GlobalError::ERROR), true); + equals(_error->PendingError(), false); + _error->MergeWithStack(); + equals(_error->empty(GlobalError::ERROR), false); + equals(_error->PendingError(), true); + equals(_error->PopMessage(text), false); + equals(_error->PendingError(), true); + equals(text, "A Notice"); + equals(_error->PopMessage(text), true); + equals(text, "Something horrible happend 2 times"); + equals(_error->PendingError(), false); + equals(_error->empty(), false); + equals(_error->PopMessage(text), false); + equals(text, "A Warning"); + equals(_error->empty(), true); + + return 0; +} diff --git a/test/libapt/makefile b/test/libapt/makefile index ee3401b35..50058262e 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -30,13 +30,19 @@ SOURCE = getlistoffilesindir_test.cc include $(PROGRAM_H) # Program for testing CommandLine reconstruction -PROGRAM = commandlineasstring${BASENAME} +PROGRAM = CommandlineAsString${BASENAME} SLIBS = -lapt-pkg SOURCE = commandlineasstring_test.cc include $(PROGRAM_H) # Program for testing debians version comparing -PROGRAM = compareversion${BASENAME} +PROGRAM = CompareVersion${BASENAME} SLIBS = -lapt-pkg SOURCE = compareversion_test.cc include $(PROGRAM_H) + +# test the GlobalError stack class +PROGRAM = GlobalError${BASENAME} +SLIBS = -lapt-pkg +SOURCE = globalerror_test.cc +include $(PROGRAM_H) -- cgit v1.2.3 From af5cf9299fb60c255d4c1c30ca9a97e7e6acfef0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 5 Jul 2010 12:12:40 +0200 Subject: extends the ParseDepends testcase to have a look also at the Wildcards --- test/libapt/parsedepends_test.cc | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'test') diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc index b7befa561..7b496878d 100644 --- a/test/libapt/parsedepends_test.cc +++ b/test/libapt/parsedepends_test.cc @@ -21,6 +21,12 @@ int main(int argc,char *argv[]) { "apt (>= 0.7.25), " "not-for-me [ !dsk ], " "only-for-me [ dsk ], " + "any-for-me [ any ], " + "not-for-darwin [ !darwin-any ], " + "cpu-for-me [ any-dsk ], " + "os-for-me [ linux-any ], " + "cpu-not-for-me [ any-amd64 ], " + "os-not-for-me [ kfreebsd-any ], " "overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), " ; @@ -100,6 +106,68 @@ test: Start++; } + if (ParseArchFlags == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + equals("any-for-me", Package); + equals("", Version); + equals(Null | pkgCache::Dep::NoOp, Op); + } else { + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + Start = strstr(Start, ","); + Start++; + } + + if (ParseArchFlags == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + equals("not-for-darwin", Package); + equals("", Version); + equals(Null | pkgCache::Dep::NoOp, Op); + } else { + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + Start = strstr(Start, ","); + Start++; + } + + if (ParseArchFlags == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + equals("cpu-for-me", Package); + equals("", Version); + equals(Null | pkgCache::Dep::NoOp, Op); + } else { + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + Start = strstr(Start, ","); + Start++; + } + + if (ParseArchFlags == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + equals("os-for-me", Package); + equals("", Version); + equals(Null | pkgCache::Dep::NoOp, Op); + } else { + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + Start = strstr(Start, ","); + Start++; + } + + if (ParseArchFlags == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + equals("", Package); // cpu-not-for-me + } else { + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + Start = strstr(Start, ","); + Start++; + } + + if (ParseArchFlags == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + equals("", Package); // os-not-for-me + } else { + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + Start = strstr(Start, ","); + Start++; + } + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); if (StripMultiArch == true) equals("overlord-dev", Package); -- cgit v1.2.3 From 8d87641558a7e0ee53b03e325614532aa686e01b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 25 Jul 2010 19:51:53 +0200 Subject: - prefer non-virtual packages in FindPreferredPkg (Closes: #590041) * test/integration/*: - add with bug#590041 testcase a small test "framework" --- test/integration/framework | 170 +++++++++++++++++++++ test/integration/run-tests | 8 + .../test-bug-590041-prefer-non-virtual-packages | 51 +++++++ 3 files changed, 229 insertions(+) create mode 100644 test/integration/framework create mode 100755 test/integration/run-tests create mode 100755 test/integration/test-bug-590041-prefer-non-virtual-packages (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework new file mode 100644 index 000000000..97dce1e19 --- /dev/null +++ b/test/integration/framework @@ -0,0 +1,170 @@ +#!/bin/sh -- # no runable script, just for vi + +# we all like colorful messages +CERROR="" # red +CWARNING="" # yellow +CMSG="" # green +CINFO="" # light blue +CDEBUG="" # blue +CNORMAL="" # default system console color +CDONE="" # green +CPASS="" # green +CFAIL="" # red +CCMD="" # pink + +msgdie() { echo "${CERROR}E: $1${CNORMAL}" >&2; exit 1; } +msgwarn() { echo "${CWARNING}W: $1${CNORMAL}" >&2; } +msgmsg() { echo "${CMSG}$1${CNORMAL}" >&2; } +msginfo() { echo "${CINFO}I: $1${CNORMAL}" >&2; } +msgdebug() { echo "${CDEBUG}D: $1${CNORMAL}" >&2; } +msgdone() { echo "${CDONE}DONE${CNORMAL}" >&2; } +msgnwarn() { echo -n "${CWARNING}W: $1${CNORMAL}" >&2; } +msgnmsg() { echo -n "${CMSG}$1${CNORMAL}" >&2; } +msgninfo() { echo -n "${CINFO}I: $1${CNORMAL}" >&2; } +msgndebug() { echo -n "${CDEBUG}D: $1${CNORMAL}" >&2; } +msgtest() { echo -n "${CINFO}$1 ${CCMD}$(echo "$2" | sed -e 's/^aptc/apt-c/' -e 's/^aptg/apt-g/' -e 's/^aptf/apt-f/')${CINFO} …${CNORMAL} " >&2; } +msgpass() { echo "${CPASS}PASS${CNORMAL}" >&2; } +msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; } +msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; } + +# enable / disable Debugging +msginfo() { true; } +msgdebug() { true; } +msgninfo() { true; } +msgndebug() { true; } +msgdone() { if [ "$1" = "debug" -o "$1" = "info" ]; then true; else echo "${CDONE}DONE${CNORMAL}" >&2; fi } + +runapt() { + msgdebug "Executing: ${CCMD}$*${CDEBUG} " + APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$* +} +aptconfig() { runapt apt-config $*; } +aptcache() { runapt apt-cache $*; } +aptget() { runapt apt-get $*; } +aptftparchive() { runapt apt-ftparchive $*; } + +setupenvironment() { + local TMPWORKINGDIRECTORY=$(mktemp -d) + msgninfo "Preparing environment for ${CCMD}$0${CINFO} in ${TMPWORKINGDIRECTORY}… " + BUILDDIRECTORY=$(readlink -f $(dirname $0)/../../build/bin) + test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first" + local OLDWORKINGDIRECTORY=$(pwd) + trap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM + cd $TMPWORKINGDIRECTORY + mkdir rootdir aptarchive + cd rootdir + mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d var/cache var/lib/dpkg + mkdir -p var/cache/apt/archives/partial var/lib/apt/lists/partial + touch var/lib/dpkg/status + mkdir -p usr/lib/apt + ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods + cd .. + echo "RootDir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf + echo "Debug::NoLocking \"true\";" >> aptconfig.conf + echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf + export LC_ALL=C + msgdone "info" +} + +configarchitecture() { + local CONFFILE=rootdir/etc/apt/apt.conf.d/01multiarch.conf + echo "APT::Architecture \"$1\";" > $CONFFILE + shift + while [ -n "$1" ]; do + echo "APT::Architectures:: \"$1\";" >> $CONFFILE + shift + done +} + +buildflataptarchive() { + msginfo "Build APT archive for ${CCMD}$0${CINFO}…" + cd aptarchive + APTARCHIVE=$(readlink -f .) + if [ -f Packages ]; then + msgninfo "\tPackages file… " + cat Packages | gzip > Packages.gz + cat Packages | bzip2 > Packages.bz2 + cat Packages | lzma > Packages.lzma + msgdone "info" + fi + if [ -f Sources ]; then + msgninfo "\tSources file… " + cat Sources | gzip > Sources.gz + cat Sources | bzip2 > Sources.bz2 + cat Sources | lzma > Sources.lzma + msgdone "info" + fi + cd .. + aptftparchive release . > Release +} + +setupflataptarchive() { + buildflataptarchive + APTARCHIVE=$(readlink -f ./aptarchive) + if [ -f ${APTARCHIVE}/Packages ]; then + msgninfo "\tadd deb sources.list line… " + echo "deb file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list + msgdone "info" + else + rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list + fi + if [ -f ${APTARCHIVE}/Sources ]; then + msgninfo "\tadd deb-src sources.list line… " + echo "deb-src file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list + msgdone "info" + else + rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list + fi + aptget update -qq +} + +diff() { + local DIFFTEXT="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')" + if [ -n "$DIFFTEXT" ]; then + echo + echo "$DIFFTEXT" + return 1 + else + return 0 + fi +} + +testequal() { + local COMPAREFILE=$(mktemp) + echo "$1" > $COMPAREFILE + shift + msgtest "Test for equality of" "$*" + $* 2>&1 | diff $COMPAREFILE - && msgpass || msgfail +} + +testshowvirtual() { + local VIRTUAL="E: Can't select versions from package '$1' as it purely virtual" + local PACKAGE="$1" + shift + while [ -n "$1" ]; do + VIRTUAL="${VIRTUAL} +E: Can't select versions from package '$1' as it purely virtual" + PACKAGE="${PACKAGE} $1" + shift + done + msgtest "Test for virtual packages" "apt-cache show $PACKAGE" + VIRTUAL="${VIRTUAL} +E: No packages found" + local COMPAREFILE=$(mktemp) + local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH_CPU) + eval `apt-config shell ARCH APT::Architecture` + echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE + aptcache show $PACKAGE 2>&1 | diff $COMPAREFILE - && msgpass || msgfail +} + +testnopackage() { + msgtest "Test for non-existent packages" "apt-cache show $*" + local SHOWPKG="$(aptcache show $* 2>&1 | grep '^Package: ')" + if [ -n "$SHOWPKG" ]; then + echo + echo "$SHOWPKG" + msgfail + return 1 + fi + msgpass +} diff --git a/test/integration/run-tests b/test/integration/run-tests new file mode 100755 index 000000000..cb74f21e7 --- /dev/null +++ b/test/integration/run-tests @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +local DIR=$(readlink -f $(dirname $0)) +for testcase in $(run-parts --list $DIR | grep '/test-'); do + echo "\033[1;32mRun Testcase \033[1;35m$(basename ${testcase})\033[0m" + ${testcase} +done diff --git a/test/integration/test-bug-590041-prefer-non-virtual-packages b/test/integration/test-bug-590041-prefer-non-virtual-packages new file mode 100755 index 000000000..aa9e487e1 --- /dev/null +++ b/test/integration/test-bug-590041-prefer-non-virtual-packages @@ -0,0 +1,51 @@ +#!/bin/sh +set -e + +. $(readlink -f $(dirname $0))/framework +setupenvironment +configarchitecture "i386" "armel" + +pkglibc6="Package: libc6 +Architecture: armel +Version: 2.11.2-2~0.3 +Description: Embedded GNU C Library: Shared libraries +Filename: pool/main/e/eglibc/libc6_2.11.2-2_armel.deb +Installed-Size: 9740 +MD5sum: f5b878ce5fb8aa01a7927fa1460df537 +Maintainer: GNU Libc Maintainers +Priority: required +SHA1: 0464d597dfbf949e8c17a42325b1f93fb4914afd +SHA256: faca4a3d9ccff57568abf41f6cb81ddd835be7b5d8b0161e2d5f9a7f26aae3c0 +Section: libs +Size: 4178958 +" + +pkglibdb1="Package: libdb1 +Architecture: i386 +Version: 2.1.3-13~0.3 +Replaces: libc6 (<< 2.2.5-13~0.3) +Description: The Berkeley database routines [glibc 2.0/2.1 compatibility] +Filename: pool/main/d/db1-compat/libdb1-compat_2.1.3-13_armel.deb +Installed-Size: 136 +MD5sum: 4043f176ab2b40b0c01bc1211b8c103c +Maintainer: Colin Watson +Priority: extra +SHA1: b9396fdd2e3e8d1d4ba9e74e7346075852d85666 +SHA256: f17decaa28d1db3eeb9eb17bebe50d437d293a509bcdd7cdfd3ebb56f5de3cea +Section: oldlibs +Size: 44168 +" + +cat <<-EOF >aptarchive/Packages +$pkglibc6 +$pkglibdb1 +EOF + +setupflataptarchive + +testshowvirtual libc6:i386 +testequal "$pkglibc6" aptcache show libc6:armel +testequal "$pkglibc6" aptcache show libc6 +testequal "$pkglibdb1" aptcache show libdb1:i386 +testnopackage libdb1:armel +testequal "$pkglibdb1" aptcache show libdb1 -- cgit v1.2.3 From f6bfb482a32543deed925b127c972a7c258df4a1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 25 Jul 2010 20:04:16 +0200 Subject: Strip the .sh extension from the libapt testrunner and make it a bit more robust against calling from outside --- test/libapt/run-tests | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ test/libapt/run-tests.sh | 60 ----------------------------------------------- 2 files changed, 61 insertions(+), 60 deletions(-) create mode 100755 test/libapt/run-tests delete mode 100755 test/libapt/run-tests.sh (limited to 'test') diff --git a/test/libapt/run-tests b/test/libapt/run-tests new file mode 100755 index 000000000..0f55f7386 --- /dev/null +++ b/test/libapt/run-tests @@ -0,0 +1,61 @@ +#!/bin/sh +set -e + +local DIR=$(readlink -f $(dirname $0)) +echo "Compiling the tests …" +test -d "$DIR/../../build/obj/test/libapt/" || mkdir -p "$DIR/../../build/obj/test/libapt/" +$(cd $DIR && make) +echo "Running all testcases …" +LDPATH="$DIR/../../build/bin" +EXT="_libapt_test" +for testapp in $(ls ${LDPATH}/*$EXT) +do + name=$(basename ${testapp}) + tmppath="" + + if [ $name = "GetListOfFilesInDir${EXT}" ]; then + # TODO: very-low: move env creation to the actual test-app + echo "Prepare Testarea for \033[1;35m$name\033[0m ..." + tmppath=$(mktemp -d) + touch "${tmppath}/anormalfile" \ + "${tmppath}/01yet-anothernormalfile" \ + "${tmppath}/anormalapt.conf" \ + "${tmppath}/01yet-anotherapt.conf" \ + "${tmppath}/anormalapt.list" \ + "${tmppath}/01yet-anotherapt.list" \ + "${tmppath}/wrongextension.wron" \ + "${tmppath}/wrong-extension.wron" \ + "${tmppath}/strangefile." \ + "${tmppath}/s.t.r.a.n.g.e.f.i.l.e" \ + "${tmppath}/.hiddenfile" \ + "${tmppath}/.hiddenfile.conf" \ + "${tmppath}/.hiddenfile.list" \ + "${tmppath}/multi..dot" \ + "${tmppath}/multi.dot.conf" \ + "${tmppath}/multi.dot.list" \ + "${tmppath}/disabledfile.disabled" \ + "${tmppath}/disabledfile.conf.disabled" \ + "${tmppath}/disabledfile.list.disabled" \ + "${tmppath}/invälid.conf" \ + "${tmppath}/invalíd" \ + "${tmppath}/01invalíd" + ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list" + ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list" + elif [ $name = "getLanguages${EXT}" ]; then + echo "Prepare Testarea for \033[1;35m$name\033[0m ..." + tmppath=$(mktemp -d) + touch "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tr" \ + "${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" + fi + + echo -n "Testing with \033[1;35m${name}\033[0m ... " + LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m" + + if [ -n "$tmppath" -a -d "$tmppath" ]; then + echo "Cleanup Testarea after \033[1;35m$name\033[0m ..." + rm -rf "$tmppath" + fi + +done diff --git a/test/libapt/run-tests.sh b/test/libapt/run-tests.sh deleted file mode 100755 index cb7769e4a..000000000 --- a/test/libapt/run-tests.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -set -e - -echo "Compiling the tests ..." -test -d '../../build/obj/test/libapt/' || mkdir -p '../../build/obj/test/libapt/' -make -echo "Running all testcases ..." -LDPATH=$(pwd)/../../build/bin -EXT="_libapt_test" -for testapp in $(ls ${LDPATH}/*$EXT) -do - name=$(basename ${testapp}) - tmppath="" - - if [ $name = "GetListOfFilesInDir${EXT}" ]; then - # TODO: very-low: move env creation to the actual test-app - echo "Prepare Testarea for \033[1;35m$name\033[0m ..." - tmppath=$(mktemp -d) - touch "${tmppath}/anormalfile" \ - "${tmppath}/01yet-anothernormalfile" \ - "${tmppath}/anormalapt.conf" \ - "${tmppath}/01yet-anotherapt.conf" \ - "${tmppath}/anormalapt.list" \ - "${tmppath}/01yet-anotherapt.list" \ - "${tmppath}/wrongextension.wron" \ - "${tmppath}/wrong-extension.wron" \ - "${tmppath}/strangefile." \ - "${tmppath}/s.t.r.a.n.g.e.f.i.l.e" \ - "${tmppath}/.hiddenfile" \ - "${tmppath}/.hiddenfile.conf" \ - "${tmppath}/.hiddenfile.list" \ - "${tmppath}/multi..dot" \ - "${tmppath}/multi.dot.conf" \ - "${tmppath}/multi.dot.list" \ - "${tmppath}/disabledfile.disabled" \ - "${tmppath}/disabledfile.conf.disabled" \ - "${tmppath}/disabledfile.list.disabled" \ - "${tmppath}/invälid.conf" \ - "${tmppath}/invalíd" \ - "${tmppath}/01invalíd" - ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list" - ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list" - elif [ $name = "getLanguages${EXT}" ]; then - echo "Prepare Testarea for \033[1;35m$name\033[0m ..." - tmppath=$(mktemp -d) - touch "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tr" \ - "${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" - fi - - echo -n "Testing with \033[1;35m${name}\033[0m ... " - LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m" - - if [ -n "$tmppath" -a -d "$tmppath" ]; then - echo "Cleanup Testarea after \033[1;35m$name\033[0m ..." - rm -rf "$tmppath" - fi - -done -- cgit v1.2.3 From 8f8169ac464249c8a2b35b13f9c5278d4c9e5a46 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 28 Jul 2010 21:47:42 +0200 Subject: auto-install Packages and status file of the testcase --- test/integration/framework | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index 97dce1e19..7e0d4b902 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -45,8 +45,9 @@ aptftparchive() { runapt apt-ftparchive $*; } setupenvironment() { local TMPWORKINGDIRECTORY=$(mktemp -d) + local TESTDIR=$(readlink -f $(dirname $0)) msgninfo "Preparing environment for ${CCMD}$0${CINFO} in ${TMPWORKINGDIRECTORY}… " - BUILDDIRECTORY=$(readlink -f $(dirname $0)/../../build/bin) + BUILDDIRECTORY="${TESTDIR}/../../build/bin" test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first" local OLDWORKINGDIRECTORY=$(pwd) trap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM @@ -55,10 +56,21 @@ setupenvironment() { cd rootdir mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d var/cache var/lib/dpkg mkdir -p var/cache/apt/archives/partial var/lib/apt/lists/partial - touch var/lib/dpkg/status + local STATUSFILE=$(echo "$(basename $0)" | sed 's/^test-/status-/') + if [ -f "${TESTDIR}/${STATUSFILE}" ]; then + cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status + else + touch var/lib/dpkg/status + fi mkdir -p usr/lib/apt ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods cd .. + local PACKAGESFILE=$(echo "$(basename $0)" | sed 's/^test-/Packages-/') + if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then + cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages + else + touch var/lib/dpkg/status + fi echo "RootDir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf echo "Debug::NoLocking \"true\";" >> aptconfig.conf echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf -- cgit v1.2.3 From 966640d8fd2feac29909a22415955b3ce5779dcd Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 28 Jul 2010 21:53:17 +0200 Subject: * apt-pkg/orderlist.cc: - try to install another or-group member in DepRemove before breaking the or group (Closes: #590438) --- ...g-590438-broken-provides-thanks-to-remove-order | 35 ++++++++ ...g-590438-broken-provides-thanks-to-remove-order | 97 ++++++++++++++++++++++ ...g-590438-broken-provides-thanks-to-remove-order | 59 +++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order create mode 100644 test/integration/status-bug-590438-broken-provides-thanks-to-remove-order create mode 100755 test/integration/test-bug-590438-broken-provides-thanks-to-remove-order (limited to 'test') diff --git a/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order new file mode 100644 index 000000000..16bf008f6 --- /dev/null +++ b/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order @@ -0,0 +1,35 @@ +Package: gawk +Priority: optional +Section: interpreters +Installed-Size: 2084 +Maintainer: Arthur Loiret +Architecture: i386 +Version: 1:3.1.7.dfsg-5 +Provides: awk +Pre-Depends: libc6 (>= 2.3) +Filename: pool/main/g/gawk/gawk_3.1.7.dfsg-5_i386.deb +Size: 766008 +MD5sum: 6459a02cfc1b9eafb3c0415e4ff4e252 +SHA1: ac033488dae4b7e8167d610e490319c047edf7e4 +SHA256: a2337dfe1cc82aeae46f2c722e5cc7be9ecefdea4aaf13f540cfe70bd8b1d627 +Description-de: GNU awk, eine Mustererkennungs- und Verarbeitungssprache +Homepage: http://www.gnu.org/software/gawk/ +Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, use::filtering, use::scanning, works-with::text + +Package: aawk +Priority: optional +Section: interpreters +Installed-Size: 2084 +Maintainer: Arthur Loiret +Architecture: i386 +Version: 1:3.1.7.dfsg-5 +Provides: awk +Pre-Depends: libc6 (>= 2.3) +Filename: pool/main/a/aawk/aawk_3.1.7.dfsg-5_i386.deb +Size: 766008 +MD5sum: 6459a02cfc1b9eafb3c0415e4ff4e252 +SHA1: ac033488dae4b7e8167d610e490319c047edf7e4 +SHA256: a2337dfe1cc82aeae46f2c722e5cc7be9ecefdea4aaf13f540cfe70bd8b1d627 +Description-de: GNU awk, eine Mustererkennungs- und Verarbeitungssprache +Homepage: http://www.gnu.org/software/gawk/ +Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, use::filtering, use::scanning, works-with::text diff --git a/test/integration/status-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/status-bug-590438-broken-provides-thanks-to-remove-order new file mode 100644 index 000000000..c2c03c0e4 --- /dev/null +++ b/test/integration/status-bug-590438-broken-provides-thanks-to-remove-order @@ -0,0 +1,97 @@ +Package: libc-bin +Status: install ok installed +Priority: required +Section: libs +Installed-Size: 1516 +Maintainer: GNU Libc Maintainers +Architecture: i386 +Source: eglibc +Version: 2.11.2-2 +Replaces: libc0.1, libc0.3, libc6, libc6.1 +Breaks: libc0.1 (<< 2.10), libc0.3 (<< 2.10), libc6 (<< 2.10), libc6.1 (<< 2.10) +Filename: pool/main/e/eglibc/libc-bin_2.11.2-2_i386.deb +Size: 703542 +MD5sum: f554ec34c092bb8e52e3d917bec7b46c +SHA1: 4d5ba53b50937b1d50e3234e45335de5ea97b84b +SHA256: 4f1e6430a730321209bb6b9cf89ba8a72c95f5c93f3e263a982251b3cc8beb14 +Description-de: Die »Embedded GNU C Library«: Binärdateien +Homepage: http://www.eglibc.org +Tag: devel::lang:c, devel::packaging, implemented-in::c, interface::commandline, role::program, scope::utility, special::auto-inst-parts, suite::gnu, works-with::text, works-with::unicode + +Package: libc6 +Status: install ok installed +Priority: required +Section: libs +Installed-Size: 9340 +Maintainer: GNU Libc Maintainers +Architecture: i386 +Source: eglibc +Version: 2.11.2-2 +Provides: glibc-2.11-1 +Depends: libc-bin (= 2.11.2-2), libgcc1 +Recommends: libc6-i686 +Suggests: glibc-doc, debconf | debconf-2.0, locales +Conflicts: tzdata (<< 2007k-1), tzdata-etch +Breaks: locales (<< 2.11), locales-all (<< 2.11), nscd (<< 2.11) +Filename: pool/main/e/eglibc/libc6_2.11.2-2_i386.deb +Size: 3877166 +MD5sum: 3d8fe972a359ad362ac1957c2687e5c2 +SHA1: cd901f3265254e40ad198b935877f546eeaa8403 +SHA256: e1bc3da1e11f9b742d05f927362e2079482db4186ff45af9f937d284e112e7e5 +Description-de: Die »Embedded GNU C Library«: Laufzeitbibliotheken +Homepage: http://www.eglibc.org +Tag: devel::lang:c, devel::library, implemented-in::c, protocol::ipv6, role::shared-lib, suite::gnu + +Package: mawk +Status: install ok installed +Priority: required +Section: utils +Installed-Size: 228 +Maintainer: Steve Langasek +Architecture: i386 +Version: 1.3.3-15 +Provides: awk +Pre-Depends: libc6 (>= 2.1) +Filename: pool/main/m/mawk/mawk_1.3.3-15_i386.deb +Size: 81430 +MD5sum: e0f9e9903a862a52b5f107d560c4d8e0 +SHA1: cca3b3ea3a57b9c3c136fb538a4fb06a99d1a33e +SHA256: 7449b10ffb6a8636a249ad6866188cad0040a6a446fb4a3a71d81fd136297ee6 +Description-de: Eine Muster- und Textverarbeitungssprache +Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, use::filtering, use::scanning, works-with::text + +Package: gcc-4.5-base +Status: install ok installed +Priority: required +Section: libs +Installed-Size: 172 +Maintainer: Debian GCC Maintainers +Architecture: i386 +Source: gcc-4.5 +Version: 4.5.0-8 +Filename: pool/main/g/gcc-4.5/gcc-4.5-base_4.5.0-8_i386.deb +Size: 117894 +MD5sum: f5850c42681fcfee3429a1b43da68433 +SHA1: 0548343feba69c4c01d5dbf147393d8dc27605ac +SHA256: 04b60f5fe24b7397e3be233051615ff9addb66d4581578f67fde76f5d7f69f7a +Description: The GNU Compiler Collection (base package) +Homepage: http://gcc.gnu.org/ + +Package: libgcc1 +Status: install ok installed +Priority: required +Section: libs +Installed-Size: 148 +Maintainer: Debian GCC Maintainers +Architecture: i386 +Source: gcc-4.5 (4.5.0-8) +Version: 1:4.5.0-8 +Depends: gcc-4.5-base (= 4.5.0-8), libc6 (>= 2.2.4) +Filename: pool/main/g/gcc-4.5/libgcc1_4.5.0-8_i386.deb +Size: 52190 +MD5sum: beda956a1dcdeffed11072c2d0f3eb83 +SHA1: 7117ec43eec7982a030fcc9a12d4772de3fcdba0 +SHA256: 1d10bd532adce8683b475fcc60c22300f717ef19bf84dc5bf43b07e504f85dcb +Description: GCC support library +Homepage: http://gcc.gnu.org/ + diff --git a/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order new file mode 100755 index 000000000..bb10c4f73 --- /dev/null +++ b/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order @@ -0,0 +1,59 @@ +#!/bin/sh +set -e + +local TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture "i386" +setupflataptarchive + +pkgbasefile="Package: base-files +Status: install ok installed +Essential: yes +Priority: required +Section: admin +Installed-Size: 472 +Maintainer: Santiago Vila +Architecture: i386 +Version: 5.8 +Replaces: base, dpkg (<= 1.15.0), miscutils +Provides: base +Filename: pool/main/b/base-files/base-files_5.8_i386.deb +Size: 73986 +MD5sum: 8489687ce10e656babd467c9ee389349 +Description-de: Verschiedene Dateien für das Basis-System von Debian" + +predependstest() { +# rm rootdir/var/cache/apt/*.bin + cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status + echo "$pkgbasefile +Pre-Depends: $1 +" >> rootdir/var/lib/dpkg/status + testequal "Inst gawk (1:3.1.7.dfsg-5 localhost [i386]) +Conf gawk (1:3.1.7.dfsg-5 localhost [i386]) +Remv mawk [1.3.3-15]" aptget install gawk mawk- -sqq -o PreDepends=$(echo "$1" | sed 's/ //g') +} + +predependstest "gawk | mawk" +predependstest "mawk | gawk" + +predependstest "aawk | mawk | gawk" +predependstest "aawk | gawk | mawk" + +predependstest "gawk | awk" +predependstest "aawk | gawk | awk" + +predependstest "mawk | awk" + +predependstest "awk | gawk" +predependstest "awk | gawk | aawk" + +predependstest "awk | mawk" + +predependstest "aawk | awk" +predependstest "awk | aawk" + +predependstest "awk" + +# aptget install gawk mawk- -sqq -o Debug::pkgOrderList=1 #-o Debug::pkgPackageManager=1 -- cgit v1.2.3 From 685625bd308f62a382aaf61f1621a18b9441edfd Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 29 Jul 2010 12:26:26 +0200 Subject: configure also the replacement before remove by adding Immediate flag --- ...g-590438-broken-provides-thanks-to-remove-order | 32 ++++++++++ test/integration/framework | 16 +++++ ...g-590438-broken-provides-thanks-to-remove-order | 69 +++++++++++++++++----- 3 files changed, 102 insertions(+), 15 deletions(-) (limited to 'test') diff --git a/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order index 16bf008f6..75a769e1a 100644 --- a/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order +++ b/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order @@ -33,3 +33,35 @@ SHA256: a2337dfe1cc82aeae46f2c722e5cc7be9ecefdea4aaf13f540cfe70bd8b1d627 Description-de: GNU awk, eine Mustererkennungs- und Verarbeitungssprache Homepage: http://www.gnu.org/software/gawk/ Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, use::filtering, use::scanning, works-with::text + +Package: gawk2 +Priority: optional +Section: interpreters +Installed-Size: 2084 +Maintainer: Arthur Loiret +Architecture: i386 +Version: 1:3.1.7.dfsg-5 +Provides: awk +Pre-Depends: libc6 (>= 2.3) +Depends: coolstuff +Filename: pool/main/g/gawk/gawk_3.1.7.dfsg-5_i386.deb +Size: 766008 +MD5sum: 6459a02cfc1b9eafb3c0415e4ff4e252 +SHA1: ac033488dae4b7e8167d610e490319c047edf7e4 +SHA256: a2337dfe1cc82aeae46f2c722e5cc7be9ecefdea4aaf13f540cfe70bd8b1d627 +Description-de: GNU awk, eine Mustererkennungs- und Verarbeitungssprache +Homepage: http://www.gnu.org/software/gawk/ +Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, use::filtering, use::scanning, works-with::text + +Package: coolstuff +Priority: optional +Section: cool +Installed-Size: 10 +Maintainer: David Kalnischkies +Architecture: all +Version: 1-1 +Filename: pool/main/c/coolstuff/coolstuff_1-1_all.deb +Size: 7608 +MD5sum: 6459aa2efc139eafb323ac3f4f5aeb22 +Description: We all need cool stuff + diff --git a/test/integration/framework b/test/integration/framework index 7e0d4b902..7b323fdb5 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -149,6 +149,22 @@ testequal() { $* 2>&1 | diff $COMPAREFILE - && msgpass || msgfail } +testequalor2() { + local COMPAREFILE1=$(mktemp) + local COMPAREFILE2=$(mktemp) + local COMPAREAGAINST=$(mktemp) + echo "$1" > $COMPAREFILE1 + echo "$2" > $COMPAREFILE2 + shift 2 + msgtest "Test for equality OR of" "$*" + $* 2>&1 1> $COMPAREAGAINST + (diff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null || + diff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null) && msgpass || + ( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(diff $COMPAREFILE1 $COMPAREAGAINST)" \ + "\n${CINFO}Diff against OR 2${CNORMAL}" "$(diff $COMPAREFILE2 $COMPAREAGAINST)" && + msgfail ) +} + testshowvirtual() { local VIRTUAL="E: Can't select versions from package '$1' as it purely virtual" local PACKAGE="$1" diff --git a/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order index bb10c4f73..17ce50295 100755 --- a/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order +++ b/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order @@ -24,7 +24,7 @@ Size: 73986 MD5sum: 8489687ce10e656babd467c9ee389349 Description-de: Verschiedene Dateien für das Basis-System von Debian" -predependstest() { +predependsgawk() { # rm rootdir/var/cache/apt/*.bin cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status echo "$pkgbasefile @@ -35,25 +35,64 @@ Conf gawk (1:3.1.7.dfsg-5 localhost [i386]) Remv mawk [1.3.3-15]" aptget install gawk mawk- -sqq -o PreDepends=$(echo "$1" | sed 's/ //g') } -predependstest "gawk | mawk" -predependstest "mawk | gawk" +predependsgawk "gawk | mawk" +predependsgawk "mawk | gawk" -predependstest "aawk | mawk | gawk" -predependstest "aawk | gawk | mawk" +predependsgawk "aawk | mawk | gawk" +predependsgawk "aawk | gawk | mawk" -predependstest "gawk | awk" -predependstest "aawk | gawk | awk" +predependsgawk "gawk | awk" +predependsgawk "aawk | gawk | awk" -predependstest "mawk | awk" +predependsgawk "mawk | awk" -predependstest "awk | gawk" -predependstest "awk | gawk | aawk" +predependsgawk "awk | gawk" +predependsgawk "awk | gawk | aawk" -predependstest "awk | mawk" +predependsgawk "awk | mawk" -predependstest "aawk | awk" -predependstest "awk | aawk" +predependsgawk "aawk | awk" +predependsgawk "awk | aawk" -predependstest "awk" +predependsgawk "awk" -# aptget install gawk mawk- -sqq -o Debug::pkgOrderList=1 #-o Debug::pkgPackageManager=1 +predependsgawk2() { +# rm rootdir/var/cache/apt/*.bin + cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status + echo "$pkgbasefile +Pre-Depends: $1 +" >> rootdir/var/lib/dpkg/status + testequalor2 "Inst coolstuff (1-1 localhost [all]) +Conf coolstuff (1-1 localhost [all]) +Inst gawk2 (1:3.1.7.dfsg-5 localhost [i386]) +Conf gawk2 (1:3.1.7.dfsg-5 localhost [i386]) +Remv mawk [1.3.3-15]" "Inst coolstuff (1-1 localhost [all]) +Inst gawk2 (1:3.1.7.dfsg-5 localhost [i386]) +Conf coolstuff (1-1 localhost [all]) +Conf gawk2 (1:3.1.7.dfsg-5 localhost [i386]) +Remv mawk [1.3.3-15]" aptget install gawk2 mawk- -sqq -o PreDepends=$(echo "$1" | sed 's/ //g') +} + +predependsgawk2 "gawk2 | mawk" +predependsgawk2 "mawk | gawk2" + +predependsgawk2 "aawk | mawk | gawk2" +predependsgawk2 "aawk | gawk2 | mawk" + +predependsgawk2 "gawk2 | awk" +predependsgawk2 "aawk | gawk2 | awk" + +predependsgawk2 "mawk | awk" + +predependsgawk2 "awk | gawk2" +predependsgawk2 "awk | gawk2 | aawk" + +predependsgawk2 "awk | mawk" + +predependsgawk2 "aawk | awk" +predependsgawk2 "awk | aawk" + +predependsgawk2 "awk" + + +# aptget install gawk2 mawk- -s #-o Debug::pkgOrderList=1 #-o Debug::pkgPackageManager=1 -- cgit v1.2.3 From 8e86786b2f0002a7512f97d0f9b5ef3e4794e26e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 29 Jul 2010 15:09:18 +0200 Subject: remove the temporary compare files we create --- test/integration/framework | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index 7b323fdb5..b4e9302e8 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -147,6 +147,7 @@ testequal() { shift msgtest "Test for equality of" "$*" $* 2>&1 | diff $COMPAREFILE - && msgpass || msgfail + rm $COMPAREFILE } testequalor2() { @@ -163,6 +164,7 @@ testequalor2() { ( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(diff $COMPAREFILE1 $COMPAREAGAINST)" \ "\n${CINFO}Diff against OR 2${CNORMAL}" "$(diff $COMPAREFILE2 $COMPAREAGAINST)" && msgfail ) + rm $COMPAREFILE1 $COMPAREFILE2 $COMPAREAGAINST } testshowvirtual() { @@ -183,6 +185,7 @@ E: No packages found" eval `apt-config shell ARCH APT::Architecture` echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE aptcache show $PACKAGE 2>&1 | diff $COMPAREFILE - && msgpass || msgfail + rm $COMPAREFILE } testnopackage() { -- cgit v1.2.3