summaryrefslogtreecommitdiff
path: root/test/libapt
diff options
context:
space:
mode:
Diffstat (limited to 'test/libapt')
-rw-r--r--test/libapt/CMakeLists.txt3
-rw-r--r--test/libapt/cachefilter_test.cc97
-rw-r--r--test/libapt/commandline_test.cc10
-rw-r--r--test/libapt/getlanguages_test.cc7
-rw-r--r--test/libapt/getlistoffilesindir_test.cc7
-rw-r--r--test/libapt/openmaybeclearsignedfile_test.cc342
-rw-r--r--test/libapt/parsedepends_test.cc83
7 files changed, 486 insertions, 63 deletions
diff --git a/test/libapt/CMakeLists.txt b/test/libapt/CMakeLists.txt
index f7cd5b2f6..86c0b28b5 100644
--- a/test/libapt/CMakeLists.txt
+++ b/test/libapt/CMakeLists.txt
@@ -22,6 +22,9 @@ if(NOT GTEST_FOUND AND EXISTS ${GTEST_ROOT})
endif()
if(GTEST_FOUND)
+ # Definition of the C++ files used to build the test binary - note that this
+ # is expanded at CMake time, so you have to rerun cmake if you add or remove
+ # a file (you can just run cmake . in the build directory)
file(GLOB files gtest_runner.cc *-helpers.cc *_test.cc)
add_executable(libapt_test ${files})
target_include_directories(libapt_test PRIVATE ${GTEST_INCLUDE_DIRS})
diff --git a/test/libapt/cachefilter_test.cc b/test/libapt/cachefilter_test.cc
index 28924b758..08812e0dc 100644
--- a/test/libapt/cachefilter_test.cc
+++ b/test/libapt/cachefilter_test.cc
@@ -1,6 +1,7 @@
#include <config.h>
#include <apt-pkg/cachefilter.h>
+#include <apt-pkg/fileutl.h>
#include <string>
@@ -9,17 +10,22 @@
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 *");
+ // * should be treated like any
+ APT::CacheFilter::PackageArchitectureMatchesSpecification ams("*");
+ EXPECT_TRUE(ams("sparc"));
+ EXPECT_TRUE(ams("amd64"));
+ EXPECT_TRUE(ams("kfreebsd-amd64"));
+ }
+ {
+ SCOPED_TRACE("Pattern is any-i386");
+ APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-i386");
+ EXPECT_TRUE(ams("i386"));
+ EXPECT_FALSE(ams("amd64"));
+ EXPECT_TRUE(ams("linux-i386"));
+ EXPECT_FALSE(ams("linux-amd64"));
+ EXPECT_TRUE(ams("kfreebsd-i386"));
+ EXPECT_TRUE(ams("musl-linux-i386"));
}
{
SCOPED_TRACE("Pattern is linux-any");
@@ -29,11 +35,9 @@ TEST(CacheFilterTest, ArchitectureSpecification)
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"));
}
+ if (FileExists(DPKG_DATADIR "/tupletable"))
{
SCOPED_TRACE("Pattern is gnu-any-any");
APT::CacheFilter::PackageArchitectureMatchesSpecification ams("gnu-any-any"); //really?
@@ -42,11 +46,32 @@ TEST(CacheFilterTest, ArchitectureSpecification)
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"));
}
+ if (FileExists(DPKG_DATADIR "/triplettable"))
+ {
+ SCOPED_TRACE("Pattern is gnueabi-any-any");
+ APT::CacheFilter::PackageArchitectureMatchesSpecification ams("gnueabi-any-any"); //really?
+ EXPECT_TRUE(ams("linux-armel"));
+ EXPECT_TRUE(ams("armel"));
+ EXPECT_FALSE(ams("armhf"));
+ EXPECT_FALSE(ams("linux-armhf"));
+ EXPECT_FALSE(ams("musleabihf-linux-armhf"));
+ }
+ if (FileExists(DPKG_DATADIR "/triplettable"))
+ {
+ SCOPED_TRACE("Pattern is gnueabihf-any-any");
+ APT::CacheFilter::PackageArchitectureMatchesSpecification ams("gnueabihf-any-any"); //really?
+ EXPECT_FALSE(ams("linux-armel"));
+ EXPECT_FALSE(ams("armel"));
+ EXPECT_TRUE(ams("armhf"));
+ EXPECT_TRUE(ams("linux-armhf"));
+ EXPECT_FALSE(ams("musleabihf-linux-armhf"));
+ }
+
+ // Weird ones - armhf's tuple is actually eabihf-gnu-linux-arm
+ // armel's tuple is actually eabi-gnu-linux-arm
+ // x32's tuple is actually x32-gnu-linux-amd64
{
SCOPED_TRACE("Architecture is armhf");
APT::CacheFilter::PackageArchitectureMatchesSpecification ams("armhf", false);
@@ -54,13 +79,41 @@ TEST(CacheFilterTest, ArchitectureSpecification)
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("any-arm"));
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"));
}
+ {
+ SCOPED_TRACE("Pattern is any-arm");
+ APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-arm");
+ EXPECT_TRUE(ams("armhf"));
+ EXPECT_TRUE(ams("armel"));
+ EXPECT_TRUE(ams("linux-armhf"));
+ EXPECT_TRUE(ams("linux-armel"));
+ EXPECT_TRUE(ams("musl-linux-armhf"));
+ EXPECT_TRUE(ams("uclibc-linux-armel"));
+
+ EXPECT_FALSE(ams("arm64"));
+ EXPECT_FALSE(ams("linux-arm64"));
+ EXPECT_FALSE(ams("kfreebsd-arm64"));
+ EXPECT_FALSE(ams("musl-linux-arm64"));
+ }
+ {
+ SCOPED_TRACE("Pattern is any-amd64");
+ APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-amd64");
+ EXPECT_TRUE(ams("amd64"));
+ EXPECT_TRUE(ams("x32"));
+ EXPECT_TRUE(ams("linux-amd64"));
+ EXPECT_TRUE(ams("linux-x32"));
+ EXPECT_TRUE(ams("kfreebsd-amd64"));
+ EXPECT_TRUE(ams("musl-linux-amd64"));
+ EXPECT_TRUE(ams("uclibc-linux-amd64"));
+
+ EXPECT_FALSE(ams("i386"));
+ EXPECT_FALSE(ams("linux-i386"));
+ EXPECT_FALSE(ams("kfreebsd-i386"));
+ EXPECT_FALSE(ams("musl-linux-i386"));
+ EXPECT_FALSE(ams("uclibc-linux-i386"));
+ }
}
diff --git a/test/libapt/commandline_test.cc b/test/libapt/commandline_test.cc
index 97725c854..1dc9c6946 100644
--- a/test/libapt/commandline_test.cc
+++ b/test/libapt/commandline_test.cc
@@ -24,8 +24,16 @@ TEST(CommandLineTest,SaveInConfig)
"apt-get", "install", "-sf");
APT_EXPECT_CMD("apt-cache -s apt -so Debug::test=Test",
"apt-cache", "-s", "apt", "-so", "Debug::test=Test");
- APT_EXPECT_CMD("apt-cache -s apt -so Debug::test=\"Das ist ein Test\"",
+ APT_EXPECT_CMD("apt-cache -s apt -so Debug::test='Das ist ein Test'",
"apt-cache", "-s", "apt", "-so", "Debug::test=Das ist ein Test");
+ APT_EXPECT_CMD("apt-cache -s apt -so Debug::test='Das ist ein Test'",
+ "apt-cache", "-s", "apt", "-so", "Debug::test=\"Das ist ein Test\"");
+ APT_EXPECT_CMD("apt-cache -s apt -so Debug::test='Das ist ein Test' foo",
+ "apt-cache", "-s", "apt", "-so", "\"Debug::test=Das ist ein Test\"", "foo");
+ APT_EXPECT_CMD("apt-cache -s apt -so Debug::test='Das ist ein Test' foo",
+ "apt-cache", "-s", "apt", "-so", "\'Debug::test=Das ist ein Test\'", "foo");
+ APT_EXPECT_CMD("apt-cache -s apt -so Debug::test='That is crazy!' foo",
+ "apt-cache", "-s", "apt", "-so", "\'Debug::test=That \ris\n crazy!\'", "foo");
APT_EXPECT_CMD("apt-cache -s apt --hallo test=1.0",
"apt-cache", "-s", "apt", "--hallo", "test=1.0");
#undef APT_EXPECT_CMD
diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc
index c50ff6ff8..29ff0c9ae 100644
--- a/test/libapt/getlanguages_test.cc
+++ b/test/libapt/getlanguages_test.cc
@@ -2,6 +2,7 @@
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <algorithm>
@@ -214,6 +215,7 @@ TEST(LanguagesTest,TranslationFiles)
EXPECT_EQ(1, vec.size());
EXPECT_EQ("none", vec[0]);
+ _error->PushToStack();
_config->Set("Acquire::Languages", "");
//FIXME: Remove support for this deprecated setting
_config->Set("APT::Acquire::Translation", "ast_DE");
@@ -228,6 +230,11 @@ TEST(LanguagesTest,TranslationFiles)
EXPECT_EQ(1, vec.size());
EXPECT_EQ("en", vec[0]);
+ // discard the deprecation warning for APT::Acquire::Translation
+ if (_error->PendingError())
+ _error->MergeWithStack();
+ else
+ _error->RevertToStack();
EXPECT_EQ(0, system(std::string("rm -rf ").append(tempdir).c_str()));
_config->Clear();
diff --git a/test/libapt/getlistoffilesindir_test.cc b/test/libapt/getlistoffilesindir_test.cc
index 2369c911a..8c5e56b1d 100644
--- a/test/libapt/getlistoffilesindir_test.cc
+++ b/test/libapt/getlistoffilesindir_test.cc
@@ -1,6 +1,7 @@
#include <config.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/error.h>
#include <string>
#include <vector>
@@ -49,6 +50,7 @@ TEST(FileUtlTest,GetListOfFilesInDir)
createLink(tempdir, "non-existing-file", "brokenlink.list");
// Files with no extension
+ _error->PushToStack();
std::vector<std::string> files = GetListOfFilesInDir(tempdir, "", true);
ASSERT_EQ(2, files.size());
EXPECT_EQ(P("01yet-anothernormalfile"), files[0]);
@@ -103,5 +105,10 @@ TEST(FileUtlTest,GetListOfFilesInDir)
EXPECT_EQ(P("disabledfile.disabled"), files[3]);
EXPECT_EQ(P("disabledfile.list.disabled"), files[4]);
+ // discard the unknown file extension messages
+ if (_error->PendingError())
+ _error->MergeWithStack();
+ else
+ _error->RevertToStack();
removeDirectory(tempdir);
}
diff --git a/test/libapt/openmaybeclearsignedfile_test.cc b/test/libapt/openmaybeclearsignedfile_test.cc
new file mode 100644
index 000000000..40735812d
--- /dev/null
+++ b/test/libapt/openmaybeclearsignedfile_test.cc
@@ -0,0 +1,342 @@
+#include <config.h>
+
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/gpgv.h>
+
+#include <string>
+
+#include <gtest/gtest.h>
+
+#include "file-helpers.h"
+
+/* The test files are created with the 'Joe Sixpack' and 'Marvin Paranoid'
+ test key included in the integration testing framework */
+
+TEST(OpenMaybeClearSignedFileTest,SimpleSignedFile)
+{
+ std::string tempfile;
+ FileFd fd;
+ // Using c++11 raw-strings would be nifty, but travis doesn't support it…
+ createTemporaryFile("simplesignedfile", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n"
+"Hash: SHA512\n"
+"\n"
+"Test\n"
+"-----BEGIN PGP SIGNATURE-----\n"
+"\n"
+"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n"
+"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n"
+"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n"
+"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n"
+"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n"
+"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n"
+"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n"
+"=TB1F\n"
+"-----END PGP SIGNATURE-----\n");
+
+ EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd));
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
+ EXPECT_TRUE(fd.IsOpen());
+ char buffer[100];
+ EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer)));
+ EXPECT_STREQ(buffer, "Test");
+ EXPECT_TRUE(fd.Eof());
+}
+
+TEST(OpenMaybeClearSignedFileTest,WhitespaceSignedFile)
+{
+ std::string tempfile;
+ FileFd fd;
+ // no raw-string here to protect the whitespace from cleanup
+ createTemporaryFile("simplesignedfile", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE----- \t \n"
+"Hash: SHA512 \n"
+" \n"
+"Test \n"
+"-----BEGIN PGP SIGNATURE----- \n"
+" \n"
+"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt \n"
+"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l \n"
+"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg \n"
+"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k \n"
+"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx \n"
+"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns \n"
+"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq \n"
+"=TB1F \n"
+"-----END PGP SIGNATURE-----");
+
+ EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd));
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
+ EXPECT_TRUE(fd.IsOpen());
+ char buffer[100];
+ EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer)));
+ EXPECT_STREQ(buffer, "Test");
+ EXPECT_TRUE(fd.Eof());
+}
+
+TEST(OpenMaybeClearSignedFileTest,SignedFileWithContentHeaders)
+{
+ std::string tempfile;
+ FileFd fd;
+ createTemporaryFile("headerssignedfile", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n"
+"Version: 0.8.15~exp1\n"
+"Hash: SHA512\n"
+"Comment: I love you!\n"
+"X-Expires: never\n"
+"Multilines: no\n"
+" yes\n"
+" maybe\n"
+"\n"
+"Test\n"
+"-----BEGIN PGP SIGNATURE-----\n"
+"\n"
+"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n"
+"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n"
+"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n"
+"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n"
+"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n"
+"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n"
+"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n"
+"=TB1F\n"
+"-----END PGP SIGNATURE-----\n");
+
+ EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd));
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
+ EXPECT_TRUE(fd.IsOpen());
+ char buffer[100];
+ EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer)));
+ EXPECT_STREQ(buffer, "Test");
+ EXPECT_TRUE(fd.Eof());
+}
+
+// That isn't how multiple signatures are done
+TEST(OpenMaybeClearSignedFileTest,SignedFileWithTwoSignatures)
+{
+ std::string tempfile;
+ FileFd fd;
+ createTemporaryFile("doublesignedfile", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n"
+"Hash: SHA512\n"
+"\n"
+"Test\n"
+"-----BEGIN PGP SIGNATURE-----\n"
+"\n"
+"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n"
+"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n"
+"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n"
+"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n"
+"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n"
+"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n"
+"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n"
+"=TB1F\n"
+"-----END PGP SIGNATURE-----\n"
+"-----BEGIN PGP SIGNATURE-----\n"
+"\n"
+"iQFHBAEBCgAxFiEE3mauypFRr6GHfsMd6FJdR1KBROIFAlhT/yYTHG1hcnZpbkBl\n"
+"eGFtcGxlLm9yZwAKCRDoUl1HUoFE4qq3B/459MSk3xCW30wc5+ul5ZxTSg6eLYPJ\n"
+"tfVNYi90/ZxRrYQAN+EWozEIZcxoMYp8Ans3++irkjPbHs4NsesmFKt2W5meFl4V\n"
+"oUzYrOh5y5GlDeF7ok5g9atQe8BojjBics+g1IBYcnaMU+ywONmlixa03IPGfxV5\n"
+"oTx02Xvlns20i6HRc0WFtft5q1hXo4EIlVc9O0u902SVEEkeuHF3+bCcXrNLPBJA\n"
+"+8dxmH5+i89f/kVqURrdHdEuA1tsTNyb2C+lvRONh21H8QRRTU/iUQSzV6vZvof5\n"
+"ASc9hsAZRG0xHuRU0F94V/XrkWw8QYAobJ/yxvs4L0EuA4optbSqawDB\n"
+"=CP8j\n"
+"-----END PGP SIGNATURE-----\n");
+
+ EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd));
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
+ EXPECT_TRUE(fd.IsOpen());
+ char buffer[100];
+ EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer)));
+ EXPECT_STREQ(buffer, "Test");
+ EXPECT_TRUE(fd.Eof());
+}
+
+TEST(OpenMaybeClearSignedFileTest,TwoSimpleSignedFile)
+{
+ std::string tempfile;
+ FileFd fd;
+ // read only the first message
+ createTemporaryFile("twosimplesignedfile", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n"
+"Hash: SHA512\n"
+"\n"
+"Test\n"
+"-----BEGIN PGP SIGNATURE-----\n"
+"\n"
+"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n"
+"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n"
+"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n"
+"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n"
+"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n"
+"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n"
+"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n"
+"=TB1F\n"
+"-----END PGP SIGNATURE-----\n"
+"-----BEGIN PGP SIGNED MESSAGE-----\n"
+"Hash: SHA512\n"
+"\n"
+"Test\n"
+"-----BEGIN PGP SIGNATURE-----\n"
+"\n"
+"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n"
+"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n"
+"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n"
+"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n"
+"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n"
+"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n"
+"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n"
+"=TB1F\n"
+"-----END PGP SIGNATURE-----");
+
+ EXPECT_TRUE(_error->empty());
+ EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd));
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
+ EXPECT_FALSE(_error->empty());
+ EXPECT_TRUE(fd.IsOpen());
+ char buffer[100];
+ EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer)));
+ EXPECT_STREQ(buffer, "Test");
+ EXPECT_TRUE(fd.Eof());
+ ASSERT_FALSE(_error->empty());
+
+ std::string msg;
+ _error->PopMessage(msg);
+ EXPECT_EQ("Clearsigned file '" + tempfile + "' contains unsigned lines.", msg);
+}
+
+TEST(OpenMaybeClearSignedFileTest,UnsignedFile)
+{
+ std::string tempfile;
+ FileFd fd;
+ createTemporaryFile("unsignedfile", fd, &tempfile, "Test");
+
+ EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd));
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
+ EXPECT_TRUE(fd.IsOpen());
+ char buffer[100];
+ EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer)));
+ EXPECT_STREQ(buffer, "Test");
+ EXPECT_TRUE(fd.Eof());
+}
+
+TEST(OpenMaybeClearSignedFileTest,GarbageTop)
+{
+ std::string tempfile;
+ FileFd fd;
+ createTemporaryFile("garbagetop", fd, &tempfile, "Garbage\n"
+"-----BEGIN PGP SIGNED MESSAGE-----\n"
+"Hash: SHA512\n"
+"\n"
+"Test\n"
+"-----BEGIN PGP SIGNATURE-----\n"
+"\n"
+"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n"
+"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n"
+"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n"
+"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n"
+"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n"
+"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n"
+"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n"
+"=TB1F\n"
+"-----END PGP SIGNATURE-----\n");
+
+ EXPECT_TRUE(_error->empty());
+ EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd));
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
+ EXPECT_TRUE(fd.IsOpen());
+ char buffer[100];
+ EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer)));
+ EXPECT_STREQ(buffer, "Test");
+ EXPECT_TRUE(fd.Eof());
+ ASSERT_FALSE(_error->empty());
+ ASSERT_FALSE(_error->PendingError());
+
+ std::string msg;
+ _error->PopMessage(msg);
+ EXPECT_EQ("Clearsigned file '" + tempfile + "' does not start with a signed message block.", msg);
+}
+
+TEST(OpenMaybeClearSignedFileTest,GarbageBottom)
+{
+ std::string tempfile;
+ FileFd fd;
+ createTemporaryFile("garbagebottom", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n"
+"Hash: SHA512\n"
+"\n"
+"Test\n"
+"-----BEGIN PGP SIGNATURE-----\n"
+"\n"
+"iQFEBAEBCgAuFiEENKjp0Y2zIPNn6OqgWpDRQdusja4FAlhT7+kQHGpvZUBleGFt\n"
+"cGxlLm9yZwAKCRBakNFB26yNrjvEB/9/e3jA1l0fvPafx9LEXcH8CLpUFQK7ra9l\n"
+"3M4YAH4JKQlTG1be7ixruBRlCTh3YiSs66fKMeJeUYoxA2HPhvbGFEjQFAxunEYg\n"
+"X/LBKv1mQWa+Q34P5GBjK8kQdLCN+yJAiUErmWNQG3GPninrxsC9tY5jcWvHeP1k\n"
+"V7N3MLnNqzXaCJM24mnKidC5IDadUdQ8qC8c3rjUexQ8vBz0eucH56jbqV5oOcvx\n"
+"pjlW965dCPIf3OI8q6J7bIOjyY+u/PTcVlqPq3TUz/ti6RkVbKpLH0D4ll3lUTns\n"
+"JQt/+gJCPxHUJphy8sccBKhW29CLELJIIafvU30E1nWn9szh2Xjq\n"
+"=TB1F\n"
+"-----END PGP SIGNATURE-----\n"
+"Garbage");
+
+ EXPECT_TRUE(_error->empty());
+ EXPECT_TRUE(OpenMaybeClearSignedFile(tempfile, fd));
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
+ EXPECT_TRUE(fd.IsOpen());
+ char buffer[100];
+ EXPECT_TRUE(fd.ReadLine(buffer, sizeof(buffer)));
+ EXPECT_STREQ(buffer, "Test");
+ EXPECT_TRUE(fd.Eof());
+ ASSERT_FALSE(_error->empty());
+ ASSERT_FALSE(_error->PendingError());
+
+ std::string msg;
+ _error->PopMessage(msg);
+ EXPECT_EQ("Clearsigned file '" + tempfile + "' contains unsigned lines.", msg);
+}
+
+TEST(OpenMaybeClearSignedFileTest,BogusNoSig)
+{
+ std::string tempfile;
+ FileFd fd;
+ createTemporaryFile("bogusnosig", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n"
+"Hash: SHA512\n"
+"\n"
+"Test");
+
+ EXPECT_TRUE(_error->empty());
+ EXPECT_FALSE(OpenMaybeClearSignedFile(tempfile, fd));
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
+ EXPECT_FALSE(_error->empty());
+ EXPECT_FALSE(fd.IsOpen());
+
+ std::string msg;
+ _error->PopMessage(msg);
+ EXPECT_EQ("Splitting of file " + tempfile + " failed as it doesn't contain all expected parts 0 1 0", msg);
+}
+
+TEST(OpenMaybeClearSignedFileTest,BogusSigStart)
+{
+ std::string tempfile;
+ FileFd fd;
+ createTemporaryFile("bogusnosig", fd, &tempfile, "-----BEGIN PGP SIGNED MESSAGE-----\n"
+"Hash: SHA512\n"
+"\n"
+"Test\n"
+"-----BEGIN PGP SIGNATURE-----");
+
+ EXPECT_TRUE(_error->empty());
+ EXPECT_FALSE(OpenMaybeClearSignedFile(tempfile, fd));
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
+ EXPECT_FALSE(_error->empty());
+ EXPECT_FALSE(fd.IsOpen());
+
+ std::string msg;
+ _error->PopMessage(msg);
+ EXPECT_EQ("Signature in file " + tempfile + " wasn't closed", msg);
+}
diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc
index f537542b4..c2781b5d6 100644
--- a/test/libapt/parsedepends_test.cc
+++ b/test/libapt/parsedepends_test.cc
@@ -9,13 +9,15 @@
#include <gtest/gtest.h>
-static void parseDependency(bool const StripMultiArch, bool const ParseArchFlags, bool const ParseRestrictionsList)
+static void parseDependency(bool const StripMultiArch, bool const ParseArchFlags, bool const ParseRestrictionsList, std::string Arch)
{
std::string Package;
std::string Version;
unsigned int Op = 5;
unsigned int Null = 0;
- _config->Set("APT::Architecture","amd64");
+ // The tests are made for amd64. Specify a different arch here to check if
+ // they still work.
+ _config->Set("APT::Architecture",Arch);
_config->Set("APT::Build-Profiles","stage1");
const char* Depends =
@@ -47,7 +49,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag
const char* Start = Depends;
const char* End = Depends + strlen(Depends);
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
if (StripMultiArch == true)
EXPECT_EQ("debhelper", Package);
else
@@ -55,7 +57,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag
EXPECT_EQ("5.0", Version);
EXPECT_EQ(Null | pkgCache::Dep::GreaterEq, Op);
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
if (StripMultiArch == true)
EXPECT_EQ("libdb-dev", Package);
else
@@ -63,7 +65,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag
EXPECT_EQ("", Version);
EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op);
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
if (StripMultiArch == true)
EXPECT_EQ("gettext", Package);
else
@@ -71,7 +73,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag
EXPECT_EQ("0.12", Version);
EXPECT_EQ(Null | pkgCache::Dep::LessEq, Op);
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
if (StripMultiArch == true)
EXPECT_EQ("libcurl4-gnutls-dev", Package);
else
@@ -79,160 +81,160 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag
EXPECT_EQ("", Version);
EXPECT_EQ(Null | pkgCache::Dep::Or, Op);
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("libcurl3-gnutls-dev", Package);
EXPECT_EQ("7.15.5", Version);
EXPECT_EQ(Null | pkgCache::Dep::Greater, Op);
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("docbook-xml", Package);
EXPECT_EQ("", Version);
EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op);
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("apt", Package);
EXPECT_EQ("0.7.25", Version);
EXPECT_EQ(Null | pkgCache::Dep::GreaterEq, Op);
if (ParseArchFlags == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("", Package); // not-for-me
} else {
- EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseArchFlags == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("only-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));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseArchFlags == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("any-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));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseArchFlags == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("not-for-darwin", 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));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseArchFlags == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("cpu-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));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseArchFlags == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("os-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));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseArchFlags == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
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));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseArchFlags == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("", Package); // libc-not-for-me
} else {
- EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseArchFlags == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("", Package); // cpu-not-for-me
} else {
- EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseArchFlags == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("", Package); // os-not-for-me
} else {
- EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseRestrictionsList == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("", Package); // not-in-stage1
} else {
- EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseRestrictionsList == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("", Package); // not-stage1-and-not-nodoc
} else {
- EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseRestrictionsList == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("not-stage1-or-not-nodoc", Package);
} else {
- EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
if (ParseRestrictionsList == true) {
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
EXPECT_EQ("", Package); // unknown-profile
} else {
- EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64"));
Start = strstr(Start, ",");
Start++;
}
- Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
if (StripMultiArch == true)
EXPECT_EQ("overlord-dev", Package);
else
@@ -240,7 +242,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag
EXPECT_EQ("7.15.3~", Version);
EXPECT_EQ(Null | pkgCache::Dep::Equals | pkgCache::Dep::Or, Op);
- debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList, "amd64");
if (StripMultiArch == true)
EXPECT_EQ("overlord-dev", Package);
else
@@ -262,7 +264,8 @@ test:
SCOPED_TRACE(std::string("StripMultiArch: ") + (StripMultiArch ? "true" : "false"));
SCOPED_TRACE(std::string("ParseArchFlags: ") + (ParseArchFlags ? "true" : "false"));
SCOPED_TRACE(std::string("ParseRestrictionsList: ") + (ParseRestrictionsList ? "true" : "false"));
- parseDependency(StripMultiArch, ParseArchFlags, ParseRestrictionsList);
+ parseDependency(StripMultiArch, ParseArchFlags, ParseRestrictionsList, "kfreebsd-i386");
+ parseDependency(StripMultiArch, ParseArchFlags, ParseRestrictionsList, "amd64");
}
if (StripMultiArch == false) {
if (ParseArchFlags == false)