]>
git.saurik.com Git - apt.git/blob - test/libapt/indexcopytosourcelist_test.cc
3 #include <apt-pkg/configuration.h>
4 #include <apt-pkg/aptconfiguration.h>
5 #include <apt-pkg/indexcopy.h>
10 #include <gtest/gtest.h>
12 class NoCopy
: private IndexCopy
{
14 std::string
ConvertToSourceList(std::string
const &CD
,std::string
&&Path
) {
15 IndexCopy::ConvertToSourceList(CD
, Path
);
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
; }
25 TEST(IndexCopyTest
, ConvertToSourceList
)
28 std::string
const CD("/media/cdrom/");
30 char const * Releases
[] = { "unstable", "wheezy-updates", NULL
};
31 char const * Components
[] = { "main", "non-free", NULL
};
33 for (char const ** Release
= Releases
; *Release
!= NULL
; ++Release
)
35 SCOPED_TRACE(std::string("Release ") + *Release
);
36 for (char const ** Component
= Components
; *Component
!= NULL
; ++Component
)
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
;
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
));
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
));
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
));
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
));
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
));