From 2bb255740bf18b5e0524fe833523303abb5c9051 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 12 Mar 2010 19:41:30 +0100 Subject: * apt-pkg/deb/dpkgpm.cc: - if available store the Commandline in the history * apt-pkg/contrib/cmndline.cc: - save Commandline in Commandline::AsString for logging --- test/libapt/commandlineasstring_test.cc | 39 +++++++++++++++++++++++++++++++++ test/libapt/makefile | 6 +++++ 2 files changed, 45 insertions(+) create mode 100644 test/libapt/commandlineasstring_test.cc (limited to 'test/libapt') 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 +#include + +#include + +#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/makefile b/test/libapt/makefile index 08f581e6d..cb76d5ee6 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -23,3 +23,9 @@ 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) -- cgit v1.2.3 From ea5624c3d04c35f5a269b6f7431c135330c9b9b5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 13 Mar 2010 14:11:22 +0100 Subject: * apt-pkg/deb/debversion.cc: - consider absent of debian revision equivalent to 0 (Closes: #573592) This moves the existing testcase for version comparison to "my" directory, adds a few more tests (e.g. the tests used in cupt) and rewrites the testcases runner: The runner does now call dpkg --compare-versions to check what dpkg thinks about the comparison - all done in less code ;) --- test/libapt/compareversion_test.cc | 123 +++++++++++++++++++++++++++++++++++++ test/libapt/makefile | 6 ++ 2 files changed, 129 insertions(+) create mode 100644 test/libapt/compareversion_test.cc (limited to 'test/libapt') 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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +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/makefile b/test/libapt/makefile index cb76d5ee6..98bdb3348 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -29,3 +29,9 @@ 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) -- cgit v1.2.3 From 3152f4aa4a97ad06ef1073aabe137f999f787ee1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 28 May 2010 23:11:36 +0200 Subject: * apt-pkg/aptconfiguration.cc: - remove duplicate architectures in getArchitectures() --- test/libapt/getarchitectures_test.cc | 61 ++++++++++++++++++++++++++++++++++++ test/libapt/makefile | 5 +++ 2 files changed, 66 insertions(+) create mode 100644 test/libapt/getarchitectures_test.cc (limited to 'test/libapt') 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 +#include + +#include "assert.h" +#include +#include + +#include + +// simple helper to quickly output a vector of strings +void dumpVector(std::vector vec) { + for (std::vector::const_iterator v = vec.begin(); + v != vec.end(); v++) + std::cout << *v << std::endl; +} + +int main(int argc,char *argv[]) +{ + std::vector 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/makefile b/test/libapt/makefile index 98bdb3348..ee3401b35 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -12,6 +12,11 @@ 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 -- cgit v1.2.3 From 8fa7eefb8a320e8fa4a26c4718fa606d4d27a56f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 28 May 2010 23:40:08 +0200 Subject: create the bin-test directory automatic in the runner --- test/libapt/run-tests.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'test/libapt') diff --git a/test/libapt/run-tests.sh b/test/libapt/run-tests.sh index f9df1af5f..cb7769e4a 100755 --- a/test/libapt/run-tests.sh +++ b/test/libapt/run-tests.sh @@ -2,6 +2,7 @@ set -e echo "Compiling the tests ..." +test -d '../../build/obj/test/libapt/' || mkdir -p '../../build/obj/test/libapt/' make echo "Running all testcases ..." LDPATH=$(pwd)/../../build/bin -- cgit v1.2.3 From c4ba7c44ff03d67ff982bbab26dc48d796041e02 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 25 Jun 2010 19:16:12 +0200 Subject: add a simple stack handling to be able to delay error handling --- test/libapt/globalerror_test.cc | 77 +++++++++++++++++++++++++++++++++++++++++ test/libapt/makefile | 10 ++++-- 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 test/libapt/globalerror_test.cc (limited to 'test/libapt') 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 + +#include "assert.h" +#include + +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 index ee3401b35..50058262e 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -30,13 +30,19 @@ SOURCE = getlistoffilesindir_test.cc include $(PROGRAM_H) # Program for testing CommandLine reconstruction -PROGRAM = commandlineasstring${BASENAME} +PROGRAM = CommandlineAsString${BASENAME} SLIBS = -lapt-pkg SOURCE = commandlineasstring_test.cc include $(PROGRAM_H) # Program for testing debians version comparing -PROGRAM = compareversion${BASENAME} +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) -- cgit v1.2.3 From af5cf9299fb60c255d4c1c30ca9a97e7e6acfef0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 5 Jul 2010 12:12:40 +0200 Subject: extends the ParseDepends testcase to have a look also at the Wildcards --- test/libapt/parsedepends_test.cc | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'test/libapt') diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc index b7befa561..7b496878d 100644 --- a/test/libapt/parsedepends_test.cc +++ b/test/libapt/parsedepends_test.cc @@ -21,6 +21,12 @@ int main(int argc,char *argv[]) { "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), " ; @@ -100,6 +106,68 @@ test: 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); -- cgit v1.2.3 From f6bfb482a32543deed925b127c972a7c258df4a1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 25 Jul 2010 20:04:16 +0200 Subject: Strip the .sh extension from the libapt testrunner and make it a bit more robust against calling from outside --- test/libapt/run-tests | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ test/libapt/run-tests.sh | 60 ----------------------------------------------- 2 files changed, 61 insertions(+), 60 deletions(-) create mode 100755 test/libapt/run-tests delete mode 100755 test/libapt/run-tests.sh (limited to 'test/libapt') diff --git a/test/libapt/run-tests b/test/libapt/run-tests new file mode 100755 index 000000000..0f55f7386 --- /dev/null +++ b/test/libapt/run-tests @@ -0,0 +1,61 @@ +#!/bin/sh +set -e + +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 + name=$(basename ${testapp}) + tmppath="" + + if [ $name = "GetListOfFilesInDir${EXT}" ]; then + # TODO: very-low: move env creation to the actual test-app + echo "Prepare Testarea for \033[1;35m$name\033[0m ..." + tmppath=$(mktemp -d) + touch "${tmppath}/anormalfile" \ + "${tmppath}/01yet-anothernormalfile" \ + "${tmppath}/anormalapt.conf" \ + "${tmppath}/01yet-anotherapt.conf" \ + "${tmppath}/anormalapt.list" \ + "${tmppath}/01yet-anotherapt.list" \ + "${tmppath}/wrongextension.wron" \ + "${tmppath}/wrong-extension.wron" \ + "${tmppath}/strangefile." \ + "${tmppath}/s.t.r.a.n.g.e.f.i.l.e" \ + "${tmppath}/.hiddenfile" \ + "${tmppath}/.hiddenfile.conf" \ + "${tmppath}/.hiddenfile.list" \ + "${tmppath}/multi..dot" \ + "${tmppath}/multi.dot.conf" \ + "${tmppath}/multi.dot.list" \ + "${tmppath}/disabledfile.disabled" \ + "${tmppath}/disabledfile.conf.disabled" \ + "${tmppath}/disabledfile.list.disabled" \ + "${tmppath}/invälid.conf" \ + "${tmppath}/invalíd" \ + "${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 ... " + LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m" + + if [ -n "$tmppath" -a -d "$tmppath" ]; then + echo "Cleanup Testarea after \033[1;35m$name\033[0m ..." + rm -rf "$tmppath" + fi + +done diff --git a/test/libapt/run-tests.sh b/test/libapt/run-tests.sh deleted file mode 100755 index cb7769e4a..000000000 --- a/test/libapt/run-tests.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -set -e - -echo "Compiling the tests ..." -test -d '../../build/obj/test/libapt/' || mkdir -p '../../build/obj/test/libapt/' -make -echo "Running all testcases ..." -LDPATH=$(pwd)/../../build/bin -EXT="_libapt_test" -for testapp in $(ls ${LDPATH}/*$EXT) -do - name=$(basename ${testapp}) - tmppath="" - - if [ $name = "GetListOfFilesInDir${EXT}" ]; then - # TODO: very-low: move env creation to the actual test-app - echo "Prepare Testarea for \033[1;35m$name\033[0m ..." - tmppath=$(mktemp -d) - touch "${tmppath}/anormalfile" \ - "${tmppath}/01yet-anothernormalfile" \ - "${tmppath}/anormalapt.conf" \ - "${tmppath}/01yet-anotherapt.conf" \ - "${tmppath}/anormalapt.list" \ - "${tmppath}/01yet-anotherapt.list" \ - "${tmppath}/wrongextension.wron" \ - "${tmppath}/wrong-extension.wron" \ - "${tmppath}/strangefile." \ - "${tmppath}/s.t.r.a.n.g.e.f.i.l.e" \ - "${tmppath}/.hiddenfile" \ - "${tmppath}/.hiddenfile.conf" \ - "${tmppath}/.hiddenfile.list" \ - "${tmppath}/multi..dot" \ - "${tmppath}/multi.dot.conf" \ - "${tmppath}/multi.dot.list" \ - "${tmppath}/disabledfile.disabled" \ - "${tmppath}/disabledfile.conf.disabled" \ - "${tmppath}/disabledfile.list.disabled" \ - "${tmppath}/invälid.conf" \ - "${tmppath}/invalíd" \ - "${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 ... " - LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m" - - if [ -n "$tmppath" -a -d "$tmppath" ]; then - echo "Cleanup Testarea after \033[1;35m$name\033[0m ..." - rm -rf "$tmppath" - fi - -done -- cgit v1.2.3