From a7e052eae64486a31595bc9b3f4a1c02c13256e3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 30 Nov 2011 16:37:09 +0100 Subject: ensure that we exit instead of proceed in execution after the trap (the execution leads to hard failures anyway) --- test/integration/framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index b55f793a4..2ea1844f0 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -102,7 +102,7 @@ aptitude() { addtrap() { CURRENTTRAP="$CURRENTTRAP $1" - trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM + trap "$CURRENTTRAP exit;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM } setupenvironment() { -- cgit v1.2.3 From 2c405a44a0e4ff4c6f40e2521a55811179c87ec3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 11 Dec 2011 02:55:20 +0100 Subject: add a testcase for FindPackages() to better validate that cdrom should work. Unfortunately it's hard to do an automated integration test with cd, so we test this method in isolation which tries to find Indexes and dropping of duplications with DropRepeats() --- test/libapt/cdromfindpackages_test.cc | 86 +++++++++++++++++++++++++++++++++++ test/libapt/makefile | 6 +++ test/libapt/run-tests | 29 ++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 test/libapt/cdromfindpackages_test.cc (limited to 'test') diff --git a/test/libapt/cdromfindpackages_test.cc b/test/libapt/cdromfindpackages_test.cc new file mode 100644 index 000000000..e9f5a51b0 --- /dev/null +++ b/test/libapt/cdromfindpackages_test.cc @@ -0,0 +1,86 @@ +#include +#include + +#include +#include +#include + +#include "assert.h" + +class Cdrom : public pkgCdrom { + public: + bool FindPackages(std::string const &CD, + std::vector &List, + std::vector &SList, + std::vector &SigList, + std::vector &TransList, + std::string &InfoDir) { + bool const result = pkgCdrom::FindPackages(CD, List, SList, SigList, TransList, InfoDir, NULL, 0); + std::sort(List.begin(), List.end()); + std::sort(SList.begin(), SList.end()); + std::sort(SigList.begin(), SigList.end()); + std::sort(TransList.begin(), TransList.end()); + return result; + } + + bool DropRepeats(std::vector &List, char const *Name) { + return pkgCdrom::DropRepeats(List, Name); + } +}; + +int main(int argc, char const *argv[]) { + if (argc != 2) { + std::cout << "One parameter expected - given " << argc << std::endl; + return 100; + } + + Cdrom cd; + std::vector Packages, Sources, Signatur, Translation; + std::string InfoDir; + std::string path = argv[1]; + equals(true, cd.FindPackages(path, Packages, Sources, Signatur, Translation, InfoDir)); + equals(4, Packages.size()); + equals(path + "/dists/sid/main/binary-i386/", Packages[0]); + equals(path + "/dists/stable/contrib/binary-amd64/", Packages[1]); + equals(path + "/dists/stable/main/binary-i386/", Packages[2]); + equals(path + "/dists/unstable/main/binary-i386/", Packages[3]); + equals(3, Sources.size()); + equals(path + "/dists/sid/main/source/", Sources[0]); + equals(path + "/dists/stable/main/source/", Sources[1]); + equals(path + "/dists/unstable/main/source/", Sources[2]); + equals(3, Signatur.size()); + equals(path + "/dists/sid/", Signatur[0]); + equals(path + "/dists/stable/", Signatur[1]); + equals(path + "/dists/unstable/", Signatur[2]); + equals(4, Translation.size()); + equals(path + "/dists/sid/main/i18n/Translation-de", Translation[0]); + equals(path + "/dists/sid/main/i18n/Translation-en", Translation[1]); + equals(path + "/dists/unstable/main/i18n/Translation-de", Translation[2]); + equals(path + "/dists/unstable/main/i18n/Translation-en", Translation[3]); + equals(path + "/.disk/", InfoDir); + + cd.DropRepeats(Packages, "Packages"); + cd.DropRepeats(Sources, "Sources"); + _error->PushToStack(); + cd.DropRepeats(Signatur, "InRelease"); + cd.DropRepeats(Signatur, "Release.gpg"); + _error->RevertToStack(); + _error->DumpErrors(); + cd.DropRepeats(Translation, ""); + + equals(3, Packages.size()); + equals(path + "/dists/stable/contrib/binary-amd64/", Packages[0]); + equals(path + "/dists/stable/main/binary-i386/", Packages[1]); + equals(path + "/dists/unstable/main/binary-i386/", Packages[2]); + equals(2, Sources.size()); + equals(path + "/dists/stable/main/source/", Sources[0]); + equals(path + "/dists/unstable/main/source/", Sources[1]); + equals(2, Signatur.size()); + equals(path + "/dists/stable/", Signatur[0]); + equals(path + "/dists/unstable/", Signatur[1]); + equals(2, Translation.size()); + equals(path + "/dists/unstable/main/i18n/Translation-de", Translation[0]); + equals(path + "/dists/unstable/main/i18n/Translation-en", Translation[1]); + + return 0; +} diff --git a/test/libapt/makefile b/test/libapt/makefile index d3dddaeed..1952051e2 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -74,3 +74,9 @@ PROGRAM = Configuration${BASENAME} SLIBS = -lapt-pkg SOURCE = configuration_test.cc include $(PROGRAM_H) + +# test cdroms core FindPackages +PROGRAM = CdromFindPackages${BASENAME} +SLIBS = -lapt-pkg +SOURCE = cdromfindpackages_test.cc +include $(PROGRAM_H) diff --git a/test/libapt/run-tests b/test/libapt/run-tests index ada2dc38b..bd47d4e0d 100755 --- a/test/libapt/run-tests +++ b/test/libapt/run-tests @@ -75,6 +75,35 @@ do continue elif [ $name = "CompareVersion${EXT}" ]; then tmppath="${DIR}/versions.lst" + elif [ $name = "CdromFindPackages${EXT}" ]; then + tmppath=$(mktemp -d) + mkdir -p "${tmppath}/.disk" "${tmppath}/pool" \ + "${tmppath}/dists/stable/main/binary-i386" \ + "${tmppath}/dists/stable/main/source" \ + "${tmppath}/dists/stable/contrib/binary-amd64" \ + "${tmppath}/dists/stable/contrib/binary-all" \ + "${tmppath}/dists/unstable/main/binary-i386" \ + "${tmppath}/dists/unstable/main/i18n" \ + "${tmppath}/dists/unstable/main/source" \ + "${tmppath}/dists/broken/non-free/source" + touch "${tmppath}/dists/broken/.aptignr" \ + "${tmppath}/dists/stable/main/binary-i386/Packages" \ + "${tmppath}/dists/stable/main/binary-i386/Packages.gz" \ + "${tmppath}/dists/stable/main/source/Sources.gz" \ + "${tmppath}/dists/stable/contrib/binary-amd64/Packages" \ + "${tmppath}/dists/stable/contrib/binary-amd64/Packages.gz" \ + "${tmppath}/dists/stable/contrib/binary-all/Packages" \ + "${tmppath}/dists/unstable/main/binary-i386/Packages.gz" \ + "${tmppath}/dists/unstable/main/binary-i386/Packages.gz" \ + "${tmppath}/dists/unstable/main/i18n/Translation-en" \ + "${tmppath}/dists/unstable/main/i18n/Translation-de.gz" \ + "${tmppath}/dists/unstable/main/source/Sources.gz" \ + "${tmppath}/dists/broken/non-free/source/Sources.gz" \ + "${tmppath}/dists/stable/Release.gpg" \ + "${tmppath}/dists/stable/Release" \ + "${tmppath}/dists/unstable/InRelease" \ + "${tmppath}/dists/broken/Release.gpg" + ln -s "${tmppath}/dists/unstable" "${tmppath}/dists/sid" fi echo -n "Testing with ${NAME} " -- cgit v1.2.3 From eed564b853a0e5778080c5c3012517a814041d5a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 11 Dec 2011 13:08:21 +0100 Subject: use different compression types in the test now that we support them --- test/libapt/run-tests | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/libapt/run-tests b/test/libapt/run-tests index bd47d4e0d..5fff4ecca 100755 --- a/test/libapt/run-tests +++ b/test/libapt/run-tests @@ -88,16 +88,16 @@ do "${tmppath}/dists/broken/non-free/source" touch "${tmppath}/dists/broken/.aptignr" \ "${tmppath}/dists/stable/main/binary-i386/Packages" \ - "${tmppath}/dists/stable/main/binary-i386/Packages.gz" \ - "${tmppath}/dists/stable/main/source/Sources.gz" \ + "${tmppath}/dists/stable/main/binary-i386/Packages.bz2" \ + "${tmppath}/dists/stable/main/source/Sources.xz" \ "${tmppath}/dists/stable/contrib/binary-amd64/Packages" \ "${tmppath}/dists/stable/contrib/binary-amd64/Packages.gz" \ "${tmppath}/dists/stable/contrib/binary-all/Packages" \ - "${tmppath}/dists/unstable/main/binary-i386/Packages.gz" \ - "${tmppath}/dists/unstable/main/binary-i386/Packages.gz" \ + "${tmppath}/dists/unstable/main/binary-i386/Packages.xz" \ + "${tmppath}/dists/unstable/main/binary-i386/Packages.lzma" \ "${tmppath}/dists/unstable/main/i18n/Translation-en" \ - "${tmppath}/dists/unstable/main/i18n/Translation-de.gz" \ - "${tmppath}/dists/unstable/main/source/Sources.gz" \ + "${tmppath}/dists/unstable/main/i18n/Translation-de.bz2" \ + "${tmppath}/dists/unstable/main/source/Sources.xz" \ "${tmppath}/dists/broken/non-free/source/Sources.gz" \ "${tmppath}/dists/stable/Release.gpg" \ "${tmppath}/dists/stable/Release" \ -- cgit v1.2.3