]> git.saurik.com Git - apt.git/blob - test/libapt/indexcopytosourcelist_test.cc
Fix option name DPkg::Progress-Fancy in apt.8 manpage (LP: #1310506)
[apt.git] / test / libapt / indexcopytosourcelist_test.cc
1 #include <config.h>
2
3 #include <apt-pkg/configuration.h>
4 #include <apt-pkg/aptconfiguration.h>
5 #include <apt-pkg/indexcopy.h>
6
7 #include <string>
8 #include <stdio.h>
9
10 #include "assert.h"
11
12 class NoCopy : public IndexCopy {
13 public:
14 std::string ConvertToSourceList(std::string CD,std::string Path) {
15 IndexCopy::ConvertToSourceList(CD, Path);
16 return Path;
17 }
18 bool GetFile(std::string &/*Filename*/, unsigned long long &/*Size*/) { return false; }
19 bool RewriteEntry(FILE * /*Target*/, std::string /*File*/) { return false; }
20 const char *GetFileName() { return NULL; }
21 const char *Type() { return NULL; }
22
23 };
24
25 int main() {
26 NoCopy ic;
27 std::string const CD("/media/cdrom/");
28
29 char const * Releases[] = { "unstable", "wheezy-updates", NULL };
30 char const * Components[] = { "main", "non-free", NULL };
31
32 for (char const ** Release = Releases; *Release != NULL; ++Release) {
33 for (char const ** Component = Components; *Component != NULL; ++Component) {
34 std::string const Path = std::string("dists/") + *Release + "/" + *Component + "/";
35 std::string const Binary = Path + "binary-";
36 std::string const A = Binary + "armel/";
37 std::string const B = Binary + "mips/";
38 std::string const C = Binary + "kfreebsd-mips/";
39 std::string const S = Path + "source/";
40 std::string const List = std::string(*Release) + " " + *Component;
41
42 _config->Clear("APT");
43 APT::Configuration::getArchitectures(false);
44 equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
45 equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
46 equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
47 equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
48
49 _config->Clear("APT");
50 _config->Set("APT::Architecture", "mips");
51 _config->Set("APT::Architectures::", "mips");
52 APT::Configuration::getArchitectures(false);
53 equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
54 equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
55 equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
56 equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
57
58 _config->Clear("APT");
59 _config->Set("APT::Architecture", "kfreebsd-mips");
60 _config->Set("APT::Architectures::", "kfreebsd-mips");
61 APT::Configuration::getArchitectures(false);
62 equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
63 equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
64 equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), List);
65 equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
66
67 _config->Clear("APT");
68 _config->Set("APT::Architecture", "armel");
69 _config->Set("APT::Architectures::", "armel");
70 APT::Configuration::getArchitectures(false);
71 equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
72 equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
73 equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
74 equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
75
76 _config->Clear("APT");
77 _config->Set("APT::Architecture", "armel");
78 _config->Set("APT::Architectures::", "armel");
79 _config->Set("APT::Architectures::", "mips");
80 APT::Configuration::getArchitectures(false);
81 equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
82 equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
83 equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
84 equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
85 }
86 }
87
88 return 0;
89 }