diff options
author | David Kalnischkies <david@kalnischkies.de> | 2016-05-27 12:08:32 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2016-05-27 14:08:44 +0200 |
commit | 124e6916b7b02984803ff8217e8163947aae2882 (patch) | |
tree | c1eb71e8091c5d21fa757e5b94bcb82a3294c17f /test/libapt/fileutl_test.cc | |
parent | cb6020cdfea3d6dec6f6ad13843ab46f0c10d562 (diff) |
fix and document on the fly compressor config
libapt allows to configure compressors to be used by its system via
configuration implemented in 03bef78461c6f443187b60799402624326843396,
but that was never really documented and also only partly working, which
also explains why the tests weren't using it…
Diffstat (limited to 'test/libapt/fileutl_test.cc')
-rw-r--r-- | test/libapt/fileutl_test.cc | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc index 607c4a195..8cd5132ce 100644 --- a/test/libapt/fileutl_test.cc +++ b/test/libapt/fileutl_test.cc @@ -4,7 +4,9 @@ #include <apt-pkg/fileutl.h> #include <apt-pkg/strutl.h> #include <apt-pkg/aptconfiguration.h> +#include <apt-pkg/configuration.h> +#include <algorithm> #include <string> #include <vector> #include <stdlib.h> @@ -162,26 +164,34 @@ static void TestFileFd(mode_t const a_umask, mode_t const ExpectedFilePermission static void TestFileFd(unsigned int const filemode) { - std::vector<APT::Configuration::Compressor> compressors = APT::Configuration::getCompressors(); - - // testing the (un)compress via pipe, as the 'real' compressors are usually built in via libraries - compressors.push_back(APT::Configuration::Compressor("rev", ".reversed", "rev", NULL, NULL, 42)); - //compressors.push_back(APT::Configuration::Compressor("cat", ".ident", "cat", NULL, NULL, 42)); - - for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin(); c != compressors.end(); ++c) + auto const compressors = APT::Configuration::getCompressors(); + EXPECT_EQ(7, compressors.size()); + bool atLeastOneWasTested = false; + for (auto const &c: compressors) { if ((filemode & FileFd::ReadWrite) == FileFd::ReadWrite && - (c->Name.empty() != true && c->Binary.empty() != true)) + (c.Name.empty() != true && c.Binary.empty() != true)) continue; - TestFileFd(0002, 0664, filemode, *c); - TestFileFd(0022, 0644, filemode, *c); - TestFileFd(0077, 0600, filemode, *c); - TestFileFd(0026, 0640, filemode, *c); + atLeastOneWasTested = true; + TestFileFd(0002, 0664, filemode, c); + TestFileFd(0022, 0644, filemode, c); + TestFileFd(0077, 0600, filemode, c); + TestFileFd(0026, 0640, filemode, c); } + EXPECT_TRUE(atLeastOneWasTested); } TEST(FileUtlTest, FileFD) { + // testing the (un)compress via pipe, as the 'real' compressors are usually built in via libraries + _config->Set("APT::Compressor::rev::Name", "rev"); + _config->Set("APT::Compressor::rev::Extension", ".reversed"); + _config->Set("APT::Compressor::rev::Binary", "rev"); + _config->Set("APT::Compressor::rev::Cost", 10); + auto const compressors = APT::Configuration::getCompressors(false); + EXPECT_EQ(7, compressors.size()); + EXPECT_TRUE(std::any_of(compressors.begin(), compressors.end(), [](APT::Configuration::Compressor const &c) { return c.Name == "rev"; })); + std::string const startdir = SafeGetCWD(); EXPECT_FALSE(startdir.empty()); std::string tempdir; |