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