]>
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
: public IndexCopy
{
14 std::string
ConvertToSourceList(std::string CD
,std::string Path
) {
15 IndexCopy::ConvertToSourceList(CD
, Path
);
18 bool GetFile(std::string
&/*Filename*/, unsigned long long &/*Size*/) { return false; }
19 bool RewriteEntry(FileFd
& /*Target*/, std::string
const &/*File*/) { return false; }
20 const char *GetFileName() { return NULL
; }
21 const char *Type() { 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
;
47 _config
->Clear("APT");
48 APT::Configuration::getArchitectures(false);
49 EXPECT_EQ(A
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ A
));
50 EXPECT_EQ(B
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ B
));
51 EXPECT_EQ(C
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ C
));
52 EXPECT_EQ(List
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ S
));
54 _config
->Clear("APT");
55 _config
->Set("APT::Architecture", "mips");
56 _config
->Set("APT::Architectures::", "mips");
57 APT::Configuration::getArchitectures(false);
58 EXPECT_EQ(A
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ A
));
59 EXPECT_EQ(List
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ B
));
60 EXPECT_EQ(C
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ C
));
61 EXPECT_EQ(List
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ S
));
63 _config
->Clear("APT");
64 _config
->Set("APT::Architecture", "kfreebsd-mips");
65 _config
->Set("APT::Architectures::", "kfreebsd-mips");
66 APT::Configuration::getArchitectures(false);
67 EXPECT_EQ(A
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ A
));
68 EXPECT_EQ(B
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ B
));
69 EXPECT_EQ(List
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ C
));
70 EXPECT_EQ(List
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ S
));
72 _config
->Clear("APT");
73 _config
->Set("APT::Architecture", "armel");
74 _config
->Set("APT::Architectures::", "armel");
75 APT::Configuration::getArchitectures(false);
76 EXPECT_EQ(List
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ A
));
77 EXPECT_EQ(B
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ B
));
78 EXPECT_EQ(C
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ C
));
79 EXPECT_EQ(List
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ S
));
81 _config
->Clear("APT");
82 _config
->Set("APT::Architecture", "armel");
83 _config
->Set("APT::Architectures::", "armel");
84 _config
->Set("APT::Architectures::", "mips");
85 APT::Configuration::getArchitectures(false);
86 EXPECT_EQ(List
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ A
));
87 EXPECT_EQ(List
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ B
));
88 EXPECT_EQ(C
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ C
));
89 EXPECT_EQ(List
, ic
.ConvertToSourceList("/media/cdrom/", CD
+ S
));