diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2012-09-04 14:56:01 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2012-09-04 14:56:01 +0200 |
commit | 85909fca550d03b0e215d16cdd701190b43ff63c (patch) | |
tree | b6767be7b1898830499b0a5fb8153460223b5649 /test/libapt | |
parent | ac5b5e826ab405935dc257c0a0984ae39b02bc23 (diff) | |
parent | 89e95aee05c7f2fde7eb11261df9697a4896b49b (diff) |
merged sftp://bzr.debian.org/bzr/apt/apt/debian-sid
Diffstat (limited to 'test/libapt')
-rw-r--r-- | test/libapt/cdromreducesourcelist_test.cc | 86 | ||||
-rw-r--r-- | test/libapt/indexcopytosourcelist_test.cc | 86 | ||||
-rw-r--r-- | test/libapt/makefile | 12 |
3 files changed, 184 insertions, 0 deletions
diff --git a/test/libapt/cdromreducesourcelist_test.cc b/test/libapt/cdromreducesourcelist_test.cc new file mode 100644 index 000000000..729da23a6 --- /dev/null +++ b/test/libapt/cdromreducesourcelist_test.cc @@ -0,0 +1,86 @@ +#include <apt-pkg/cdrom.h> +#include <apt-pkg/error.h> + +#include <algorithm> +#include <string> +#include <vector> + +#include "assert.h" + +class Cdrom : public pkgCdrom { +public: + std::vector<std::string> ReduceSourcelist(std::string CD,std::vector<std::string> List) { + pkgCdrom::ReduceSourcelist(CD, List); + return List; + } +}; + +int main(int argc, char const *argv[]) { + Cdrom cd; + std::vector<std::string> List; + std::string CD("/media/cdrom/"); + + std::vector<std::string> R = cd.ReduceSourcelist(CD, List); + equals(R.empty(), true); + + List.push_back(" wheezy main"); + R = cd.ReduceSourcelist(CD, List); + equals(R.size(), 1); + equals(R[0], " wheezy main"); + + List.push_back(" wheezy main"); + R = cd.ReduceSourcelist(CD, List); + equals(R.size(), 1); + equals(R[0], " wheezy main"); + + List.push_back(" wheezy contrib"); + R = cd.ReduceSourcelist(CD, List); + equals(R.size(), 1); + equals(R[0], " wheezy contrib main"); + + List.push_back(" wheezy-update contrib"); + R = cd.ReduceSourcelist(CD, List); + equals(R.size(), 2); + equals(R[0], " wheezy contrib main"); + equals(R[1], " wheezy-update contrib"); + + List.push_back(" wheezy-update contrib"); + R = cd.ReduceSourcelist(CD, List); + equals(R.size(), 2); + equals(R[0], " wheezy contrib main"); + equals(R[1], " wheezy-update contrib"); + + List.push_back(" wheezy-update non-free"); + R = cd.ReduceSourcelist(CD, List); + equals(R.size(), 2); + equals(R[0], " wheezy contrib main"); + equals(R[1], " wheezy-update contrib non-free"); + + List.push_back(" wheezy-update main"); + R = cd.ReduceSourcelist(CD, List); + equals(R.size(), 2); + equals(R[0], " wheezy contrib main"); + equals(R[1], " wheezy-update contrib main non-free"); + + List.push_back(" wheezy non-free"); + R = cd.ReduceSourcelist(CD, List); + equals(R.size(), 2); + equals(R[0], " wheezy contrib main non-free"); + equals(R[1], " wheezy-update contrib main non-free"); + + List.push_back(" sid main"); + R = cd.ReduceSourcelist(CD, List); + equals(R.size(), 3); + equals(R[0], " sid main"); + equals(R[1], " wheezy contrib main non-free"); + equals(R[2], " wheezy-update contrib main non-free"); + + List.push_back(" sid main-reduce"); + R = cd.ReduceSourcelist(CD, List); + equals(R.size(), 3); + equals(R[0], " sid main main-reduce"); + equals(R[1], " wheezy contrib main non-free"); + equals(R[2], " wheezy-update contrib main non-free"); + + return 0; +} diff --git a/test/libapt/indexcopytosourcelist_test.cc b/test/libapt/indexcopytosourcelist_test.cc new file mode 100644 index 000000000..69d8fae86 --- /dev/null +++ b/test/libapt/indexcopytosourcelist_test.cc @@ -0,0 +1,86 @@ +#include <apt-pkg/configuration.h> +#include <apt-pkg/aptconfiguration.h> +#include <apt-pkg/indexcopy.h> + +#include <string> + +#include "assert.h" + +class NoCopy : public IndexCopy { +public: + std::string ConvertToSourceList(std::string CD,std::string Path) { + IndexCopy::ConvertToSourceList(CD, Path); + return Path; + } + bool GetFile(std::string &Filename,unsigned long long &Size) { return false; } + bool RewriteEntry(FILE *Target,std::string File) { return false; } + const char *GetFileName() { return NULL; } + const char *Type() { return NULL; } + +}; + +int main(int argc, char const *argv[]) { + NoCopy ic; + std::string const CD("/media/cdrom/"); + + char const * Releases[] = { "unstable", "wheezy-updates", NULL }; + char const * Components[] = { "main", "non-free", NULL }; + + for (char const ** Release = Releases; *Release != NULL; ++Release) { + for (char const ** Component = Components; *Component != NULL; ++Component) { + std::string const Path = std::string("dists/") + *Release + "/" + *Component + "/"; + std::string const Binary = Path + "binary-"; + std::string const A = Binary + "armel/"; + std::string const B = Binary + "mips/"; + std::string const C = Binary + "kfreebsd-mips/"; + std::string const S = Path + "source/"; + std::string const List = std::string(*Release) + " " + *Component; + + _config->Clear("APT"); + APT::Configuration::getArchitectures(false); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List); + + _config->Clear("APT"); + _config->Set("APT::Architecture", "mips"); + _config->Set("APT::Architectures::", "mips"); + APT::Configuration::getArchitectures(false); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List); + + _config->Clear("APT"); + _config->Set("APT::Architecture", "kfreebsd-mips"); + _config->Set("APT::Architectures::", "kfreebsd-mips"); + APT::Configuration::getArchitectures(false); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), List); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List); + + _config->Clear("APT"); + _config->Set("APT::Architecture", "armel"); + _config->Set("APT::Architectures::", "armel"); + APT::Configuration::getArchitectures(false); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List); + + _config->Clear("APT"); + _config->Set("APT::Architecture", "armel"); + _config->Set("APT::Architectures::", "armel"); + _config->Set("APT::Architectures::", "mips"); + APT::Configuration::getArchitectures(false); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C); + equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List); + } + } + + return 0; +} diff --git a/test/libapt/makefile b/test/libapt/makefile index b2e6db2dd..5e225f240 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -86,3 +86,15 @@ PROGRAM = CdromFindPackages${BASENAME} SLIBS = -lapt-pkg SOURCE = cdromfindpackages_test.cc include $(PROGRAM_H) + +# test cdroms index reduction for source.list +PROGRAM = CdromReduceSourceList${BASENAME} +SLIBS = -lapt-pkg +SOURCE = cdromreducesourcelist_test.cc +include $(PROGRAM_H) + +# text IndexCopy::ConvertToSourceList +PROGRAM = IndexCopyToSourceList${BASENAME} +SLIBS = -lapt-pkg +SOURCE = indexcopytosourcelist_test.cc +include $(PROGRAM_H) |