summaryrefslogtreecommitdiff
path: root/test/libapt
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-09-03 14:04:50 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-09-03 14:04:50 +0200
commit0205540433440a9ff4ad4ea4cce44c700a4b401c (patch)
tree97809e2e38482d3d7f124b30552a0936adf4d405 /test/libapt
parent24baab5c477bf1e57a0b169a7bac1d2e9ab0c974 (diff)
parent2c6baa5a1f935eb3b8d4eb9fdef62e696416e27a (diff)
merged from lp:~donkult/apt/sid
Diffstat (limited to 'test/libapt')
-rw-r--r--test/libapt/assert.h21
-rw-r--r--test/libapt/commandlineasstring_test.cc39
-rw-r--r--test/libapt/compareversion_test.cc123
-rw-r--r--test/libapt/getarchitectures_test.cc61
-rw-r--r--test/libapt/getlanguages_test.cc149
-rw-r--r--test/libapt/globalerror_test.cc77
-rw-r--r--test/libapt/makefile48
-rw-r--r--test/libapt/parsedepends_test.cc196
-rwxr-xr-xtest/libapt/run-tests (renamed from test/libapt/run-tests.sh)17
9 files changed, 727 insertions, 4 deletions
diff --git a/test/libapt/assert.h b/test/libapt/assert.h
new file mode 100644
index 000000000..5da76ae0a
--- /dev/null
+++ b/test/libapt/assert.h
@@ -0,0 +1,21 @@
+#include <iostream>
+
+#define equals(x,y) assertEquals(x, y, __LINE__)
+
+template < typename X, typename Y >
+void OutputAssert(X expect, char const* compare, Y get, unsigned long const &line) {
+ std::cerr << "Test FAILED: »" << expect << "« " << compare << " »" << get << "« at line " << line << std::endl;
+}
+
+template < typename X, typename Y >
+void assertEquals(X expect, Y get, unsigned long const &line) {
+ if (expect == get)
+ return;
+ OutputAssert(expect, "==", get, line);
+}
+
+void assertEquals(unsigned int const &expect, int const &get, unsigned long const &line) {
+ if (get < 0)
+ OutputAssert(expect, "==", get, line);
+ assertEquals<unsigned int const&, unsigned int const&>(expect, get, line);
+}
diff --git a/test/libapt/commandlineasstring_test.cc b/test/libapt/commandlineasstring_test.cc
new file mode 100644
index 000000000..a38957d7e
--- /dev/null
+++ b/test/libapt/commandlineasstring_test.cc
@@ -0,0 +1,39 @@
+#include <apt-pkg/cmndline.h>
+#include <apt-pkg/configuration.h>
+
+#include <string>
+
+#include "assert.h"
+
+class CLT: public CommandLine {
+
+ public:
+ std::string static AsString(const char * const * const argv,
+ unsigned int const argc) {
+ std::string const static conf = "Commandline::AsString";
+ _config->Clear(conf);
+ SaveInConfig(argc, argv);
+ return _config->Find(conf);
+ }
+};
+
+#define CMD(y,z) equals(CLT::AsString(argv, y), z);
+
+int main() {
+ {
+ const char* const argv[] = {"apt-get", "install", "-sf"};
+ CMD(3, "apt-get install -sf");
+ }
+ {
+ const char* const argv[] = {"apt-cache", "-s", "apt", "-so", "Debug::test=Test"};
+ CMD(5, "apt-cache -s apt -so Debug::test=Test");
+ }
+ {
+ const char* const argv[] = {"apt-cache", "-s", "apt", "-so", "Debug::test=Das ist ein Test"};
+ CMD(5, "apt-cache -s apt -so Debug::test=\"Das ist ein Test\"");
+ }
+ {
+ const char* const argv[] = {"apt-cache", "-s", "apt", "--hallo", "test=1.0"};
+ CMD(5, "apt-cache -s apt --hallo test=1.0");
+ }
+}
diff --git a/test/libapt/compareversion_test.cc b/test/libapt/compareversion_test.cc
new file mode 100644
index 000000000..b6213e84c
--- /dev/null
+++ b/test/libapt/compareversion_test.cc
@@ -0,0 +1,123 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+/* ######################################################################
+
+ Version Test - Simple program to run through a file and comare versions.
+
+ Each version is compared and the result is checked against an expected
+ result in the file. The format of the file is
+ a b Res
+ Where Res is -1, 1, 0. dpkg -D=1 --compare-versions a "<" b can be
+ used to determine what Res should be. # at the start of the line
+ is a comment and blank lines are skipped
+
+ The runner will also call dpkg --compare-versions to check if APT and
+ dpkg have (still) the same idea.
+
+ ##################################################################### */
+ /*}}}*/
+#include <apt-pkg/macros.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/version.h>
+#include <apt-pkg/debversion.h>
+#include <apt-pkg/fileutl.h>
+#include <iostream>
+#include <fstream>
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+using namespace std;
+
+bool callDPkg(const char *val, const char *ref, const char &op) {
+ pid_t Process = ExecFork();
+ if (Process == 0)
+ {
+ const char * args[6];
+ args[0] = "/usr/bin/dpkg";
+ args[1] = "--compare-versions";
+ args[2] = val;
+ args[3] = (op == 1) ? ">>" : ( (op == 0) ? "=" : "<<");
+ args[4] = ref;
+ args[5] = 0;
+ execv(args[0], (char**) args);
+ exit(1);
+ }
+ int Ret;
+ waitpid(Process, &Ret, 0);
+ return WIFEXITED(Ret) == true && WEXITSTATUS(Ret) == 0;
+}
+
+void assertVersion(int const &CurLine, string const &A, string const &B, int const &Expected) {
+ int Res = debVS.CmpVersion(A.c_str(), B.c_str());
+ bool const dpkg = callDPkg(A.c_str(),B.c_str(), Expected);
+ Res = (Res < 0) ? -1 : ( (Res > 0) ? 1 : Res);
+
+ if (Res != Expected)
+ _error->Error("Comparison failed on line %u. '%s' '%s' '%s' %i != %i",CurLine,A.c_str(),((Expected == 1) ? "<<" : ( (Expected == 0) ? "=" : ">>")) ,B.c_str(),Res,Expected);
+ if (dpkg == false)
+ _error->Error("DPkg differ with line: %u. '%s' '%s' '%s' == false",CurLine,A.c_str(),((Expected == 1) ? "<<" : ( (Expected == 0) ? "=" : ">>")),B.c_str());
+}
+
+bool RunTest(const char *File)
+{
+ ifstream F(File,ios::in);
+ if (!F != 0)
+ return false;
+
+ char Buffer[300];
+ int CurLine = 0;
+
+ while (1)
+ {
+ F.getline(Buffer,sizeof(Buffer));
+ CurLine++;
+ if (F.eof() != 0)
+ return true;
+ if (!F != 0)
+ return _error->Error("Line %u in %s is too long",CurLine,File);
+
+ // Comment
+ if (Buffer[0] == '#' || Buffer[0] == 0)
+ continue;
+
+ // First version
+ char *I;
+ char *Start = Buffer;
+ for (I = Buffer; *I != 0 && *I != ' '; I++);
+ string A(Start, I - Start);
+
+ if (*I == 0)
+ return _error->Error("Invalid line %u",CurLine);
+
+ // Second version
+ I++;
+ Start = I;
+ for (I = Start; *I != 0 && *I != ' '; I++);
+ string B(Start,I - Start);
+
+ if (*I == 0 || I[1] == 0)
+ return _error->Error("Invalid line %u",CurLine);
+
+ // Result
+ I++;
+ int const Expected = atoi(I);
+ assertVersion(CurLine, A, B, Expected);
+ // Check the reverse as well
+ assertVersion(CurLine, B, A, Expected*-1);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ if (argc <= 1)
+ RunTest("../versions.lst");
+ else
+ RunTest(argv[1]);
+
+ // Print any errors or warnings found
+ _error->DumpErrors();
+ return 0;
+}
diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc
new file mode 100644
index 000000000..1500caeed
--- /dev/null
+++ b/test/libapt/getarchitectures_test.cc
@@ -0,0 +1,61 @@
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/configuration.h>
+
+#include "assert.h"
+#include <string>
+#include <vector>
+
+#include <iostream>
+
+// simple helper to quickly output a vector of strings
+void dumpVector(std::vector<std::string> vec) {
+ for (std::vector<std::string>::const_iterator v = vec.begin();
+ v != vec.end(); v++)
+ std::cout << *v << std::endl;
+}
+
+int main(int argc,char *argv[])
+{
+ std::vector<std::string> vec;
+
+ _config->Set("APT::Architectures::1", "i386");
+ _config->Set("APT::Architectures::2", "amd64");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 2);
+ equals(vec[0], "i386");
+ equals(vec[1], "amd64");
+
+ _config->Set("APT::Architecture", "i386");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 2);
+ equals(vec[0], "i386");
+ equals(vec[1], "amd64");
+
+ _config->Set("APT::Architectures::2", "");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 1);
+ equals(vec[0], "i386");
+
+ _config->Set("APT::Architecture", "armel");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 2);
+ equals(vec[0], "i386");
+ equals(vec[1], "armel");
+
+ _config->Set("APT::Architectures::2", "amd64");
+ _config->Set("APT::Architectures::3", "i386");
+ _config->Set("APT::Architectures::4", "armel");
+ _config->Set("APT::Architectures::5", "i386");
+ _config->Set("APT::Architectures::6", "amd64");
+ _config->Set("APT::Architectures::7", "armel");
+ _config->Set("APT::Architectures::8", "armel");
+ _config->Set("APT::Architectures::9", "amd64");
+ _config->Set("APT::Architectures::10", "amd64");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 3);
+ equals(vec[0], "i386");
+ equals(vec[1], "amd64");
+ equals(vec[2], "armel");
+
+ return 0;
+}
diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc
new file mode 100644
index 000000000..9a8910b58
--- /dev/null
+++ b/test/libapt/getlanguages_test.cc
@@ -0,0 +1,149 @@
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/configuration.h>
+
+#include "assert.h"
+#include <string>
+#include <vector>
+
+#include <iostream>
+
+// simple helper to quickly output a vector of strings
+void dumpVector(std::vector<std::string> vec) {
+ for (std::vector<std::string>::const_iterator v = vec.begin();
+ v != vec.end(); v++)
+ std::cout << *v << std::endl;
+}
+
+int main(int argc,char *argv[])
+{
+ if (argc != 2) {
+ std::cout << "One parameter expected - given " << argc << std::endl;
+ return 100;
+ }
+
+ char const* env[2];
+ env[0] = "de_DE.UTF-8";
+ env[1] = "";
+
+ std::vector<std::string> vec = APT::Configuration::getLanguages(false, false, env);
+ equals(vec.size(), 2);
+ equals(vec[0], "de");
+ equals(vec[1], "en");
+
+ // Special: Check if the cache is actually in use
+ env[0] = "en_GB.UTF-8";
+ vec = APT::Configuration::getLanguages(false, true, env);
+ equals(vec.size(), 2);
+ equals(vec[0], "de");
+ equals(vec[1], "en");
+
+ env[0] = "en_GB.UTF-8";
+ vec = APT::Configuration::getLanguages(false, false, env);
+ equals(vec.size(), 2);
+ equals(vec[0], "en_GB");
+ equals(vec[1], "en");
+
+ // esperanto
+ env[0] = "eo.UTF-8";
+ vec = APT::Configuration::getLanguages(false, false, env);
+ equals(vec.size(), 2);
+ equals(vec[0], "eo");
+ equals(vec[1], "en");
+
+ env[0] = "tr_DE@euro";
+ vec = APT::Configuration::getLanguages(false, false, env);
+ equals(vec.size(), 2);
+ equals(vec[0], "tr");
+ equals(vec[1], "en");
+
+ env[0] = "de_NO";
+ env[1] = "se_NO:en_GB:nb_NO:nb:no_NO:no:nn_NO:nn:da:sv:en";
+ vec = APT::Configuration::getLanguages(false, false, env);
+ equals(vec.size(), 5);
+ equals(vec[0], "de");
+ equals(vec[1], "en_GB");
+ equals(vec[2], "nb");
+ equals(vec[3], "no");
+ equals(vec[4], "en");
+
+ env[0] = "pt_PR.UTF-8";
+ env[1] = "";
+ vec = APT::Configuration::getLanguages(false, false, env);
+ equals(vec.size(), 3);
+ equals(vec[0], "pt_PR");
+ equals(vec[1], "pt");
+ equals(vec[2], "en");
+
+ env[0] = "ast_DE.UTF-8";
+ vec = APT::Configuration::getLanguages(false, false, env); // bogus, but syntactical correct
+ equals(vec.size(), 2);
+ equals(vec[0], "ast");
+ equals(vec[1], "en");
+
+ env[0] = "C";
+ vec = APT::Configuration::getLanguages(false, false, env);
+ equals(vec.size(), 1);
+ equals(vec[0], "en");
+
+ _config->Set("Acquire::Languages::1", "environment");
+ _config->Set("Acquire::Languages::2", "en");
+ env[0] = "de_DE.UTF-8";
+ vec = APT::Configuration::getLanguages(false, false, env);
+ equals(vec.size(), 2);
+ equals(vec[0], "de");
+ equals(vec[1], "en");
+
+ _config->Set("Acquire::Languages::3", "de");
+ env[0] = "de_DE.UTF-8";
+ vec = APT::Configuration::getLanguages(false, false, env);
+ equals(vec.size(), 2);
+ equals(vec[0], "de");
+ equals(vec[1], "en");
+
+ _config->Set("Dir::State::lists", argv[1]);
+ vec = APT::Configuration::getLanguages(true, false, env);
+ equals(vec.size(), 5);
+ equals(vec[0], "de");
+ equals(vec[1], "en");
+ equals(vec[2], "none");
+ equals(vec[3], "pt");
+ equals(vec[4], "tr");
+
+ _config->Set("Dir::State::lists", "/non-existing-dir");
+ _config->Set("Acquire::Languages::1", "none");
+ env[0] = "de_DE.UTF-8";
+ vec = APT::Configuration::getLanguages(false, false, env);
+ equals(vec.size(), 0);
+ env[0] = "de_DE.UTF-8";
+ vec = APT::Configuration::getLanguages(true, false, env);
+ equals(vec[0], "en");
+ equals(vec[1], "de");
+
+ _config->Set("Acquire::Languages::1", "fr");
+ _config->Set("Acquire::Languages", "de_DE");
+ env[0] = "de_DE.UTF-8";
+ vec = APT::Configuration::getLanguages(false, false, env);
+ equals(vec.size(), 1);
+ equals(vec[0], "de_DE");
+
+ _config->Set("Acquire::Languages", "none");
+ env[0] = "de_DE.UTF-8";
+ vec = APT::Configuration::getLanguages(true, false, env);
+ equals(vec.size(), 0);
+
+ _config->Set("Acquire::Languages", "");
+ //FIXME: Remove support for this deprecated setting
+ _config->Set("APT::Acquire::Translation", "ast_DE");
+ env[0] = "de_DE.UTF-8";
+ vec = APT::Configuration::getLanguages(true, false, env);
+ equals(vec.size(), 2);
+ equals(vec[0], "ast_DE");
+ equals(vec[1], "en");
+ _config->Set("APT::Acquire::Translation", "none");
+ env[0] = "de_DE.UTF-8";
+ vec = APT::Configuration::getLanguages(true, false, env);
+ equals(vec.size(), 1);
+ equals(vec[0], "en");
+
+ return 0;
+}
diff --git a/test/libapt/globalerror_test.cc b/test/libapt/globalerror_test.cc
new file mode 100644
index 000000000..b2752255f
--- /dev/null
+++ b/test/libapt/globalerror_test.cc
@@ -0,0 +1,77 @@
+#include <apt-pkg/error.h>
+
+#include "assert.h"
+#include <string>
+
+int main(int argc,char *argv[])
+{
+ equals(_error->empty(), true);
+ equals(_error->PendingError(), false);
+ equals(_error->Notice("%s Notice", "A"), false);
+ equals(_error->empty(), true);
+ equals(_error->empty(GlobalError::DEBUG), false);
+ equals(_error->PendingError(), false);
+ equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false);
+ equals(_error->PendingError(), true);
+ std::string text;
+ equals(_error->PopMessage(text), false);
+ equals(_error->PendingError(), true);
+ equals(text, "A Notice");
+ equals(_error->PopMessage(text), true);
+ equals(text, "Something horrible happend 2 times");
+ equals(_error->empty(GlobalError::DEBUG), true);
+ equals(_error->PendingError(), false);
+ equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false);
+ equals(_error->PendingError(), true);
+ equals(_error->empty(GlobalError::FATAL), false);
+ _error->Discard();
+
+ equals(_error->empty(), true);
+ equals(_error->PendingError(), false);
+ equals(_error->Notice("%s Notice", "A"), false);
+ equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false);
+ equals(_error->PendingError(), true);
+ equals(_error->empty(GlobalError::NOTICE), false);
+ _error->PushToStack();
+ equals(_error->empty(GlobalError::NOTICE), true);
+ equals(_error->PendingError(), false);
+ equals(_error->Warning("%s Warning", "A"), false);
+ equals(_error->empty(GlobalError::ERROR), true);
+ equals(_error->PendingError(), false);
+ _error->RevertToStack();
+ equals(_error->empty(GlobalError::ERROR), false);
+ equals(_error->PendingError(), true);
+ equals(_error->PopMessage(text), false);
+ equals(_error->PendingError(), true);
+ equals(text, "A Notice");
+ equals(_error->PopMessage(text), true);
+ equals(text, "Something horrible happend 2 times");
+ equals(_error->PendingError(), false);
+ equals(_error->empty(), true);
+
+ equals(_error->Notice("%s Notice", "A"), false);
+ equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false);
+ equals(_error->PendingError(), true);
+ equals(_error->empty(GlobalError::NOTICE), false);
+ _error->PushToStack();
+ equals(_error->empty(GlobalError::NOTICE), true);
+ equals(_error->PendingError(), false);
+ equals(_error->Warning("%s Warning", "A"), false);
+ equals(_error->empty(GlobalError::ERROR), true);
+ equals(_error->PendingError(), false);
+ _error->MergeWithStack();
+ equals(_error->empty(GlobalError::ERROR), false);
+ equals(_error->PendingError(), true);
+ equals(_error->PopMessage(text), false);
+ equals(_error->PendingError(), true);
+ equals(text, "A Notice");
+ equals(_error->PopMessage(text), true);
+ equals(text, "Something horrible happend 2 times");
+ equals(_error->PendingError(), false);
+ equals(_error->empty(), false);
+ equals(_error->PopMessage(text), false);
+ equals(text, "A Warning");
+ equals(_error->empty(), true);
+
+ return 0;
+}
diff --git a/test/libapt/makefile b/test/libapt/makefile
new file mode 100644
index 000000000..50058262e
--- /dev/null
+++ b/test/libapt/makefile
@@ -0,0 +1,48 @@
+# -*- make -*-
+BASE=../..
+SUBDIR=test/libapt
+BASENAME=_libapt_test
+
+# Bring in the default rules
+include ../../buildlib/defaults.mak
+
+# Program for testing getLanguageCode
+PROGRAM = getLanguages${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = getlanguages_test.cc
+include $(PROGRAM_H)
+
+PROGRAM = getArchitectures${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = getarchitectures_test.cc
+include $(PROGRAM_H)
+
+# Program for testing ParseDepends
+PROGRAM = ParseDepends${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = parsedepends_test.cc
+include $(PROGRAM_H)
+
+# Program for testing GetListOfFilesInDir
+PROGRAM = GetListOfFilesInDir${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = getlistoffilesindir_test.cc
+include $(PROGRAM_H)
+
+# Program for testing CommandLine reconstruction
+PROGRAM = CommandlineAsString${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = commandlineasstring_test.cc
+include $(PROGRAM_H)
+
+# Program for testing debians version comparing
+PROGRAM = CompareVersion${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = compareversion_test.cc
+include $(PROGRAM_H)
+
+# test the GlobalError stack class
+PROGRAM = GlobalError${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = globalerror_test.cc
+include $(PROGRAM_H)
diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc
new file mode 100644
index 000000000..7b496878d
--- /dev/null
+++ b/test/libapt/parsedepends_test.cc
@@ -0,0 +1,196 @@
+#include <apt-pkg/deblistparser.h>
+#include <apt-pkg/configuration.h>
+
+#include "assert.h"
+
+int main(int argc,char *argv[]) {
+ string Package;
+ string Version;
+ unsigned int Op = 5;
+ unsigned int Null = 0;
+ bool StripMultiArch = true;
+ bool ParseArchFlags = false;
+ _config->Set("APT::Architecture","dsk");
+
+ const char* Depends =
+ "debhelper:any (>= 5.0), "
+ "libdb-dev:any, "
+ "gettext:native (<= 0.12), "
+ "libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), "
+ "debiandoc-sgml, "
+ "apt (>= 0.7.25), "
+ "not-for-me [ !dsk ], "
+ "only-for-me [ dsk ], "
+ "any-for-me [ any ], "
+ "not-for-darwin [ !darwin-any ], "
+ "cpu-for-me [ any-dsk ], "
+ "os-for-me [ linux-any ], "
+ "cpu-not-for-me [ any-amd64 ], "
+ "os-not-for-me [ kfreebsd-any ], "
+ "overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), "
+ ;
+
+ unsigned short runner = 0;
+test:
+// std::clog << (StripMultiArch ? "NO-Multi" : "Multi") << " " << (ParseArchFlags ? "Flags" : "NO-Flags") << std::endl;
+
+ // Stripping MultiArch is currently the default setting to not confuse
+ // non-MultiArch capable users of the library with "strange" extensions.
+ const char* Start = Depends;
+ const char* End = Depends + strlen(Depends);
+
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ if (StripMultiArch == true)
+ equals("debhelper", Package);
+ else
+ equals("debhelper:any", Package);
+ equals("5.0", Version);
+ equals(Null | pkgCache::Dep::GreaterEq, Op);
+
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ if (StripMultiArch == true)
+ equals("libdb-dev", Package);
+ else
+ equals("libdb-dev:any", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::NoOp, Op);
+
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ if (StripMultiArch == true)
+ equals("gettext", Package);
+ else
+ equals("gettext:native", Package);
+ equals("0.12", Version);
+ equals(Null | pkgCache::Dep::LessEq, Op);
+
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ if (StripMultiArch == true)
+ equals("libcurl4-gnutls-dev", Package);
+ else
+ equals("libcurl4-gnutls-dev:native", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::Or, Op);
+
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("libcurl3-gnutls-dev", Package);
+ equals("7.15.5", Version);
+ equals(Null | pkgCache::Dep::Greater, Op);
+
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("debiandoc-sgml", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::NoOp, Op);
+
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("apt", Package);
+ equals("0.7.25", Version);
+ equals(Null | pkgCache::Dep::GreaterEq, Op);
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("", Package); // not-for-me
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("only-for-me", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::NoOp, Op);
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("any-for-me", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::NoOp, Op);
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("not-for-darwin", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::NoOp, Op);
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("cpu-for-me", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::NoOp, Op);
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("os-for-me", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::NoOp, Op);
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("", Package); // cpu-not-for-me
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("", Package); // os-not-for-me
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ if (StripMultiArch == true)
+ equals("overlord-dev", Package);
+ else
+ equals("overlord-dev:any", Package);
+ equals("7.15.3~", Version);
+ equals(Null | pkgCache::Dep::Equals | pkgCache::Dep::Or, Op);
+
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ if (StripMultiArch == true)
+ equals("overlord-dev", Package);
+ else
+ equals("overlord-dev:native", Package);
+ equals("7.15.5", Version);
+ equals(Null | pkgCache::Dep::Greater, Op);
+
+ if (StripMultiArch == false)
+ ParseArchFlags = true;
+ StripMultiArch = !StripMultiArch;
+
+ runner++;
+ if (runner < 4)
+ goto test; // this is the prove: tests are really evil ;)
+
+ return 0;
+}
diff --git a/test/libapt/run-tests.sh b/test/libapt/run-tests
index 1fcfb6861..0f55f7386 100755
--- a/test/libapt/run-tests.sh
+++ b/test/libapt/run-tests
@@ -1,10 +1,12 @@
#!/bin/sh
set -e
-echo "Compiling the tests ..."
-make
-echo "Running all testcases ..."
-LDPATH=$(pwd)/../../build/bin
+local DIR=$(readlink -f $(dirname $0))
+echo "Compiling the tests …"
+test -d "$DIR/../../build/obj/test/libapt/" || mkdir -p "$DIR/../../build/obj/test/libapt/"
+$(cd $DIR && make)
+echo "Running all testcases …"
+LDPATH="$DIR/../../build/bin"
EXT="_libapt_test"
for testapp in $(ls ${LDPATH}/*$EXT)
do
@@ -39,6 +41,13 @@ do
"${tmppath}/01invalíd"
ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list"
ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list"
+ elif [ $name = "getLanguages${EXT}" ]; then
+ echo "Prepare Testarea for \033[1;35m$name\033[0m ..."
+ tmppath=$(mktemp -d)
+ touch "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tr" \
+ "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \
+ "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \
+ "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak"
fi
echo -n "Testing with \033[1;35m${name}\033[0m ... "