diff options
author | David Kalnischkies <david@kalnischkies.de> | 2016-01-26 17:42:33 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2016-01-26 17:42:33 +0100 |
commit | b7aa74a1859e3be00f3a20b0956d1cb93d62df5b (patch) | |
tree | f4fdf1cc1dc128d069056786b0f95fe72d80bbcf /test | |
parent | 2651f1c071927b7fc440ec7a638ecad7ccf04a2e (diff) |
stablize gtest testcase environment
Avoid the dependency on a specific current path for the tar test and
ensure that _system is correctly initialized (gcc-6 runs into a segfault
otherwise and with it fixed starts to depend on the multi-arch
configuration of the running system… not good).
Git-Dch: Ignore
Diffstat (limited to 'test')
-rw-r--r-- | test/libapt/extracttar_test.cc | 2 | ||||
-rw-r--r-- | test/libapt/gtest_runner.cc | 7 | ||||
-rw-r--r-- | test/libapt/indexcopytosourcelist_test.cc | 21 |
3 files changed, 26 insertions, 4 deletions
diff --git a/test/libapt/extracttar_test.cc b/test/libapt/extracttar_test.cc index b4e1fd37f..0255bd767 100644 --- a/test/libapt/extracttar_test.cc +++ b/test/libapt/extracttar_test.cc @@ -20,7 +20,7 @@ class Stream : public pkgDirStream TEST(ExtractTar, ExtractTar) { - EXPECT_EQ(system("tar c makefile | gzip > tar.tgz"), 0); + EXPECT_EQ(system("tar c /etc/passwd 2>/dev/null | gzip > tar.tgz"), 0); FileFd fd("tar.tgz", FileFd::ReadOnly); unlink("tar.tgz"); diff --git a/test/libapt/gtest_runner.cc b/test/libapt/gtest_runner.cc index 46054afa3..73854d976 100644 --- a/test/libapt/gtest_runner.cc +++ b/test/libapt/gtest_runner.cc @@ -1,10 +1,15 @@ #include <gtest/gtest.h> +#include <apt-pkg/configuration.h> +#include <apt-pkg/pkgsystem.h> #include <apt-pkg/error.h> +#include <apt-pkg/init.h> int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + if (pkgInitSystem(*_config, _system) == false) + return 42; + int const result = RUN_ALL_TESTS(); if (_error->empty() == false) { std::cerr << "The test generated the following global messages:" << std::endl; diff --git a/test/libapt/indexcopytosourcelist_test.cc b/test/libapt/indexcopytosourcelist_test.cc index 2d07dba15..eb6d49edf 100644 --- a/test/libapt/indexcopytosourcelist_test.cc +++ b/test/libapt/indexcopytosourcelist_test.cc @@ -9,9 +9,9 @@ #include <gtest/gtest.h> -class NoCopy : public IndexCopy { +class NoCopy : private IndexCopy { public: - std::string ConvertToSourceList(std::string CD,std::string Path) { + std::string ConvertToSourceList(std::string const &CD,std::string &&Path) { IndexCopy::ConvertToSourceList(CD, Path); return Path; } @@ -44,13 +44,20 @@ TEST(IndexCopyTest, ConvertToSourceList) std::string const S = Path + "source/"; std::string const List = std::string(*Release) + " " + *Component; + { + SCOPED_TRACE("no archs configured"); _config->Clear("APT"); + _config->Set("APT::Architecture", "all"); + _config->Set("APT::Architectures::", "all"); APT::Configuration::getArchitectures(false); EXPECT_EQ(A, ic.ConvertToSourceList("/media/cdrom/", CD + A)); EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B)); EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C)); EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S)); + } + { + SCOPED_TRACE("mips configured"); _config->Clear("APT"); _config->Set("APT::Architecture", "mips"); _config->Set("APT::Architectures::", "mips"); @@ -59,7 +66,10 @@ TEST(IndexCopyTest, ConvertToSourceList) EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + B)); EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C)); EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S)); + } + { + SCOPED_TRACE("kfreebsd-mips configured"); _config->Clear("APT"); _config->Set("APT::Architecture", "kfreebsd-mips"); _config->Set("APT::Architectures::", "kfreebsd-mips"); @@ -68,7 +78,10 @@ TEST(IndexCopyTest, ConvertToSourceList) EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B)); EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + C)); EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S)); + } + { + SCOPED_TRACE("armel configured"); _config->Clear("APT"); _config->Set("APT::Architecture", "armel"); _config->Set("APT::Architectures::", "armel"); @@ -77,7 +90,10 @@ TEST(IndexCopyTest, ConvertToSourceList) EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B)); EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C)); EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S)); + } + { + SCOPED_TRACE("armel+mips configured"); _config->Clear("APT"); _config->Set("APT::Architecture", "armel"); _config->Set("APT::Architectures::", "armel"); @@ -87,6 +103,7 @@ TEST(IndexCopyTest, ConvertToSourceList) EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + B)); EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C)); EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S)); + } } } } |