diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/libapt/cachefilter_test.cc | 66 | ||||
-rw-r--r-- | test/libapt/parsedepends_test.cc | 22 |
2 files changed, 88 insertions, 0 deletions
diff --git a/test/libapt/cachefilter_test.cc b/test/libapt/cachefilter_test.cc new file mode 100644 index 000000000..28924b758 --- /dev/null +++ b/test/libapt/cachefilter_test.cc @@ -0,0 +1,66 @@ +#include <config.h> + +#include <apt-pkg/cachefilter.h> + +#include <string> + +#include <gtest/gtest.h> + +TEST(CacheFilterTest, ArchitectureSpecification) +{ + { + SCOPED_TRACE("Pattern is any-armhf"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-armhf"); + EXPECT_TRUE(ams("armhf")); + EXPECT_FALSE(ams("armel")); + EXPECT_TRUE(ams("linux-armhf")); + EXPECT_FALSE(ams("linux-armel")); + EXPECT_TRUE(ams("kfreebsd-armhf")); + EXPECT_TRUE(ams("gnu-linux-armhf")); + EXPECT_FALSE(ams("gnu-linux-armel")); + EXPECT_TRUE(ams("gnu-kfreebsd-armhf")); + EXPECT_TRUE(ams("musl-linux-armhf")); + } + { + SCOPED_TRACE("Pattern is linux-any"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("linux-any"); + EXPECT_TRUE(ams("armhf")); + EXPECT_TRUE(ams("armel")); + EXPECT_TRUE(ams("linux-armhf")); + EXPECT_TRUE(ams("linux-armel")); + EXPECT_FALSE(ams("kfreebsd-armhf")); + EXPECT_TRUE(ams("gnu-linux-armhf")); + EXPECT_TRUE(ams("gnu-linux-armel")); + EXPECT_FALSE(ams("gnu-kfreebsd-armhf")); + EXPECT_TRUE(ams("musl-linux-armhf")); + } + { + SCOPED_TRACE("Pattern is gnu-any-any"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("gnu-any-any"); //really? + EXPECT_TRUE(ams("armhf")); + EXPECT_TRUE(ams("armel")); + EXPECT_TRUE(ams("linux-armhf")); + EXPECT_TRUE(ams("linux-armel")); + EXPECT_TRUE(ams("kfreebsd-armhf")); + EXPECT_TRUE(ams("gnu-linux-armhf")); + EXPECT_TRUE(ams("gnu-linux-armel")); + EXPECT_TRUE(ams("gnu-kfreebsd-armhf")); + EXPECT_FALSE(ams("musl-linux-armhf")); + } + { + SCOPED_TRACE("Architecture is armhf"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("armhf", false); + EXPECT_TRUE(ams("armhf")); + EXPECT_FALSE(ams("armel")); + EXPECT_TRUE(ams("linux-any")); + EXPECT_FALSE(ams("kfreebsd-any")); + EXPECT_TRUE(ams("any-armhf")); + EXPECT_FALSE(ams("any-armel")); + EXPECT_TRUE(ams("linux-armhf")); + EXPECT_FALSE(ams("kfreebsd-armhf")); + EXPECT_TRUE(ams("gnu-linux-armhf")); + EXPECT_FALSE(ams("gnu-linux-armel")); + EXPECT_FALSE(ams("gnu-kfreebsd-armhf")); + EXPECT_FALSE(ams("musl-linux-armhf")); + } +} diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc index f644599bd..f537542b4 100644 --- a/test/libapt/parsedepends_test.cc +++ b/test/libapt/parsedepends_test.cc @@ -31,6 +31,8 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag "not-for-darwin [ !darwin-any ], " "cpu-for-me [ any-amd64 ], " "os-for-me [ linux-any ], " + "libc-for-me [ gnu-linux-any ], " + "libc-not-for-me [ musl-linux-any ], " "cpu-not-for-me [ any-armel ], " "os-not-for-me [ kfreebsd-any ], " "not-in-stage1 <!stage1>, " @@ -158,6 +160,26 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag if (ParseArchFlags == true) { Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + EXPECT_EQ("libc-for-me", Package); + EXPECT_EQ("", Version); + EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op); + } else { + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + Start = strstr(Start, ","); + Start++; + } + + if (ParseArchFlags == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + EXPECT_EQ("", Package); // libc-not-for-me + } else { + EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + Start = strstr(Start, ","); + Start++; + } + + if (ParseArchFlags == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); EXPECT_EQ("", Package); // cpu-not-for-me } else { EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); |