summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libadhocutil/unittests/Jamfile.jam25
-rw-r--r--libadhocutil/unittests/testPlugins.cpp12
-rw-r--r--libadhocutil/unittests/testPluginsRuntime.cpp34
-rw-r--r--libadhocutil/unittests/utilTestClasses.cpp5
-rw-r--r--libadhocutil/unittests/utilTestClasses.h20
5 files changed, 85 insertions, 11 deletions
diff --git a/libadhocutil/unittests/Jamfile.jam b/libadhocutil/unittests/Jamfile.jam
index ecee7d1..b4ec60a 100644
--- a/libadhocutil/unittests/Jamfile.jam
+++ b/libadhocutil/unittests/Jamfile.jam
@@ -6,6 +6,7 @@ lib boost_utf : : <name>boost_unit_test_framework ;
lib boost_filesystem ;
lib boost_system ;
lib boost_thread ;
+lib dl ;
run
testContext.cpp
@@ -119,17 +120,41 @@ run
testCache
;
+lib utilTestClasses :
+ utilTestClasses.cpp
+ : :
+ <define>BOOST_TEST_DYN_LINK
+ <library>..//adhocutil
+ <library>boost_utf
+ ;
+
run
testPlugins.cpp
: : :
<define>BOOST_TEST_DYN_LINK
<library>..//adhocutil
<library>boost_utf
+ <library>utilTestClasses
:
testPlugins
;
run
+ testPluginsRuntime.cpp
+ : : :
+ <define>ROOT=\"$(me)\"
+ <define>BOOST_TEST_DYN_LINK
+ <library>..//adhocutil
+ <library>boost_utf
+ <library>boost_filesystem
+ <library>boost_system
+ <library>dl
+ <dependency>utilTestClasses
+ :
+ testPluginsRuntime
+ ;
+
+run
testFactory.cpp
: : :
<define>BOOST_TEST_DYN_LINK
diff --git a/libadhocutil/unittests/testPlugins.cpp b/libadhocutil/unittests/testPlugins.cpp
index 130d577..ef5ed4b 100644
--- a/libadhocutil/unittests/testPlugins.cpp
+++ b/libadhocutil/unittests/testPlugins.cpp
@@ -3,20 +3,10 @@
#include "plugins.h"
#include "plugins.impl.h"
+#include "utilTestClasses.h"
using namespace AdHoc;
-class BaseThing { };
-
-class ImplOfThing : public BaseThing { };
-class OtherImplOfThing : public BaseThing { };
-
-class OtherBase { };
-
-class OtherImpl : public OtherBase { };
-
-PLUGIN(ImplOfThing, BaseThing);
-
BOOST_AUTO_TEST_CASE( ready )
{
BOOST_REQUIRE(PluginManager::getDefault());
diff --git a/libadhocutil/unittests/testPluginsRuntime.cpp b/libadhocutil/unittests/testPluginsRuntime.cpp
new file mode 100644
index 0000000..0aa9955
--- /dev/null
+++ b/libadhocutil/unittests/testPluginsRuntime.cpp
@@ -0,0 +1,34 @@
+#define BOOST_TEST_MODULE Plugins
+#include <boost/test/unit_test.hpp>
+
+#include "plugins.h"
+#include "plugins.impl.h"
+#include "utilTestClasses.h"
+#include <definedDirs.h>
+#include <dlfcn.h>
+
+using namespace AdHoc;
+
+auto variant = selfExe.parent_path().leaf();
+auto toolset = selfExe.parent_path().parent_path().leaf();
+auto lib = rootDir / "bin" / toolset / variant / "libutilTestClasses.so";
+
+BOOST_AUTO_TEST_CASE( ready )
+{
+ BOOST_REQUIRE(PluginManager::getDefault());
+ BOOST_REQUIRE(boost::filesystem::exists(lib));
+}
+
+BOOST_AUTO_TEST_CASE( clean )
+{
+ BOOST_REQUIRE_EQUAL(0, AdHoc::PluginManager::getDefault()->getAll<BaseThing>().size());
+}
+
+BOOST_AUTO_TEST_CASE( loadAndUnloadlib )
+{
+ void * handle = dlopen(lib.c_str(), RTLD_NOW);
+ BOOST_REQUIRE(handle);
+ BOOST_REQUIRE_EQUAL(1, AdHoc::PluginManager::getDefault()->getAll<BaseThing>().size());
+ dlclose(handle);
+ BOOST_REQUIRE_EQUAL(0, AdHoc::PluginManager::getDefault()->getAll<BaseThing>().size());
+}
diff --git a/libadhocutil/unittests/utilTestClasses.cpp b/libadhocutil/unittests/utilTestClasses.cpp
new file mode 100644
index 0000000..cb31104
--- /dev/null
+++ b/libadhocutil/unittests/utilTestClasses.cpp
@@ -0,0 +1,5 @@
+#include "utilTestClasses.h"
+#include "plugins.impl.h"
+
+PLUGIN(ImplOfThing, BaseThing);
+
diff --git a/libadhocutil/unittests/utilTestClasses.h b/libadhocutil/unittests/utilTestClasses.h
new file mode 100644
index 0000000..f2a2036
--- /dev/null
+++ b/libadhocutil/unittests/utilTestClasses.h
@@ -0,0 +1,20 @@
+#ifndef LIBADHOCUTIL_UNITTESTS_UTILTESTCLASSES_H
+#define LIBADHOCUTIL_UNITTESTS_UTILTESTCLASSES_H
+
+class BaseThing {
+};
+
+class ImplOfThing : public BaseThing {
+};
+
+class OtherImplOfThing : public BaseThing {
+};
+
+class OtherBase {
+};
+
+class OtherImpl : public OtherBase {
+};
+
+#endif
+