summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2013-05-04 14:37:46 +0100
committerRoger Leigh <rleigh@debian.org>2013-05-04 17:17:18 +0100
commitc1d2866451b6491c632e4d90979f01099d3a1070 (patch)
tree76ab062ce960a5a7d112eb6252e1b2878b05e294 /test
parent979ab50a59bb3a78722e46ec71f1079cb7821b12 (diff)
downloadschroot-c1d2866451b6491c632e4d90979f01099d3a1070.tar.gz
test: Use chroot factory rather than specific classes
Diffstat (limited to 'test')
-rw-r--r--test/sbuild/chroot/block-device.cc50
-rw-r--r--test/sbuild/chroot/btrfs-snapshot.cc52
-rw-r--r--test/sbuild/chroot/chroot.cc63
-rw-r--r--test/sbuild/chroot/chroot.h18
-rw-r--r--test/sbuild/chroot/custom.cc43
-rw-r--r--test/sbuild/chroot/directory.cc48
-rw-r--r--test/sbuild/chroot/facet/userdata.cc1
-rw-r--r--test/sbuild/chroot/file.cc48
-rw-r--r--test/sbuild/chroot/loopback.cc47
-rw-r--r--test/sbuild/chroot/lvm-snapshot.cc38
-rw-r--r--test/sbuild/chroot/plain.cc29
11 files changed, 138 insertions, 299 deletions
diff --git a/test/sbuild/chroot/block-device.cc b/test/sbuild/chroot/block-device.cc
index 5f2a99bf..715ad505 100644
--- a/test/sbuild/chroot/block-device.cc
+++ b/test/sbuild/chroot/block-device.cc
@@ -21,7 +21,6 @@
#include <algorithm>
#include <set>
-#include <sbuild/chroot/block-device.h>
#include <sbuild/chroot/facet/block-device.h>
#include <sbuild/chroot/facet/mountable.h>
#include <sbuild/i18n.h>
@@ -35,18 +34,7 @@ using namespace CppUnit;
using sbuild::_;
-class chroot_block_device : public sbuild::chroot::block_device
-{
-public:
- chroot_block_device():
- sbuild::chroot::block_device()
- {}
-
- virtual ~chroot_block_device()
- {}
-};
-
-class test_chroot_block_device : public test_chroot_base<chroot_block_device>
+class test_chroot_block_device : public test_chroot_base
{
CPPUNIT_TEST_SUITE(test_chroot_block_device);
CPPUNIT_TEST(test_device);
@@ -74,12 +62,12 @@ class test_chroot_block_device : public test_chroot_base<chroot_block_device>
public:
test_chroot_block_device():
- test_chroot_base<chroot_block_device>()
+ test_chroot_base("block-device")
{}
void setUp()
{
- test_chroot_base<chroot_block_device>::setUp();
+ test_chroot_base::setUp();
CPPUNIT_ASSERT(chroot);
CPPUNIT_ASSERT(session);
CPPUNIT_ASSERT(!source);
@@ -94,11 +82,9 @@ public:
virtual void setup_chroot_props (sbuild::chroot::chroot::ptr& chroot)
{
- test_chroot_base<chroot_block_device>::setup_chroot_props(chroot);
-
- std::shared_ptr<sbuild::chroot::block_device> c = std::dynamic_pointer_cast<sbuild::chroot::block_device>(chroot);
+ test_chroot_base::setup_chroot_props(chroot);
- c->get_facet_strict<sbuild::chroot::facet::block_device>()->set_device("/dev/testdev");
+ chroot->get_facet_strict<sbuild::chroot::facet::block_device>()->set_device("/dev/testdev");
sbuild::chroot::facet::mountable::ptr pmnt(chroot->get_facet<sbuild::chroot::facet::mountable>());
CPPUNIT_ASSERT(pmnt);
@@ -110,10 +96,8 @@ public:
void
test_device()
{
- std::shared_ptr<sbuild::chroot::block_device> c = std::dynamic_pointer_cast<sbuild::chroot::block_device>(chroot);
- CPPUNIT_ASSERT(c);
- c->get_facet_strict<sbuild::chroot::facet::block_device>()->set_device("/dev/some/device");
- CPPUNIT_ASSERT(c->get_facet_strict<sbuild::chroot::facet::block_device>()->get_device() == "/dev/some/device");
+ chroot->get_facet_strict<sbuild::chroot::facet::block_device>()->set_device("/dev/some/device");
+ CPPUNIT_ASSERT(chroot->get_facet_strict<sbuild::chroot::facet::block_device>()->get_device() == "/dev/some/device");
}
void
@@ -157,7 +141,7 @@ public:
expected.add("CHROOT_UNION_TYPE", "none");
#endif // SBUILD_FEATURE_UNION
- test_chroot_base<chroot_block_device>::test_setup_env(chroot, expected);
+ test_chroot_base::test_setup_env(chroot, expected);
}
void test_setup_env_session()
@@ -174,7 +158,7 @@ public:
#ifdef SBUILD_FEATURE_UNION
expected.add("CHROOT_UNION_TYPE", "none");
#endif // SBUILD_FEATURE_UNION
- test_chroot_base<chroot_block_device>::test_setup_env(session, expected);
+ test_chroot_base::test_setup_env(session, expected);
}
#ifdef SBUILD_FEATURE_UNION
@@ -190,7 +174,7 @@ public:
expected.add("CHROOT_UNION_OVERLAY_DIRECTORY", "/overlay");
expected.add("CHROOT_UNION_UNDERLAY_DIRECTORY", "/underlay");
- test_chroot_base<chroot_block_device>::test_setup_env(chroot_union, expected);
+ test_chroot_base::test_setup_env(chroot_union, expected);
}
void test_setup_env_session_union()
@@ -208,7 +192,7 @@ public:
expected.add("CHROOT_UNION_MOUNT_OPTIONS", "union-mount-options");
expected.add("CHROOT_UNION_OVERLAY_DIRECTORY", "/overlay/test-union-session-name");
expected.add("CHROOT_UNION_UNDERLAY_DIRECTORY", "/underlay/test-union-session-name");
- test_chroot_base<chroot_block_device>::test_setup_env(session_union, expected);
+ test_chroot_base::test_setup_env(session_union, expected);
}
void test_setup_env_source_union()
@@ -222,7 +206,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "true");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_block_device>::test_setup_env(source_union, expected);
+ test_chroot_base::test_setup_env(source_union, expected);
}
#endif // SBUILD_FEATURE_UNION
@@ -243,7 +227,7 @@ public:
#ifdef SBUILD_FEATURE_UNION
setup_keyfile_union_unconfigured(expected, group);
#endif
- test_chroot_base<chroot_block_device>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot, expected, group);
}
@@ -262,7 +246,7 @@ public:
setup_keyfile_union_unconfigured(expected, group);
#endif
- test_chroot_base<chroot_block_device>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session, expected, group);
}
@@ -276,7 +260,7 @@ public:
setup_keyfile_source(expected, group);
setup_keyfile_block(expected, group);
- test_chroot_base<chroot_block_device>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot_union, expected, group);
}
@@ -293,7 +277,7 @@ public:
setup_keyfile_session_clone(expected, group);
setup_keyfile_union_session(expected, group);
- test_chroot_base<chroot_block_device>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session_union, expected, group);
}
@@ -306,7 +290,7 @@ public:
setup_keyfile_block(expected, group);
expected.set_value(group, "description", chroot->get_description() + ' ' + _("(source chroot)"));
- test_chroot_base<chroot_block_device>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(source_union, expected, group);
}
#endif // SBUILD_FEATURE_UNION
diff --git a/test/sbuild/chroot/btrfs-snapshot.cc b/test/sbuild/chroot/btrfs-snapshot.cc
index 164f5c90..c1bf6edd 100644
--- a/test/sbuild/chroot/btrfs-snapshot.cc
+++ b/test/sbuild/chroot/btrfs-snapshot.cc
@@ -18,7 +18,6 @@
#include <config.h>
-#include <sbuild/chroot/btrfs-snapshot.h>
#include <sbuild/chroot/facet/btrfs-snapshot.h>
#include <sbuild/i18n.h>
#include <sbuild/keyfile-writer.h>
@@ -35,18 +34,7 @@ using namespace CppUnit;
using sbuild::_;
-class chroot_btrfs_snapshot : public sbuild::chroot::btrfs_snapshot
-{
-public:
- chroot_btrfs_snapshot():
- sbuild::chroot::btrfs_snapshot()
- {}
-
- virtual ~chroot_btrfs_snapshot()
- {}
-};
-
-class test_chroot_btrfs_snapshot : public test_chroot_base<chroot_btrfs_snapshot>
+class test_chroot_btrfs_snapshot : public test_chroot_base
{
CPPUNIT_TEST_SUITE(test_chroot_btrfs_snapshot);
CPPUNIT_TEST(test_source_subvolume);
@@ -72,12 +60,12 @@ class test_chroot_btrfs_snapshot : public test_chroot_base<chroot_btrfs_snapshot
public:
test_chroot_btrfs_snapshot():
- test_chroot_base<chroot_btrfs_snapshot>()
+ test_chroot_base("btrfs-snapshot")
{}
void setUp()
{
- test_chroot_base<chroot_btrfs_snapshot>::setUp();
+ test_chroot_base::setUp();
CPPUNIT_ASSERT(chroot);
CPPUNIT_ASSERT(session);
CPPUNIT_ASSERT(source);
@@ -86,9 +74,7 @@ public:
virtual void setup_chroot_props (sbuild::chroot::chroot::ptr& chroot)
{
- test_chroot_base<chroot_btrfs_snapshot>::setup_chroot_props(chroot);
-
- std::shared_ptr<sbuild::chroot::btrfs_snapshot> c = std::dynamic_pointer_cast<sbuild::chroot::btrfs_snapshot>(chroot);
+ test_chroot_base::setup_chroot_props(chroot);
sbuild::chroot::facet::btrfs_snapshot::ptr bfac = chroot->get_facet_strict<sbuild::chroot::facet::btrfs_snapshot>();
bfac->set_source_subvolume("/srv/chroot/sid");
@@ -98,8 +84,6 @@ public:
void
test_source_subvolume()
{
- std::shared_ptr<sbuild::chroot::btrfs_snapshot> c = std::dynamic_pointer_cast<sbuild::chroot::btrfs_snapshot>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::btrfs_snapshot::ptr bfac = chroot->get_facet_strict<sbuild::chroot::facet::btrfs_snapshot>();
bfac->set_source_subvolume("/srv/chroot/chroot");
CPPUNIT_ASSERT(bfac->get_source_subvolume() == "/srv/chroot/chroot");
@@ -108,8 +92,6 @@ public:
void
test_snapshot_directory()
{
- std::shared_ptr<sbuild::chroot::btrfs_snapshot> c = std::dynamic_pointer_cast<sbuild::chroot::btrfs_snapshot>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::btrfs_snapshot::ptr bfac = chroot->get_facet_strict<sbuild::chroot::facet::btrfs_snapshot>();
bfac->set_snapshot_directory("/srv/chroot/snapshot2");
CPPUNIT_ASSERT(bfac->get_snapshot_directory() == "/srv/chroot/snapshot2");
@@ -118,8 +100,6 @@ public:
void
test_snapshot_name()
{
- std::shared_ptr<sbuild::chroot::btrfs_snapshot> c = std::dynamic_pointer_cast<sbuild::chroot::btrfs_snapshot>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::btrfs_snapshot::ptr bfac = chroot->get_facet_strict<sbuild::chroot::facet::btrfs_snapshot>();
bfac->set_snapshot_directory("/srv/chroot/snapshot2/test-session-id");
CPPUNIT_ASSERT(bfac->get_snapshot_directory() == "/srv/chroot/snapshot2/test-session-id");
@@ -128,8 +108,6 @@ public:
void
test_source_subvolume_error()
{
- std::shared_ptr<sbuild::chroot::btrfs_snapshot> c = std::dynamic_pointer_cast<sbuild::chroot::btrfs_snapshot>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::btrfs_snapshot::ptr bfac = chroot->get_facet_strict<sbuild::chroot::facet::btrfs_snapshot>();
bfac->set_source_subvolume("chroot/invalid");
}
@@ -137,8 +115,6 @@ public:
void
test_snapshot_directory_error()
{
- std::shared_ptr<sbuild::chroot::btrfs_snapshot> c = std::dynamic_pointer_cast<sbuild::chroot::btrfs_snapshot>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::btrfs_snapshot::ptr bfac = chroot->get_facet_strict<sbuild::chroot::facet::btrfs_snapshot>();
bfac->set_snapshot_directory("chroot/invalid");
}
@@ -146,8 +122,6 @@ public:
void
test_snapshot_name_error()
{
- std::shared_ptr<sbuild::chroot::btrfs_snapshot> c = std::dynamic_pointer_cast<sbuild::chroot::btrfs_snapshot>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::btrfs_snapshot::ptr bfac = chroot->get_facet_strict<sbuild::chroot::facet::btrfs_snapshot>();
bfac->set_snapshot_name("invalid");
}
@@ -175,13 +149,11 @@ public:
expected.add("CHROOT_SESSION_CREATE", "true");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_btrfs_snapshot>::test_setup_env(chroot, expected);
+ test_chroot_base::test_setup_env(chroot, expected);
}
void test_setup_env_session()
{
- std::shared_ptr<sbuild::chroot::btrfs_snapshot> c = std::dynamic_pointer_cast<sbuild::chroot::btrfs_snapshot>(chroot);
-
sbuild::environment expected;
setup_env_gen(expected);
expected.add("CHROOT_TYPE", "btrfs-snapshot");
@@ -195,7 +167,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "false");
expected.add("CHROOT_SESSION_PURGE", "true");
- test_chroot_base<chroot_btrfs_snapshot>::test_setup_env(session, expected);
+ test_chroot_base::test_setup_env(session, expected);
}
void test_setup_env_source()
@@ -210,7 +182,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "true");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_btrfs_snapshot>::test_setup_env(source, expected);
+ test_chroot_base::test_setup_env(source, expected);
}
void test_setup_env_session_source()
@@ -225,7 +197,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "true");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_btrfs_snapshot>::test_setup_env(source, expected);
+ test_chroot_base::test_setup_env(source, expected);
}
void setup_keyfile_btrfs(sbuild::keyfile &expected, std::string group)
@@ -243,7 +215,7 @@ public:
expected.set_value(group, "btrfs-source-subvolume", "/srv/chroot/sid");
expected.set_value(group, "btrfs-snapshot-directory", "/srv/chroot/snapshot");
- test_chroot_base<chroot_btrfs_snapshot>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot,expected, chroot->get_name());
}
@@ -261,7 +233,7 @@ public:
expected.set_value(group, "btrfs-snapshot-name", "/srv/chroot/snapshot/test-session-name");
expected.set_value(group, "mount-location", "/mnt/mount-location");
- test_chroot_base<chroot_btrfs_snapshot>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session, expected, group);
}
@@ -277,7 +249,7 @@ public:
expected.set_value(group, "directory", "/srv/chroot/sid");
setup_keyfile_source_clone(expected, group);
- test_chroot_base<chroot_btrfs_snapshot>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(source, expected, group);
}
@@ -294,7 +266,7 @@ public:
expected.set_value(group, "mount-location", "/mnt/mount-location");
setup_keyfile_session_source_clone(expected, group);
- test_chroot_base<chroot_btrfs_snapshot>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session_source, expected, group);
}
diff --git a/test/sbuild/chroot/chroot.cc b/test/sbuild/chroot/chroot.cc
index a11056d7..0ae6eae7 100644
--- a/test/sbuild/chroot/chroot.cc
+++ b/test/sbuild/chroot/chroot.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/storage.h>
#include <sbuild/keyfile-writer.h>
@@ -90,36 +91,21 @@ public:
}
};
-class basic_chroot : public sbuild::chroot::chroot
+namespace
{
-public:
- basic_chroot ():
- sbuild::chroot::chroot()
- {
- add_facet(test_chroot_facet::create());
- }
-
- virtual ~basic_chroot()
- {}
-
- virtual ptr
- clone () const
- { return ptr(new basic_chroot(*this)); }
- virtual ptr
- clone_session (std::string const& session_id,
- std::string const& alias,
- std::string const& user,
- bool root) const
- { return ptr(); }
+ sbuild::chroot::facet::factory::facet_info test_info =
+ {
+ "test",
+ "Support for ‘test’ chroots",
+ []() -> sbuild::chroot::facet::facet::ptr { return test_chroot_facet::create(); }
+ };
+ sbuild::chroot::facet::factory test_register(test_info);
- chroot::ptr
- clone_source () const
- { return ptr(); }
-};
+}
-class test_chroot : public test_chroot_base<basic_chroot>
+class test_chroot : public test_chroot_base
{
CPPUNIT_TEST_SUITE(test_chroot);
CPPUNIT_TEST(test_name);
@@ -145,7 +131,7 @@ class test_chroot : public test_chroot_base<basic_chroot>
public:
test_chroot():
- test_chroot_base<basic_chroot>()
+ test_chroot_base("test")
{
}
@@ -237,7 +223,7 @@ public:
expected.set_value(group, "profile", "");
expected.set_value(group, "script-config", "desktop/config");
- test_chroot_base<basic_chroot>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot, expected, group);
}
@@ -261,45 +247,38 @@ public:
sbuild::environment observed;
chroot->setup_env(observed);
- test_chroot_base<basic_chroot>::test_setup_env(observed, expected);
+ test_chroot_base::test_setup_env(observed, expected);
}
}
void test_run_setup_scripts()
{
- std::shared_ptr<basic_chroot> c = std::dynamic_pointer_cast<basic_chroot>(chroot);
-
CPPUNIT_ASSERT(chroot->get_run_setup_scripts() == true);
}
void test_verbose()
{
- std::shared_ptr<basic_chroot> c = std::dynamic_pointer_cast<basic_chroot>(chroot);
-
CPPUNIT_ASSERT(chroot->get_verbosity() == sbuild::chroot::chroot::VERBOSITY_QUIET);
- c->set_verbosity(sbuild::chroot::chroot::VERBOSITY_VERBOSE);
+ chroot->set_verbosity(sbuild::chroot::chroot::VERBOSITY_VERBOSE);
CPPUNIT_ASSERT(chroot->get_verbosity() == sbuild::chroot::chroot::VERBOSITY_VERBOSE);
CPPUNIT_ASSERT(std::string(chroot->get_verbosity_string()) == "verbose");
- c->set_verbosity("normal");
+ chroot->set_verbosity("normal");
CPPUNIT_ASSERT(chroot->get_verbosity() == sbuild::chroot::chroot::VERBOSITY_NORMAL);
CPPUNIT_ASSERT(std::string(chroot->get_verbosity_string()) == "normal");
}
void test_preserve_environment()
{
- std::shared_ptr<basic_chroot> c = std::dynamic_pointer_cast<basic_chroot>(chroot);
-
CPPUNIT_ASSERT(chroot->get_preserve_environment() == false);
- c->set_preserve_environment(true);
+ chroot->set_preserve_environment(true);
CPPUNIT_ASSERT(chroot->get_preserve_environment() == true);
- c->set_preserve_environment(false);
+ chroot->set_preserve_environment(false);
CPPUNIT_ASSERT(chroot->get_preserve_environment() == false);
}
void test_verbose_error()
{
- std::shared_ptr<basic_chroot> c = std::dynamic_pointer_cast<basic_chroot>(chroot);
- c->set_verbosity("invalid");
+ chroot->set_verbosity("invalid");
}
void test_chroot_type()
@@ -321,7 +300,7 @@ public:
sbuild::environment observed;
chroot->setup_env(observed);
- test_chroot_base<basic_chroot>::test_setup_env(observed, expected);
+ test_chroot_base::test_setup_env(observed, expected);
}
void test_setup_keyfile()
@@ -331,7 +310,7 @@ public:
setup_keyfile_chroot(expected, group);
expected.set_value(group, "type", "test");
- test_chroot_base<basic_chroot>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot, expected, group);
}
diff --git a/test/sbuild/chroot/chroot.h b/test/sbuild/chroot/chroot.h
index aae9eae1..cd1da652 100644
--- a/test/sbuild/chroot/chroot.h
+++ b/test/sbuild/chroot/chroot.h
@@ -46,10 +46,10 @@
using namespace CppUnit;
using sbuild::_;
-template <class T>
class test_chroot_base : public TestFixture
{
protected:
+ std::string type;
sbuild::chroot::chroot::ptr chroot;
sbuild::chroot::chroot::ptr session;
sbuild::chroot::chroot::ptr source;
@@ -63,9 +63,19 @@ protected:
std::string abs_testdata_dir;
public:
- test_chroot_base():
+ test_chroot_base(std::string const& type):
TestFixture(),
+ type(type),
chroot(),
+ session(),
+ source(),
+ session_source(),
+#ifdef SBUILD_FEATURE_UNION
+ chroot_union(),
+ session_union(),
+ source_union(),
+ session_source_union(),
+#endif // SBUILD_FEATURE_UNION
abs_testdata_dir()
{
abs_testdata_dir = sbuild::getcwd();
@@ -78,7 +88,7 @@ public:
void setUp()
{
// Create new chroot
- this->chroot = sbuild::chroot::chroot::ptr(new T);
+ this->chroot = sbuild::chroot::chroot::create(type);
CPPUNIT_ASSERT(this->chroot);
CPPUNIT_ASSERT(!(static_cast<bool>(this->chroot->template get_facet<sbuild::chroot::facet::session>())));
@@ -136,7 +146,7 @@ public:
}
#ifdef SBUILD_FEATURE_UNION
- this->chroot_union = sbuild::chroot::chroot::ptr(new T);
+ this->chroot_union = sbuild::chroot::chroot::create(type);
sbuild::chroot::facet::fsunion::ptr un =
this->chroot_union->template get_facet<sbuild::chroot::facet::fsunion>();
if (!un)
diff --git a/test/sbuild/chroot/custom.cc b/test/sbuild/chroot/custom.cc
index aa57c984..f3fedccb 100644
--- a/test/sbuild/chroot/custom.cc
+++ b/test/sbuild/chroot/custom.cc
@@ -19,7 +19,6 @@
#include <config.h>
#include <sbuild/config.h>
-#include <sbuild/chroot/custom.h>
#include <sbuild/chroot/facet/custom.h>
#include <sbuild/chroot/facet/session-clonable.h>
#include <sbuild/chroot/facet/source-clonable.h>
@@ -35,18 +34,7 @@
using namespace CppUnit;
-class chroot_custom : public sbuild::chroot::custom
-{
-public:
- chroot_custom():
- sbuild::chroot::custom()
- {}
-
- virtual ~chroot_custom()
- {}
-};
-
-class test_chroot_custom : public test_chroot_base<chroot_custom>
+class test_chroot_custom : public test_chroot_base
{
CPPUNIT_TEST_SUITE(test_chroot_custom);
CPPUNIT_TEST(test_directory);
@@ -64,12 +52,12 @@ class test_chroot_custom : public test_chroot_base<chroot_custom>
public:
test_chroot_custom():
- test_chroot_base<chroot_custom>()
+ test_chroot_base("custom")
{}
void setUp()
{
- test_chroot_base<chroot_custom>::setUp();
+ test_chroot_base::setUp();
CPPUNIT_ASSERT(chroot);
CPPUNIT_ASSERT(session);
CPPUNIT_ASSERT(!source);
@@ -78,11 +66,9 @@ public:
virtual void setup_chroot_props (sbuild::chroot::chroot::ptr& chroot)
{
- test_chroot_base<chroot_custom>::setup_chroot_props(chroot);
-
- std::shared_ptr<sbuild::chroot::custom> c = std::dynamic_pointer_cast<sbuild::chroot::custom>(chroot);
+ test_chroot_base::setup_chroot_props(chroot);
- sbuild::chroot::facet::userdata::ptr userdata = c->get_facet<sbuild::chroot::facet::userdata>();
+ sbuild::chroot::facet::userdata::ptr userdata = chroot->get_facet<sbuild::chroot::facet::userdata>();
CPPUNIT_ASSERT(userdata);
userdata->set_data("custom.directory", "/srv/chroots/sid");
userdata->set_data("custom.options", "foobar");
@@ -91,8 +77,6 @@ public:
void
test_directory()
{
- std::shared_ptr<sbuild::chroot::custom> c = std::dynamic_pointer_cast<sbuild::chroot::custom>(chroot);
- CPPUNIT_ASSERT(c);
CPPUNIT_ASSERT(chroot->get_path() == "/mnt/mount-location");
CPPUNIT_ASSERT(chroot->get_mount_location() == "/mnt/mount-location");
}
@@ -121,7 +105,7 @@ public:
sbuild::environment expected;
setup_env_gen(expected);
- test_chroot_base<chroot_custom>::test_setup_env(chroot, expected);
+ test_chroot_base::test_setup_env(chroot, expected);
}
void test_setup_keyfile()
@@ -134,26 +118,21 @@ public:
expected.set_value(group, "custom.directory", "/srv/chroots/sid");
expected.set_value(group, "custom.options", "foobar");
- test_chroot_base<chroot_custom>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot, expected, group);
}
void test_session_flags1()
{
- std::shared_ptr<sbuild::chroot::custom> c = std::dynamic_pointer_cast<sbuild::chroot::custom>(chroot);
- CPPUNIT_ASSERT(c);
-
CPPUNIT_ASSERT(chroot->get_session_flags() ==
sbuild::chroot::chroot::SESSION_CREATE);
- CPPUNIT_ASSERT(c->get_facet<sbuild::chroot::facet::session_clonable>());
- CPPUNIT_ASSERT(!c->get_facet<sbuild::chroot::facet::source_clonable>());
+ CPPUNIT_ASSERT(chroot->get_facet<sbuild::chroot::facet::session_clonable>());
+ CPPUNIT_ASSERT(!chroot->get_facet<sbuild::chroot::facet::source_clonable>());
}
void test_session_flags2()
{
- std::shared_ptr<sbuild::chroot::custom> c = std::dynamic_pointer_cast<sbuild::chroot::custom>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::custom::ptr custp = chroot->get_facet_strict<sbuild::chroot::facet::custom>();
custp->set_session_cloneable(false);
@@ -166,8 +145,6 @@ public:
void test_session_flags3()
{
- std::shared_ptr<sbuild::chroot::custom> c = std::dynamic_pointer_cast<sbuild::chroot::custom>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::custom::ptr custp = chroot->get_facet_strict<sbuild::chroot::facet::custom>();
custp->set_source_cloneable(true);
@@ -180,8 +157,6 @@ public:
void test_session_flags4()
{
- std::shared_ptr<sbuild::chroot::custom> c = std::dynamic_pointer_cast<sbuild::chroot::custom>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::custom::ptr custp = chroot->get_facet_strict<sbuild::chroot::facet::custom>();
custp->set_session_cloneable(false);
custp->set_source_cloneable(true);
diff --git a/test/sbuild/chroot/directory.cc b/test/sbuild/chroot/directory.cc
index 90af9566..8727593c 100644
--- a/test/sbuild/chroot/directory.cc
+++ b/test/sbuild/chroot/directory.cc
@@ -18,7 +18,6 @@
#include <config.h>
-#include <sbuild/chroot/directory.h>
#include <sbuild/chroot/facet/directory.h>
#include <sbuild/i18n.h>
#include <sbuild/keyfile-writer.h>
@@ -34,18 +33,7 @@ using namespace CppUnit;
using sbuild::_;
-class chroot_directory : public sbuild::chroot::directory
-{
-public:
- chroot_directory():
- sbuild::chroot::directory()
- {}
-
- virtual ~chroot_directory()
- {}
-};
-
-class test_chroot_directory : public test_chroot_base<chroot_directory>
+class test_chroot_directory : public test_chroot_base
{
CPPUNIT_TEST_SUITE(test_chroot_directory);
CPPUNIT_TEST(test_directory);
@@ -75,12 +63,12 @@ class test_chroot_directory : public test_chroot_base<chroot_directory>
public:
test_chroot_directory():
- test_chroot_base<chroot_directory>()
+ test_chroot_base("directory")
{}
void setUp()
{
- test_chroot_base<chroot_directory>::setUp();
+ test_chroot_base::setUp();
CPPUNIT_ASSERT(chroot);
CPPUNIT_ASSERT(session);
CPPUNIT_ASSERT(!source);
@@ -95,7 +83,7 @@ public:
virtual void setup_chroot_props (sbuild::chroot::chroot::chroot::ptr& chroot)
{
- test_chroot_base<chroot_directory>::setup_chroot_props(chroot);
+ test_chroot_base::setup_chroot_props(chroot);
sbuild::chroot::facet::directory::ptr dirfac = chroot->get_facet<sbuild::chroot::facet::directory>();
CPPUNIT_ASSERT(dirfac);
@@ -106,8 +94,6 @@ public:
void
test_directory()
{
- std::shared_ptr<sbuild::chroot::directory> c = std::dynamic_pointer_cast<sbuild::chroot::directory>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::directory::ptr dirfac = chroot->get_facet<sbuild::chroot::facet::directory>();
CPPUNIT_ASSERT(dirfac);
dirfac->set_directory("/mnt/chroot/example");
@@ -143,7 +129,7 @@ public:
expected.add("CHROOT_UNION_TYPE", "none");
#endif // SBUILD_FEATURE_UNION
- test_chroot_base<chroot_directory>::test_setup_env(chroot, expected);
+ test_chroot_base::test_setup_env(chroot, expected);
}
void test_setup_env_session()
@@ -161,7 +147,7 @@ public:
expected.add("CHROOT_UNION_TYPE", "none");
#endif // SBUILD_FEATURE_UNION
- test_chroot_base<chroot_directory>::test_setup_env(session, expected);
+ test_chroot_base::test_setup_env(session, expected);
}
#ifdef SBUILD_FEATURE_UNION
@@ -178,7 +164,7 @@ public:
expected.add("CHROOT_UNION_OVERLAY_DIRECTORY", "/overlay");
expected.add("CHROOT_UNION_UNDERLAY_DIRECTORY", "/underlay");
- test_chroot_base<chroot_directory>::test_setup_env(chroot_union, expected);
+ test_chroot_base::test_setup_env(chroot_union, expected);
}
void test_setup_env_session_union()
@@ -197,7 +183,7 @@ public:
expected.add("CHROOT_UNION_OVERLAY_DIRECTORY", "/overlay/test-union-session-name");
expected.add("CHROOT_UNION_UNDERLAY_DIRECTORY", "/underlay/test-union-session-name");
- test_chroot_base<chroot_directory>::test_setup_env(session_union, expected);
+ test_chroot_base::test_setup_env(session_union, expected);
}
void test_setup_env_source_union()
@@ -210,7 +196,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "true");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_directory>::test_setup_env(source_union, expected);
+ test_chroot_base::test_setup_env(source_union, expected);
}
void test_setup_env_session_source_union()
@@ -225,7 +211,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "false");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_directory>::test_setup_env(session_source_union, expected);
+ test_chroot_base::test_setup_env(session_source_union, expected);
}
#endif // SBUILD_FEATURE_UNION
@@ -240,7 +226,7 @@ public:
setup_keyfile_union_unconfigured(expected, group);
#endif // SBUILD_FEATURE_UNION
- test_chroot_base<chroot_directory>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot, expected, group);
}
@@ -259,7 +245,7 @@ public:
setup_keyfile_union_unconfigured(expected, group);
#endif // SBUILD_FEATURE_UNION
- test_chroot_base<chroot_directory>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session, expected, group);
}
@@ -292,7 +278,7 @@ public:
setup_keyfile_union_unconfigured(expected, group);
#endif // SBUILD_FEATURE_UNION
- test_chroot_base<chroot_directory>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session, expected, group);
}
@@ -307,7 +293,7 @@ public:
expected.set_value(group, "directory", "/srv/chroot/example-chroot");
setup_keyfile_union_configured(expected, group);
- test_chroot_base<chroot_directory>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot_union, expected, group);
}
@@ -324,7 +310,7 @@ public:
setup_keyfile_session_clone(expected, group);
setup_keyfile_union_session(expected, group);
- test_chroot_base<chroot_directory>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session_union, expected, group);
}
@@ -338,7 +324,7 @@ public:
expected.set_value(group, "description", chroot->get_description() + ' ' + _("(source chroot)"));
expected.set_value(group, "directory", "/srv/chroot/example-chroot");
- test_chroot_base<chroot_directory>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(source_union, expected, group);
}
@@ -354,7 +340,7 @@ public:
expected.set_value(group, "mount-location", "/mnt/mount-location");
setup_keyfile_session_source_clone(expected, group);
- test_chroot_base<chroot_directory>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session_source_union, expected, group);
}
#endif // SBUILD_FEATURE_UNION
diff --git a/test/sbuild/chroot/facet/userdata.cc b/test/sbuild/chroot/facet/userdata.cc
index 078cc887..7cd4662f 100644
--- a/test/sbuild/chroot/facet/userdata.cc
+++ b/test/sbuild/chroot/facet/userdata.cc
@@ -18,7 +18,6 @@
#include <config.h>
-#include <sbuild/chroot/directory.h>
#include <sbuild/chroot/facet/directory.h>
#include <sbuild/chroot/facet/userdata.h>
diff --git a/test/sbuild/chroot/file.cc b/test/sbuild/chroot/file.cc
index 22b99927..737abd86 100644
--- a/test/sbuild/chroot/file.cc
+++ b/test/sbuild/chroot/file.cc
@@ -18,7 +18,6 @@
#include <config.h>
-#include <sbuild/chroot/file.h>
#include <sbuild/chroot/facet/file.h>
#include <sbuild/i18n.h>
#include <sbuild/keyfile-writer.h>
@@ -34,18 +33,7 @@ using namespace CppUnit;
using sbuild::_;
-class chroot_file : public sbuild::chroot::file
-{
-public:
- chroot_file():
- sbuild::chroot::file()
- {}
-
- virtual ~chroot_file()
- {}
-};
-
-class test_chroot_file : public test_chroot_base<chroot_file>
+class test_chroot_file : public test_chroot_base
{
CPPUNIT_TEST_SUITE(test_chroot_file);
CPPUNIT_TEST(test_file);
@@ -69,12 +57,12 @@ class test_chroot_file : public test_chroot_base<chroot_file>
public:
test_chroot_file():
- test_chroot_base<chroot_file>()
+ test_chroot_base("file")
{}
void setUp()
{
- test_chroot_base<chroot_file>::setUp();
+ test_chroot_base::setUp();
CPPUNIT_ASSERT(chroot);
CPPUNIT_ASSERT(session);
CPPUNIT_ASSERT(source);
@@ -89,9 +77,7 @@ public:
virtual void setup_chroot_props (sbuild::chroot::chroot::ptr& chroot)
{
- test_chroot_base<chroot_file>::setup_chroot_props(chroot);
-
- std::shared_ptr<sbuild::chroot::file> c = std::dynamic_pointer_cast<sbuild::chroot::file>(chroot);
+ test_chroot_base::setup_chroot_props(chroot);
sbuild::chroot::facet::file::ptr filefac = chroot->get_facet_strict<sbuild::chroot::facet::file>();
filefac->set_filename("/srv/chroot/example.tar.bz2");
@@ -101,8 +87,6 @@ public:
void
test_file()
{
- std::shared_ptr<sbuild::chroot::file> c = std::dynamic_pointer_cast<sbuild::chroot::file>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::file::ptr filefac = chroot->get_facet_strict<sbuild::chroot::facet::file>();
filefac->set_filename("/srv/chroot-images/unstable.tar.gz");
CPPUNIT_ASSERT(filefac->get_filename() == "/srv/chroot-images/unstable.tar.gz");
@@ -115,7 +99,6 @@ public:
void test_location()
{
- std::shared_ptr<sbuild::chroot::file> fc = std::dynamic_pointer_cast<sbuild::chroot::file>(chroot);
sbuild::chroot::facet::file::ptr filefac = chroot->get_facet_strict<sbuild::chroot::facet::file>();
filefac->set_location("");
@@ -129,7 +112,6 @@ public:
void test_location_invalid()
{
- std::shared_ptr<sbuild::chroot::file> fc = std::dynamic_pointer_cast<sbuild::chroot::file>(chroot);
sbuild::chroot::facet::file::ptr filefac = chroot->get_facet_strict<sbuild::chroot::facet::file>();
filefac->set_location("invalid");
@@ -137,10 +119,6 @@ public:
void test_repack()
{
- std::shared_ptr<sbuild::chroot::file> fc = std::dynamic_pointer_cast<sbuild::chroot::file>(chroot);
- std::shared_ptr<sbuild::chroot::file> fss = std::dynamic_pointer_cast<sbuild::chroot::file>(session);
- std::shared_ptr<sbuild::chroot::file> fs = std::dynamic_pointer_cast<sbuild::chroot::file>(source);
-
sbuild::chroot::facet::file::ptr filechrootfac = chroot->get_facet_strict<sbuild::chroot::facet::file>();
sbuild::chroot::facet::file::ptr filesessionfac = session->get_facet_strict<sbuild::chroot::facet::file>();
sbuild::chroot::facet::file::ptr filesourcefac = source->get_facet_strict<sbuild::chroot::facet::file>();
@@ -165,7 +143,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "true");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_file>::test_setup_env(chroot, expected);
+ test_chroot_base::test_setup_env(chroot, expected);
}
void test_setup_env()
@@ -177,7 +155,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "true");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_file>::test_setup_env(chroot, expected);
+ test_chroot_base::test_setup_env(chroot, expected);
}
void test_setup_env_session()
@@ -192,7 +170,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "false");
expected.add("CHROOT_SESSION_PURGE", "true");
- test_chroot_base<chroot_file>::test_setup_env(session, expected);
+ test_chroot_base::test_setup_env(session, expected);
}
void test_setup_env_source()
@@ -205,7 +183,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "true");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_file>::test_setup_env(source, expected);
+ test_chroot_base::test_setup_env(source, expected);
}
void test_setup_env_session_source()
@@ -220,7 +198,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "false");
expected.add("CHROOT_SESSION_PURGE", "true");
- test_chroot_base<chroot_file>::test_setup_env(session_source, expected);
+ test_chroot_base::test_setup_env(session_source, expected);
}
void setup_keyfile_file(sbuild::keyfile &expected, const std::string group)
@@ -238,7 +216,7 @@ public:
setup_keyfile_source(expected, group);
setup_keyfile_file(expected, group);
- test_chroot_base<chroot_file>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot, expected, group);
}
@@ -254,7 +232,7 @@ public:
expected.set_value(group, "mount-location", "/mnt/mount-location");
setup_keyfile_session_clone(expected, group);
- test_chroot_base<chroot_file>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session, expected, group);
}
@@ -267,7 +245,7 @@ public:
setup_keyfile_file(expected, group);
expected.set_value(group, "description", chroot->get_description() + ' ' + _("(source chroot)"));
- test_chroot_base<chroot_file>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(source, expected, group);
}
@@ -282,7 +260,7 @@ public:
expected.set_value(group, "file-repack", "true");
expected.set_value(group, "mount-location", "/mnt/mount-location");
- test_chroot_base<chroot_file>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session_source, expected, group);
}
diff --git a/test/sbuild/chroot/loopback.cc b/test/sbuild/chroot/loopback.cc
index 27e10a46..fa17dd79 100644
--- a/test/sbuild/chroot/loopback.cc
+++ b/test/sbuild/chroot/loopback.cc
@@ -23,7 +23,6 @@
#include <set>
#include <iostream>
-#include <sbuild/chroot/loopback.h>
#include <sbuild/chroot/facet/loopback.h>
#include <sbuild/chroot/facet/mountable.h>
#include <sbuild/i18n.h>
@@ -37,18 +36,7 @@ using namespace CppUnit;
using sbuild::_;
-class chroot_loopback : public sbuild::chroot::loopback
-{
-public:
- chroot_loopback():
- sbuild::chroot::loopback()
- {}
-
- virtual ~chroot_loopback()
- {}
-};
-
-class test_chroot_loopback : public test_chroot_base<chroot_loopback>
+class test_chroot_loopback : public test_chroot_base
{
CPPUNIT_TEST_SUITE(test_chroot_loopback);
CPPUNIT_TEST(test_file);
@@ -80,7 +68,7 @@ protected:
public:
test_chroot_loopback():
- test_chroot_base<chroot_loopback>(),
+ test_chroot_base("loopback"),
loopback_file()
{
loopback_file = abs_testdata_dir;
@@ -89,7 +77,7 @@ public:
void setUp()
{
- test_chroot_base<chroot_loopback>::setUp();
+ test_chroot_base::setUp();
CPPUNIT_ASSERT(chroot);
CPPUNIT_ASSERT(session);
CPPUNIT_ASSERT(!source);
@@ -104,9 +92,8 @@ public:
virtual void setup_chroot_props (sbuild::chroot::chroot::ptr& chroot)
{
- test_chroot_base<chroot_loopback>::setup_chroot_props(chroot);
+ test_chroot_base::setup_chroot_props(chroot);
- std::shared_ptr<sbuild::chroot::loopback> c = std::dynamic_pointer_cast<sbuild::chroot::loopback>(chroot);
sbuild::chroot::facet::loopback::ptr loop = chroot->get_facet_strict<sbuild::chroot::facet::loopback>();
CPPUNIT_ASSERT(loop);
@@ -122,8 +109,6 @@ public:
void
test_file()
{
- std::shared_ptr<sbuild::chroot::loopback> c = std::dynamic_pointer_cast<sbuild::chroot::loopback>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::loopback::ptr loop = chroot->get_facet_strict<sbuild::chroot::facet::loopback>();
CPPUNIT_ASSERT(loop);
loop->set_filename("/dev/some/file");
@@ -163,7 +148,7 @@ public:
expected.add("CHROOT_UNION_TYPE", "none");
#endif // SBUILD_FEATURE_UNION
- test_chroot_base<chroot_loopback>::test_setup_env(chroot, expected);
+ test_chroot_base::test_setup_env(chroot, expected);
}
void test_setup_env_session()
@@ -183,7 +168,7 @@ public:
expected.add("CHROOT_UNION_TYPE", "none");
#endif // SBUILD_FEATURE_UNION
- test_chroot_base<chroot_loopback>::test_setup_env(session, expected);
+ test_chroot_base::test_setup_env(session, expected);
}
#ifdef SBUILD_FEATURE_UNION
@@ -200,7 +185,7 @@ public:
expected.add("CHROOT_UNION_OVERLAY_DIRECTORY", "/overlay");
expected.add("CHROOT_UNION_UNDERLAY_DIRECTORY", "/underlay");
- test_chroot_base<chroot_loopback>::test_setup_env(chroot_union, expected);
+ test_chroot_base::test_setup_env(chroot_union, expected);
}
void test_setup_env_session_union()
@@ -219,7 +204,7 @@ public:
expected.add("CHROOT_UNION_MOUNT_OPTIONS", "union-mount-options");
expected.add("CHROOT_UNION_OVERLAY_DIRECTORY", "/overlay/test-union-session-name");
expected.add("CHROOT_UNION_UNDERLAY_DIRECTORY", "/underlay/test-union-session-name");
- test_chroot_base<chroot_loopback>::test_setup_env(session_union, expected);
+ test_chroot_base::test_setup_env(session_union, expected);
}
void test_setup_env_source_union()
@@ -233,7 +218,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "true");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_loopback>::test_setup_env(source_union, expected);
+ test_chroot_base::test_setup_env(source_union, expected);
}
void test_setup_env_session_source_union()
@@ -250,7 +235,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "false");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_loopback>::test_setup_env(session_source_union, expected);
+ test_chroot_base::test_setup_env(session_source_union, expected);
}
#endif // SBUILD_FEATURE_UNION
@@ -272,7 +257,7 @@ public:
setup_keyfile_union_unconfigured(expected, group);
#endif // SBUILD_FEATURE_UNION
- test_chroot_base<chroot_loopback>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot, expected, group);
}
@@ -291,7 +276,7 @@ public:
setup_keyfile_union_unconfigured(expected, group);
#endif // SBUILD_FEATURE_UNION
- test_chroot_base<chroot_loopback>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session, expected, group);
}
@@ -305,7 +290,7 @@ public:
setup_keyfile_loop(expected, group);
setup_keyfile_union_configured(expected, group);
- test_chroot_base<chroot_loopback>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot_union, expected, group);
}
@@ -322,7 +307,7 @@ public:
setup_keyfile_session_clone(expected, group);
setup_keyfile_union_session(expected, group);
- test_chroot_base<chroot_loopback>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session_union, expected, group);
}
@@ -335,7 +320,7 @@ public:
setup_keyfile_loop(expected, group);
expected.set_value(group, "description", chroot->get_description() + ' ' + _("(source chroot)"));
- test_chroot_base<chroot_loopback>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(source_union, expected, group);
}
@@ -350,7 +335,7 @@ public:
expected.set_value(group, "mount-device", loopback_file);
expected.set_value(group, "mount-location", "/mnt/mount-location");
- test_chroot_base<chroot_loopback>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session_source_union, expected, group);
}
#endif // SBUILD_FEATURE_UNION
diff --git a/test/sbuild/chroot/lvm-snapshot.cc b/test/sbuild/chroot/lvm-snapshot.cc
index a9fd3ef3..963aba6b 100644
--- a/test/sbuild/chroot/lvm-snapshot.cc
+++ b/test/sbuild/chroot/lvm-snapshot.cc
@@ -18,7 +18,6 @@
#include <config.h>
-#include <sbuild/chroot/lvm-snapshot.h>
#include <sbuild/chroot/facet/lvm-snapshot.h>
#include <sbuild/chroot/facet/mountable.h>
#include <sbuild/i18n.h>
@@ -36,18 +35,7 @@ using namespace CppUnit;
using sbuild::_;
-class chroot_lvm_snapshot : public sbuild::chroot::lvm_snapshot
-{
-public:
- chroot_lvm_snapshot():
- sbuild::chroot::lvm_snapshot()
- {}
-
- virtual ~chroot_lvm_snapshot()
- {}
-};
-
-class test_chroot_lvm_snapshot : public test_chroot_base<chroot_lvm_snapshot>
+class test_chroot_lvm_snapshot : public test_chroot_base
{
CPPUNIT_TEST_SUITE(test_chroot_lvm_snapshot);
CPPUNIT_TEST(test_snapshot_device);
@@ -69,12 +57,12 @@ class test_chroot_lvm_snapshot : public test_chroot_base<chroot_lvm_snapshot>
public:
test_chroot_lvm_snapshot():
- test_chroot_base<chroot_lvm_snapshot>()
+ test_chroot_base("lvm-snapshot")
{}
void setUp()
{
- test_chroot_base<chroot_lvm_snapshot>::setUp();
+ test_chroot_base::setUp();
CPPUNIT_ASSERT(chroot);
CPPUNIT_ASSERT(session);
CPPUNIT_ASSERT(source);
@@ -83,7 +71,7 @@ public:
virtual void setup_chroot_props (sbuild::chroot::chroot::ptr& chroot)
{
- test_chroot_base<chroot_lvm_snapshot>::setup_chroot_props(chroot);
+ test_chroot_base::setup_chroot_props(chroot);
sbuild::chroot::facet::lvm_snapshot::ptr psnap(chroot->get_facet_strict<sbuild::chroot::facet::lvm_snapshot>());
@@ -139,13 +127,11 @@ public:
expected.add("CHROOT_SESSION_CREATE", "true");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_lvm_snapshot>::test_setup_env(chroot, expected);
+ test_chroot_base::test_setup_env(chroot, expected);
}
void test_setup_env_session()
{
- std::shared_ptr<sbuild::chroot::lvm_snapshot> c = std::dynamic_pointer_cast<sbuild::chroot::lvm_snapshot>(chroot);
-
sbuild::environment expected;
setup_env_gen(expected);
expected.add("CHROOT_TYPE", "lvm-snapshot");
@@ -160,7 +146,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "false");
expected.add("CHROOT_SESSION_PURGE", "true");
- test_chroot_base<chroot_lvm_snapshot>::test_setup_env(session, expected);
+ test_chroot_base::test_setup_env(session, expected);
}
void test_setup_env_source()
@@ -174,7 +160,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "true");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_lvm_snapshot>::test_setup_env(source, expected);
+ test_chroot_base::test_setup_env(source, expected);
}
void test_setup_env_session_source()
@@ -191,7 +177,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "false");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_lvm_snapshot>::test_setup_env(session_source, expected);
+ test_chroot_base::test_setup_env(session_source, expected);
}
void setup_keyfile_lvm(sbuild::keyfile &expected, std::string group)
@@ -211,7 +197,7 @@ public:
expected.set_value(group, "type", "lvm-snapshot");
expected.set_value(group, "lvm-snapshot-options", "--size 1G");
- test_chroot_base<chroot_lvm_snapshot>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot,expected, chroot->get_name());
}
@@ -230,7 +216,7 @@ public:
expected.set_value(group, "mount-device", "/dev/volgroup/test-session-name");
expected.set_value(group, "mount-location", "/mnt/mount-location");
- test_chroot_base<chroot_lvm_snapshot>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session, expected, group);
}
@@ -245,7 +231,7 @@ public:
expected.set_value(group, "aliases", "test-name-source,test-alias-1-source,test-alias-2-source");
setup_keyfile_source_clone(expected, group);
- test_chroot_base<chroot_lvm_snapshot>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(source, expected, group);
}
@@ -260,7 +246,7 @@ public:
expected.set_value(group, "mount-location", "/mnt/mount-location");
setup_keyfile_session_source_clone(expected, group);
- test_chroot_base<chroot_lvm_snapshot>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(session_source, expected, group);
}
diff --git a/test/sbuild/chroot/plain.cc b/test/sbuild/chroot/plain.cc
index 7c536735..36e0d0ad 100644
--- a/test/sbuild/chroot/plain.cc
+++ b/test/sbuild/chroot/plain.cc
@@ -20,7 +20,6 @@
#include <sbuild/config.h>
#include <sbuild/chroot/facet/plain.h>
-#include <sbuild/chroot/plain.h>
#include <sbuild/keyfile-writer.h>
#include <test/sbuild/chroot/chroot.h>
@@ -32,18 +31,7 @@
using namespace CppUnit;
-class chroot_plain : public sbuild::chroot::plain
-{
-public:
- chroot_plain():
- sbuild::chroot::plain()
- {}
-
- virtual ~chroot_plain()
- {}
-};
-
-class test_chroot_plain : public test_chroot_base<chroot_plain>
+class test_chroot_plain : public test_chroot_base
{
CPPUNIT_TEST_SUITE(test_chroot_plain);
CPPUNIT_TEST(test_directory);
@@ -57,12 +45,12 @@ class test_chroot_plain : public test_chroot_base<chroot_plain>
public:
test_chroot_plain():
- test_chroot_base<chroot_plain>()
+ test_chroot_base("plain")
{}
void setUp()
{
- test_chroot_base<chroot_plain>::setUp();
+ test_chroot_base::setUp();
CPPUNIT_ASSERT(chroot);
CPPUNIT_ASSERT(!session);
CPPUNIT_ASSERT(!source);
@@ -71,10 +59,9 @@ public:
virtual void setup_chroot_props (sbuild::chroot::chroot::ptr& chroot)
{
- test_chroot_base<chroot_plain>::setup_chroot_props(chroot);
+ test_chroot_base::setup_chroot_props(chroot);
- std::shared_ptr<sbuild::chroot::plain> c = std::dynamic_pointer_cast<sbuild::chroot::plain>(chroot);
- c->set_mount_location("");
+ chroot->set_mount_location("");
sbuild::chroot::facet::plain::ptr plfac = chroot->get_facet<sbuild::chroot::facet::plain>();
plfac->set_directory("/srv/chroot/example-chroot");
@@ -83,8 +70,6 @@ public:
void
test_directory()
{
- std::shared_ptr<sbuild::chroot::plain> c = std::dynamic_pointer_cast<sbuild::chroot::plain>(chroot);
- CPPUNIT_ASSERT(c);
sbuild::chroot::facet::plain::ptr plfac = chroot->get_facet<sbuild::chroot::facet::plain>();
plfac->set_directory("/mnt/mount-location/example");
CPPUNIT_ASSERT(plfac->get_directory() == "/mnt/mount-location/example");
@@ -108,7 +93,7 @@ public:
expected.add("CHROOT_SESSION_CREATE", "false");
expected.add("CHROOT_SESSION_PURGE", "false");
- test_chroot_base<chroot_plain>::test_setup_env(chroot, expected);
+ test_chroot_base::test_setup_env(chroot, expected);
}
void test_setup_keyfile()
@@ -119,7 +104,7 @@ public:
expected.set_value(group, "type", "plain");
expected.set_value(group, "directory", "/srv/chroot/example-chroot");
- test_chroot_base<chroot_plain>::test_setup_keyfile
+ test_chroot_base::test_setup_keyfile
(chroot, expected, group);
}