]>
git.saurik.com Git - apt.git/blob - test/libapt/parsedepends_test.cc
3 #include <apt-pkg/deblistparser.h>
4 #include <apt-pkg/configuration.h>
5 #include <apt-pkg/pkgcache.h>
16 unsigned int Null
= 0;
17 bool StripMultiArch
= true;
18 bool ParseArchFlags
= false;
19 bool ParseRestrictionsList
= false;
20 _config
->Set("APT::Architecture","amd64");
21 _config
->Set("APT::Build-Profiles","stage1");
24 "debhelper:any (>= 5.0), "
26 "gettext:native (<= 0.12), "
27 "libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), "
30 "not-for-me [ !amd64 ], "
31 "only-for-me [ amd64 ], "
32 "any-for-me [ any ], "
33 "not-for-darwin [ !darwin-any ], "
34 "cpu-for-me [ any-amd64 ], "
35 "os-for-me [ linux-any ], "
36 "cpu-not-for-me [ any-armel ], "
37 "os-not-for-me [ kfreebsd-any ], "
38 "not-in-stage1 <!profile.stage1>, "
39 "not-in-stage1-or-nodoc <!profile.nodoc !profile.stage1>, "
40 "only-in-stage1 <unknown.unknown profile.stage1>, "
41 "overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), "
44 unsigned short runner
= 0;
46 // std::clog << (StripMultiArch ? "NO-Multi" : "Multi") << " " << (ParseArchFlags ? "Flags" : "NO-Flags") << std::endl;
48 // Stripping MultiArch is currently the default setting to not confuse
49 // non-MultiArch capable users of the library with "strange" extensions.
50 const char* Start
= Depends
;
51 const char* End
= Depends
+ strlen(Depends
);
53 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
54 if (StripMultiArch
== true)
55 equals("debhelper", Package
);
57 equals("debhelper:any", Package
);
58 equals("5.0", Version
);
59 equals(Null
| pkgCache::Dep::GreaterEq
, Op
);
61 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
62 if (StripMultiArch
== true)
63 equals("libdb-dev", Package
);
65 equals("libdb-dev:any", Package
);
67 equals(Null
| pkgCache::Dep::NoOp
, Op
);
69 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
70 if (StripMultiArch
== true)
71 equals("gettext", Package
);
73 equals("gettext:native", Package
);
74 equals("0.12", Version
);
75 equals(Null
| pkgCache::Dep::LessEq
, Op
);
77 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
78 if (StripMultiArch
== true)
79 equals("libcurl4-gnutls-dev", Package
);
81 equals("libcurl4-gnutls-dev:native", Package
);
83 equals(Null
| pkgCache::Dep::Or
, Op
);
85 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
86 equals("libcurl3-gnutls-dev", Package
);
87 equals("7.15.5", Version
);
88 equals(Null
| pkgCache::Dep::Greater
, Op
);
90 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
91 equals("debiandoc-sgml", Package
);
93 equals(Null
| pkgCache::Dep::NoOp
, Op
);
95 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
96 equals("apt", Package
);
97 equals("0.7.25", Version
);
98 equals(Null
| pkgCache::Dep::GreaterEq
, Op
);
100 if (ParseArchFlags
== true) {
101 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
102 equals("", Package
); // not-for-me
104 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
105 Start
= strstr(Start
, ",");
109 if (ParseArchFlags
== true) {
110 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
111 equals("only-for-me", Package
);
113 equals(Null
| pkgCache::Dep::NoOp
, Op
);
115 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
116 Start
= strstr(Start
, ",");
120 if (ParseArchFlags
== true) {
121 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
122 equals("any-for-me", Package
);
124 equals(Null
| pkgCache::Dep::NoOp
, Op
);
126 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
127 Start
= strstr(Start
, ",");
131 if (ParseArchFlags
== true) {
132 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
133 equals("not-for-darwin", Package
);
135 equals(Null
| pkgCache::Dep::NoOp
, Op
);
137 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
138 Start
= strstr(Start
, ",");
142 if (ParseArchFlags
== true) {
143 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
144 equals("cpu-for-me", Package
);
146 equals(Null
| pkgCache::Dep::NoOp
, Op
);
148 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
149 Start
= strstr(Start
, ",");
153 if (ParseArchFlags
== true) {
154 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
155 equals("os-for-me", Package
);
157 equals(Null
| pkgCache::Dep::NoOp
, Op
);
159 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
160 Start
= strstr(Start
, ",");
164 if (ParseArchFlags
== true) {
165 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
166 equals("", Package
); // cpu-not-for-me
168 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
169 Start
= strstr(Start
, ",");
173 if (ParseArchFlags
== true) {
174 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
175 equals("", Package
); // os-not-for-me
177 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
178 Start
= strstr(Start
, ",");
182 if (ParseRestrictionsList
== true) {
183 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
184 equals("", Package
); // not-in-stage1
186 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
187 Start
= strstr(Start
, ",");
191 if (ParseRestrictionsList
== true) {
192 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
193 equals("", Package
); // not-in-stage1-or-in-nodoc
195 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
196 Start
= strstr(Start
, ",");
200 if (ParseRestrictionsList
== true) {
201 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
202 equals("only-in-stage1", Package
);
204 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
205 Start
= strstr(Start
, ",");
209 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
210 if (StripMultiArch
== true)
211 equals("overlord-dev", Package
);
213 equals("overlord-dev:any", Package
);
214 equals("7.15.3~", Version
);
215 equals(Null
| pkgCache::Dep::Equals
| pkgCache::Dep::Or
, Op
);
217 debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
218 if (StripMultiArch
== true)
219 equals("overlord-dev", Package
);
221 equals("overlord-dev:native", Package
);
222 equals("7.15.5", Version
);
223 equals(Null
| pkgCache::Dep::Greater
, Op
);
225 if (StripMultiArch
== false)
226 if (ParseArchFlags
== false)
227 ParseRestrictionsList
= !ParseRestrictionsList
;
228 ParseArchFlags
= !ParseArchFlags
;
229 StripMultiArch
= !StripMultiArch
;
233 goto test
; // this is the prove: tests are really evil ;)