From: Yedidya Feldblum Date: Tue, 24 Nov 2015 02:45:15 +0000 (-0800) Subject: Fix Build: folly/test/ThreadLocalTest X-Git-Tag: deprecate-dynamic-initializer~236 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=442584e7897a6a0117c53818564494ba936dbf12;p=folly.git Fix Build: folly/test/ThreadLocalTest 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 --- diff --git a/folly/test/ThreadLocalTest.cpp b/folly/test/ThreadLocalTest.cpp index 823c6cb5..1f089fa6 100644 --- a/folly/test/ThreadLocalTest.cpp +++ b/folly/test/ThreadLocalTest.cpp @@ -39,6 +39,7 @@ #include #include +#include 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)();