]>
Commit | Line | Data |
---|---|---|
453b82a3 DK |
1 | #include <config.h> |
2 | ||
41c81fd8 DK |
3 | #include <apt-pkg/deblistparser.h> |
4 | #include <apt-pkg/configuration.h> | |
453b82a3 DK |
5 | #include <apt-pkg/pkgcache.h> |
6 | ||
7 | #include <string.h> | |
8 | #include <string> | |
41c81fd8 DK |
9 | |
10 | #include "assert.h" | |
11 | ||
65512241 | 12 | int main() { |
8f3ba4e8 DK |
13 | std::string Package; |
14 | std::string Version; | |
41c81fd8 DK |
15 | unsigned int Op = 5; |
16 | unsigned int Null = 0; | |
17 | bool StripMultiArch = true; | |
18 | bool ParseArchFlags = false; | |
565ded7b | 19 | bool ParseRestrictionsList = false; |
01f520ce | 20 | _config->Set("APT::Architecture","amd64"); |
565ded7b | 21 | _config->Set("APT::Build-Profiles","stage1"); |
41c81fd8 DK |
22 | |
23 | const char* Depends = | |
24 | "debhelper:any (>= 5.0), " | |
25 | "libdb-dev:any, " | |
26 | "gettext:native (<= 0.12), " | |
27 | "libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), " | |
28 | "debiandoc-sgml, " | |
29 | "apt (>= 0.7.25), " | |
01f520ce DK |
30 | "not-for-me [ !amd64 ], " |
31 | "only-for-me [ amd64 ], " | |
af5cf929 DK |
32 | "any-for-me [ any ], " |
33 | "not-for-darwin [ !darwin-any ], " | |
01f520ce | 34 | "cpu-for-me [ any-amd64 ], " |
af5cf929 | 35 | "os-for-me [ linux-any ], " |
01f520ce | 36 | "cpu-not-for-me [ any-armel ], " |
af5cf929 | 37 | "os-not-for-me [ kfreebsd-any ], " |
565ded7b JS |
38 | "not-in-stage1 <!profile.stage1>, " |
39 | "not-in-stage1-or-nodoc <!profile.nodoc !profile.stage1>, " | |
40 | "only-in-stage1 <unknown.unknown profile.stage1>, " | |
41c81fd8 DK |
41 | "overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), " |
42 | ; | |
43 | ||
44 | unsigned short runner = 0; | |
45 | test: | |
46 | // std::clog << (StripMultiArch ? "NO-Multi" : "Multi") << " " << (ParseArchFlags ? "Flags" : "NO-Flags") << std::endl; | |
47 | ||
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); | |
52 | ||
565ded7b | 53 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
41c81fd8 DK |
54 | if (StripMultiArch == true) |
55 | equals("debhelper", Package); | |
56 | else | |
57 | equals("debhelper:any", Package); | |
58 | equals("5.0", Version); | |
59 | equals(Null | pkgCache::Dep::GreaterEq, Op); | |
60 | ||
565ded7b | 61 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
41c81fd8 DK |
62 | if (StripMultiArch == true) |
63 | equals("libdb-dev", Package); | |
64 | else | |
65 | equals("libdb-dev:any", Package); | |
66 | equals("", Version); | |
67 | equals(Null | pkgCache::Dep::NoOp, Op); | |
68 | ||
565ded7b | 69 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
41c81fd8 DK |
70 | if (StripMultiArch == true) |
71 | equals("gettext", Package); | |
72 | else | |
73 | equals("gettext:native", Package); | |
74 | equals("0.12", Version); | |
75 | equals(Null | pkgCache::Dep::LessEq, Op); | |
76 | ||
565ded7b | 77 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
41c81fd8 DK |
78 | if (StripMultiArch == true) |
79 | equals("libcurl4-gnutls-dev", Package); | |
80 | else | |
81 | equals("libcurl4-gnutls-dev:native", Package); | |
82 | equals("", Version); | |
83 | equals(Null | pkgCache::Dep::Or, Op); | |
84 | ||
565ded7b | 85 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
41c81fd8 DK |
86 | equals("libcurl3-gnutls-dev", Package); |
87 | equals("7.15.5", Version); | |
88 | equals(Null | pkgCache::Dep::Greater, Op); | |
89 | ||
565ded7b | 90 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
41c81fd8 DK |
91 | equals("debiandoc-sgml", Package); |
92 | equals("", Version); | |
93 | equals(Null | pkgCache::Dep::NoOp, Op); | |
94 | ||
565ded7b | 95 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
41c81fd8 DK |
96 | equals("apt", Package); |
97 | equals("0.7.25", Version); | |
98 | equals(Null | pkgCache::Dep::GreaterEq, Op); | |
99 | ||
100 | if (ParseArchFlags == true) { | |
565ded7b | 101 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
41c81fd8 DK |
102 | equals("", Package); // not-for-me |
103 | } else { | |
565ded7b | 104 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); |
41c81fd8 DK |
105 | Start = strstr(Start, ","); |
106 | Start++; | |
107 | } | |
108 | ||
109 | if (ParseArchFlags == true) { | |
565ded7b | 110 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
41c81fd8 DK |
111 | equals("only-for-me", Package); |
112 | equals("", Version); | |
113 | equals(Null | pkgCache::Dep::NoOp, Op); | |
114 | } else { | |
565ded7b | 115 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); |
41c81fd8 DK |
116 | Start = strstr(Start, ","); |
117 | Start++; | |
118 | } | |
119 | ||
af5cf929 | 120 | if (ParseArchFlags == true) { |
565ded7b | 121 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
af5cf929 DK |
122 | equals("any-for-me", Package); |
123 | equals("", Version); | |
124 | equals(Null | pkgCache::Dep::NoOp, Op); | |
125 | } else { | |
565ded7b | 126 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); |
af5cf929 DK |
127 | Start = strstr(Start, ","); |
128 | Start++; | |
129 | } | |
130 | ||
131 | if (ParseArchFlags == true) { | |
565ded7b | 132 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
af5cf929 DK |
133 | equals("not-for-darwin", Package); |
134 | equals("", Version); | |
135 | equals(Null | pkgCache::Dep::NoOp, Op); | |
136 | } else { | |
565ded7b | 137 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); |
af5cf929 DK |
138 | Start = strstr(Start, ","); |
139 | Start++; | |
140 | } | |
141 | ||
142 | if (ParseArchFlags == true) { | |
565ded7b | 143 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
af5cf929 DK |
144 | equals("cpu-for-me", Package); |
145 | equals("", Version); | |
146 | equals(Null | pkgCache::Dep::NoOp, Op); | |
147 | } else { | |
565ded7b | 148 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); |
af5cf929 DK |
149 | Start = strstr(Start, ","); |
150 | Start++; | |
151 | } | |
152 | ||
153 | if (ParseArchFlags == true) { | |
565ded7b | 154 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
af5cf929 DK |
155 | equals("os-for-me", Package); |
156 | equals("", Version); | |
157 | equals(Null | pkgCache::Dep::NoOp, Op); | |
158 | } else { | |
565ded7b | 159 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); |
af5cf929 DK |
160 | Start = strstr(Start, ","); |
161 | Start++; | |
162 | } | |
163 | ||
164 | if (ParseArchFlags == true) { | |
565ded7b | 165 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
af5cf929 DK |
166 | equals("", Package); // cpu-not-for-me |
167 | } else { | |
565ded7b | 168 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); |
af5cf929 DK |
169 | Start = strstr(Start, ","); |
170 | Start++; | |
171 | } | |
172 | ||
173 | if (ParseArchFlags == true) { | |
565ded7b | 174 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
af5cf929 DK |
175 | equals("", Package); // os-not-for-me |
176 | } else { | |
565ded7b | 177 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); |
af5cf929 DK |
178 | Start = strstr(Start, ","); |
179 | Start++; | |
180 | } | |
181 | ||
565ded7b JS |
182 | if (ParseRestrictionsList == true) { |
183 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); | |
184 | equals("", Package); // not-in-stage1 | |
185 | } else { | |
186 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); | |
187 | Start = strstr(Start, ","); | |
188 | Start++; | |
189 | } | |
190 | ||
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 | |
194 | } else { | |
195 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); | |
196 | Start = strstr(Start, ","); | |
197 | Start++; | |
198 | } | |
199 | ||
200 | if (ParseRestrictionsList == true) { | |
201 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); | |
202 | equals("only-in-stage1", Package); | |
203 | } else { | |
204 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); | |
205 | Start = strstr(Start, ","); | |
206 | Start++; | |
207 | } | |
208 | ||
209 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); | |
41c81fd8 DK |
210 | if (StripMultiArch == true) |
211 | equals("overlord-dev", Package); | |
212 | else | |
213 | equals("overlord-dev:any", Package); | |
214 | equals("7.15.3~", Version); | |
215 | equals(Null | pkgCache::Dep::Equals | pkgCache::Dep::Or, Op); | |
216 | ||
565ded7b | 217 | debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); |
41c81fd8 DK |
218 | if (StripMultiArch == true) |
219 | equals("overlord-dev", Package); | |
220 | else | |
221 | equals("overlord-dev:native", Package); | |
222 | equals("7.15.5", Version); | |
223 | equals(Null | pkgCache::Dep::Greater, Op); | |
224 | ||
225 | if (StripMultiArch == false) | |
565ded7b JS |
226 | if (ParseArchFlags == false) |
227 | ParseRestrictionsList = !ParseRestrictionsList; | |
228 | ParseArchFlags = !ParseArchFlags; | |
41c81fd8 DK |
229 | StripMultiArch = !StripMultiArch; |
230 | ||
231 | runner++; | |
565ded7b | 232 | if (runner < 8) |
41c81fd8 DK |
233 | goto test; // this is the prove: tests are really evil ;) |
234 | ||
235 | return 0; | |
236 | } |