]>
Commit | Line | Data |
---|---|---|
453b82a3 DK |
1 | #include <config.h> |
2 | ||
d29a5330 DK |
3 | #include <apt-pkg/configuration.h> |
4 | #include <apt-pkg/aptconfiguration.h> | |
5 | #include <apt-pkg/indexcopy.h> | |
6 | ||
7 | #include <string> | |
453b82a3 | 8 | #include <stdio.h> |
d29a5330 | 9 | |
f00832cc | 10 | #include <gtest/gtest.h> |
d29a5330 | 11 | |
b7aa74a1 | 12 | class NoCopy : private IndexCopy { |
f00832cc | 13 | public: |
b7aa74a1 | 14 | std::string ConvertToSourceList(std::string const &CD,std::string &&Path) { |
f00832cc DK |
15 | IndexCopy::ConvertToSourceList(CD, Path); |
16 | return Path; | |
17 | } | |
3b302846 DK |
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; } | |
d29a5330 DK |
22 | |
23 | }; | |
24 | ||
f00832cc DK |
25 | TEST(IndexCopyTest, ConvertToSourceList) |
26 | { | |
d29a5330 DK |
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 | ||
f00832cc DK |
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); | |
d29a5330 DK |
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 | ||
b7aa74a1 DK |
47 | { |
48 | SCOPED_TRACE("no archs configured"); | |
d29a5330 | 49 | _config->Clear("APT"); |
b7aa74a1 DK |
50 | _config->Set("APT::Architecture", "all"); |
51 | _config->Set("APT::Architectures::", "all"); | |
d29a5330 | 52 | APT::Configuration::getArchitectures(false); |
f00832cc DK |
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)); | |
b7aa74a1 | 57 | } |
d29a5330 | 58 | |
b7aa74a1 DK |
59 | { |
60 | SCOPED_TRACE("mips configured"); | |
d29a5330 DK |
61 | _config->Clear("APT"); |
62 | _config->Set("APT::Architecture", "mips"); | |
63 | _config->Set("APT::Architectures::", "mips"); | |
64 | APT::Configuration::getArchitectures(false); | |
f00832cc DK |
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)); | |
b7aa74a1 | 69 | } |
d29a5330 | 70 | |
b7aa74a1 DK |
71 | { |
72 | SCOPED_TRACE("kfreebsd-mips configured"); | |
d29a5330 DK |
73 | _config->Clear("APT"); |
74 | _config->Set("APT::Architecture", "kfreebsd-mips"); | |
75 | _config->Set("APT::Architectures::", "kfreebsd-mips"); | |
76 | APT::Configuration::getArchitectures(false); | |
f00832cc DK |
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)); | |
b7aa74a1 | 81 | } |
d29a5330 | 82 | |
b7aa74a1 DK |
83 | { |
84 | SCOPED_TRACE("armel configured"); | |
d29a5330 DK |
85 | _config->Clear("APT"); |
86 | _config->Set("APT::Architecture", "armel"); | |
87 | _config->Set("APT::Architectures::", "armel"); | |
88 | APT::Configuration::getArchitectures(false); | |
f00832cc DK |
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)); | |
b7aa74a1 | 93 | } |
d29a5330 | 94 | |
b7aa74a1 DK |
95 | { |
96 | SCOPED_TRACE("armel+mips configured"); | |
d29a5330 DK |
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); | |
f00832cc DK |
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)); | |
b7aa74a1 | 106 | } |
d29a5330 DK |
107 | } |
108 | } | |
d29a5330 | 109 | } |