summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libadhocutil/definedDirs.h16
-rw-r--r--libadhocutil/unittests/Jamfile.jam13
-rw-r--r--libadhocutil/unittests/testDirs.cpp18
-rw-r--r--libadhocutil/unittests/testPluginsRuntime.cpp4
4 files changed, 46 insertions, 5 deletions
diff --git a/libadhocutil/definedDirs.h b/libadhocutil/definedDirs.h
index b24a1c9..9c1cc84 100644
--- a/libadhocutil/definedDirs.h
+++ b/libadhocutil/definedDirs.h
@@ -10,9 +10,21 @@
#define XSTR(s) STR(s)
#define STR(s) #s
-const auto selfExe = boost::filesystem::canonical("/proc/self/exe");
-const auto binDir = selfExe.parent_path();
+namespace AdHoc {
+ static boost::filesystem::path getBuildVariant(boost::filesystem::path binDir)
+ {
+ boost::filesystem::path p;
+ while (strncmp(p.c_str(), "gcc-", 4)) {
+ p = binDir.leaf() / p;
+ binDir = binDir.parent_path();
+ }
+ return p;
+ }
+}
+const boost::filesystem::path selfExe = boost::filesystem::canonical("/proc/self/exe");
+const boost::filesystem::path binDir = selfExe.parent_path();
const boost::filesystem::path rootDir(XSTR(ROOT));
+const boost::filesystem::path buildVariant = AdHoc::getBuildVariant(binDir);
#endif
diff --git a/libadhocutil/unittests/Jamfile.jam b/libadhocutil/unittests/Jamfile.jam
index 9f45265..5ea24a8 100644
--- a/libadhocutil/unittests/Jamfile.jam
+++ b/libadhocutil/unittests/Jamfile.jam
@@ -129,6 +129,19 @@ lib utilTestClasses :
;
run
+ testDirs.cpp
+ : : :
+ <define>BOOST_TEST_DYN_LINK
+ <library>..//adhocutil
+ <library>boost_utf
+ <define>ROOT=\"$(me)\"
+ <library>boost_filesystem
+ <library>boost_system
+ :
+ testDirs
+ ;
+
+run
testPlugins.cpp
: : :
<define>BOOST_TEST_DYN_LINK
diff --git a/libadhocutil/unittests/testDirs.cpp b/libadhocutil/unittests/testDirs.cpp
new file mode 100644
index 0000000..f215d49
--- /dev/null
+++ b/libadhocutil/unittests/testDirs.cpp
@@ -0,0 +1,18 @@
+#define BOOST_TEST_MODULE Dirs
+#include <boost/test/unit_test.hpp>
+
+#include <definedDirs.h>
+#include <boost/filesystem/convenience.hpp>
+
+BOOST_AUTO_TEST_CASE( iexist )
+{
+ BOOST_REQUIRE(boost::filesystem::exists(selfExe));
+ BOOST_REQUIRE(selfExe.is_absolute());
+ BOOST_REQUIRE_EQUAL("testDirs", selfExe.leaf().string());
+ BOOST_REQUIRE_EQUAL("unittests", rootDir.leaf().string());
+ BOOST_REQUIRE(boost::filesystem::is_directory(binDir));
+ BOOST_REQUIRE_EQUAL("libadhocutil", rootDir.parent_path().leaf().string());
+ BOOST_REQUIRE(buildVariant.is_relative());
+ BOOST_REQUIRE_EQUAL(selfExe, rootDir / "bin" / "testDirs.test" / buildVariant / "testDirs");
+}
+
diff --git a/libadhocutil/unittests/testPluginsRuntime.cpp b/libadhocutil/unittests/testPluginsRuntime.cpp
index aa1dcf1..9185cdc 100644
--- a/libadhocutil/unittests/testPluginsRuntime.cpp
+++ b/libadhocutil/unittests/testPluginsRuntime.cpp
@@ -9,9 +9,7 @@
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";
+auto lib = rootDir / "bin" / buildVariant / "libutilTestClasses.so";
static boost::optional<std::string> nullResolver(const std::type_info &, const std::string &);
static boost::optional<std::string> badResolver(const std::type_info &, const std::string &);