Fix Build: folly/test/ThreadLocalTest
authorYedidya Feldblum <yfeldblum@fb.com>
Tue, 24 Nov 2015 02:45:15 +0000 (18:45 -0800)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Tue, 24 Nov 2015 03:20:20 +0000 (19:20 -0800)
Summary: [Folly] Fix Build: `folly/test/ThreadLocalTest`.

The problem is that the to the shared lib used in the test is hardcoded. It's a relative path, so that's nice, but it has too many assumptions about where the build system deposits test binaries.

Instead, let the code simply look for the shared lib in the same directory as the test binary. This makes fewer assumptions on the build system.

Reviewed By: andriigrynenko

Differential Revision: D2689047

fb-gh-sync-id: 648da079b7af5bc9893709d009e577347dd4a463

folly/test/ThreadLocalTest.cpp

index 823c6cb515a778443030f4f8ff6c51bcc726075f..1f089fa6144dcd97190c8c88532bba5ffebb5fd0 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <folly/Benchmark.h>
 #include <folly/Baton.h>
+#include <folly/experimental/io/FsUtil.h>
 
 using namespace folly;
 
@@ -541,10 +542,10 @@ TEST(ThreadLocal, Fork2) {
   }
 }
 
-TEST(ThreadLocal, SharedLibrary)
-{
-  auto handle = dlopen("./_bin/folly/test/lib_thread_local_test.so",
-                       RTLD_LAZY);
+TEST(ThreadLocal, SharedLibrary) {
+  auto exe = fs::executable_path();
+  auto lib = exe.parent_path() / "lib_thread_local_test.so";
+  auto handle = dlopen(lib.string().c_str(), RTLD_LAZY);
   EXPECT_NE(nullptr, handle);
 
   typedef void (*useA_t)();