IVGCVSW-3561 Use absolute path of unit tests
authorMatteo Martincigh <matteo.martincigh@arm.com>
Wed, 31 Jul 2019 10:05:16 +0000 (11:05 +0100)
committerMatteo Martincigh <matteo.martincigh@arm.com>
Wed, 31 Jul 2019 10:05:18 +0000 (11:05 +0100)
 * Using the absolute path of the unit tests executable so that
   the unit tests can be run from anywhere and the relative path
   to the test shared objects would still work

Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Change-Id: I57401daa162570e9ab1717d28a54a19f421afb0e

src/backends/backendsCommon/test/DynamicBackendTests.hpp

index 1b3edc5..2bc4558 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <boost/test/unit_test.hpp>
 #include <boost/filesystem.hpp>
+#include <boost/dll.hpp>
 
 static std::string g_TestSharedObjectSubDir                 = "src/backends/backendsCommon/test/";
 static std::string g_TestSharedObjectFileName               = "libarmnnTestSharedObject.so";
@@ -31,8 +32,8 @@ std::string GetTestFilePath(const std::string& fileName)
 {
     using namespace boost::filesystem;
 
-    path currentPath(current_path());
-    path sharedObjectPath = currentPath.append(g_TestSharedObjectSubDir);
+    path programLocation = boost::dll::program_location().parent_path();
+    path sharedObjectPath = programLocation.append(g_TestSharedObjectSubDir);
     path sharedObjectFile = sharedObjectPath.append(fileName);
     BOOST_TEST(exists(sharedObjectFile));