You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

231 lines
8.7 KiB

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