aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-31 13:05:54 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-31 13:05:54 +0100
commitb94aea3834f92fded197f4f5de61774cfdf22136 (patch)
treecc01df9e9f6a5c012aa076418d189b8f80bcfbb7
parent52d4cbb8a802dc023d7e2e554350dd7f0aae5122 (diff)
downloadpaludis-b94aea3834f92fded197f4f5de61774cfdf22136.tar.gz
paludis-b94aea3834f92fded197f4f5de61774cfdf22136.tar.xz
Handle --disable-pbins better
-rw-r--r--paludis/tar_merger.cc6
-rw-r--r--paludis/tar_merger_TEST.cc38
2 files changed, 44 insertions, 0 deletions
diff --git a/paludis/tar_merger.cc b/paludis/tar_merger.cc
index 11f5edc..41a1e0d 100644
--- a/paludis/tar_merger.cc
+++ b/paludis/tar_merger.cc
@@ -32,6 +32,8 @@
#include <dlfcn.h>
#include <stdint.h>
+#include "config.h"
+
#define STUPID_CAST(type, val) reinterpret_cast<type>(reinterpret_cast<uintptr_t>(val))
using namespace paludis;
@@ -56,6 +58,10 @@ namespace
TarMergerHandle()
{
+#if ! ENABLE_PBINS
+ throw NotAvailableError("Paludis was built without support for pbins");
+#endif
+
handle = ::dlopen(("libpaludistarextras_" + stringify(PALUDIS_PC_SLOT) + ".so").c_str(), RTLD_NOW | RTLD_GLOBAL);
if (! handle)
throw MergerError("Unable to open libpaludistarextras due to error '" + stringify(::dlerror()) + "' from dlopen");
diff --git a/paludis/tar_merger_TEST.cc b/paludis/tar_merger_TEST.cc
index 7ea8091..41eed1c 100644
--- a/paludis/tar_merger_TEST.cc
+++ b/paludis/tar_merger_TEST.cc
@@ -30,6 +30,8 @@
#include <test/test_framework.hh>
#include <test/test_runner.hh>
+#include "config.h"
+
using namespace paludis;
using namespace test;
@@ -80,6 +82,8 @@ namespace
namespace test_cases
{
+#if ENABLE_PBINS
+
struct SimpleTarMergerTest : TestCase
{
SimpleTarMergerTest() : TestCase("simple tar merge") { }
@@ -136,5 +140,39 @@ namespace test_cases
TEST_CHECK((FSEntry("tar_merger_TEST_dir") / "simple_extract" / "badsym").readlink() == "nothing");
}
} test_simple_tar_merger;
+
+#else
+
+ struct TarMergerNotAvailable : TestCase
+ {
+ TarMergerNotAvailable() : TestCase("tar merger not available") { }
+
+ void run()
+ {
+ auto output(FSEntry("tar_merger_TEST_dir") / "simple.tar");
+
+ TestEnvironment env;
+ TestTarMerger merger(make_named_values<TarMergerParams>(
+ n::compression() = tmc_none,
+ n::environment() = &env,
+ n::fix_mtimes_before() = Timestamp(0, 0),
+ n::get_new_ids_or_minus_one() = &get_new_ids_or_minus_one,
+ n::image() = FSEntry("tar_merger_TEST_dir") / "simple",
+ n::install_under() = FSEntry("/"),
+ n::merged_entries() = std::make_shared<FSEntrySet>(),
+ n::no_chown() = true,
+ n::options() = MergerOptions(),
+ n::root() = FSEntry("/"),
+ n::tar_file() = output
+ ));
+
+ TEST_CHECK(! output.is_regular_file());
+
+ TEST_CHECK_THROWS(merger.merge(), NotAvailableError);
+ }
+ } test_tar_merger_not_available;
+
+#endif
+
}