]>
Commit | Line | Data |
---|---|---|
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 <gtest/gtest.h> | |
11 | ||
12 | class NoCopy : private IndexCopy { | |
13 | public: | |
14 | std::string ConvertToSourceList(std::string const &CD,std::string &&Path) { | |
15 | IndexCopy::ConvertToSourceList(CD, Path); | |
16 | return Path; | |
17 | } | |
18 | bool GetFile(std::string &/*Filename*/, unsigned long long &/*Size*/) APT_OVERRIDE { return false; } | |
19 | bool RewriteEntry(FileFd & /*Target*/, std::string const &/*File*/) APT_OVERRIDE { return false; } | |
20 | const char *GetFileName() APT_OVERRIDE { return NULL; } | |
21 | const char *Type() APT_OVERRIDE { return NULL; } | |
22 | ||
23 | }; | |
24 | ||
25 | TEST(IndexCopyTest, ConvertToSourceList) | |
26 | { | |
27 | NoCopy ic; | |
28 | std::string const CD("/media/cdrom/"); | |
29 | ||
30 | char const * Releases[] = { "unstable", "wheezy-updates", NULL }; | |
31 | char const * Components[] = { "main", "non-free", NULL }; | |
32 | ||
33 | for (char const ** Release = Releases; *Release != NULL; ++Release) | |
34 | { | |
35 | SCOPED_TRACE(std::string("Release ") + *Release); | |
36 | for (char const ** Component = Components; *Component != NULL; ++Component) | |
37 | { | |
38 | SCOPED_TRACE(std::string("Component ") + *Component); | |
39 | std::string const Path = std::string("dists/") + *Release + "/" + *Component + "/"; | |
40 | std::string const Binary = Path + "binary-"; | |
41 | std::string const A = Binary + "armel/"; | |
42 | std::string const B = Binary + "mips/"; | |
43 | std::string const C = Binary + "kfreebsd-mips/"; | |
44 | std::string const S = Path + "source/"; | |
45 | std::string const List = std::string(*Release) + " " + *Component; | |
46 | ||
47 | { | |
48 | SCOPED_TRACE("no archs configured"); | |
49 | _config->Clear("APT"); | |
50 | _config->Set("APT::Architecture", "all"); | |
51 | _config->Set("APT::Architectures::", "all"); | |
52 | APT::Configuration::getArchitectures(false); | |
53 | EXPECT_EQ(A, ic.ConvertToSourceList("/media/cdrom/", CD + A)); | |
54 | EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B)); | |
55 | EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C)); | |
56 | EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S)); | |
57 | } | |
58 | ||
59 | { | |
60 | SCOPED_TRACE("mips configured"); | |
61 | _config->Clear("APT"); | |
62 | _config->Set("APT::Architecture", "mips"); | |
63 | _config->Set("APT::Architectures::", "mips"); | |
64 | APT::Configuration::getArchitectures(false); | |
65 | EXPECT_EQ(A, ic.ConvertToSourceList("/media/cdrom/", CD + A)); | |
66 | EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + B)); | |
67 | EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C)); | |
68 | EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S)); | |
69 | } | |
70 | ||
71 | { | |
72 | SCOPED_TRACE("kfreebsd-mips configured"); | |
73 | _config->Clear("APT"); | |
74 | _config->Set("APT::Architecture", "kfreebsd-mips"); | |
75 | _config->Set("APT::Architectures::", "kfreebsd-mips"); | |
76 | APT::Configuration::getArchitectures(false); | |
77 | EXPECT_EQ(A, ic.ConvertToSourceList("/media/cdrom/", CD + A)); | |
78 | EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B)); | |
79 | EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + C)); | |
80 | EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S)); | |
81 | } | |
82 | ||
83 | { | |
84 | SCOPED_TRACE("armel configured"); | |
85 | _config->Clear("APT"); | |
86 | _config->Set("APT::Architecture", "armel"); | |
87 | _config->Set("APT::Architectures::", "armel"); | |
88 | APT::Configuration::getArchitectures(false); | |
89 | EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + A)); | |
90 | EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B)); | |
91 | EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C)); | |
92 | EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S)); | |
93 | } | |
94 | ||
95 | { | |
96 | SCOPED_TRACE("armel+mips configured"); | |
97 | _config->Clear("APT"); | |
98 | _config->Set("APT::Architecture", "armel"); | |
99 | _config->Set("APT::Architectures::", "armel"); | |
100 | _config->Set("APT::Architectures::", "mips"); | |
101 | APT::Configuration::getArchitectures(false); | |
102 | EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + A)); | |
103 | EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + B)); | |
104 | EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C)); | |
105 | EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S)); | |
106 | } | |
107 | } | |
108 | } | |
109 | } |