diff options
Diffstat (limited to 'base/test_suite.h')
-rw-r--r-- | base/test_suite.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/base/test_suite.h b/base/test_suite.h index 6b6dfd5..9104a54 100644 --- a/base/test_suite.h +++ b/base/test_suite.h @@ -14,12 +14,14 @@ #include "base/debug_on_start.h" #include "base/icu_util.h" #include "base/logging.h" +#include "base/multiprocess_test.h" #include "testing/gtest/include/gtest/gtest.h" #if defined(OS_WIN) #include <windows.h> #include "base/multiprocess_test.h" #elif defined(OS_LINUX) +#include <dlfcn.h> #include <gtk/gtk.h> #endif @@ -37,25 +39,31 @@ class TestSuite { int Run() { Initialize(); - -#if defined(OS_WIN) - // Check to see if we are being run as a client process. +#if defined(OS_WIN) || defined(OS_LINUX) std::wstring client_func = CommandLine().GetSwitchValue(kRunClientProcess); + // Check to see if we are being run as a client process. if (!client_func.empty()) { // Convert our function name to a usable string for GetProcAddress. std::string func_name(client_func.begin(), client_func.end()); +#if defined(OS_WIN) // Get our module handle and search for an exported function // which we can use as our client main. MultiProcessTest::ChildFunctionPtr func = reinterpret_cast<MultiProcessTest::ChildFunctionPtr>( GetProcAddress(GetModuleHandle(NULL), func_name.c_str())); +#elif defined(OS_LINUX) + void* exobj = dlopen(0, RTLD_LAZY); + MultiProcessTest::ChildFunctionPtr func = + reinterpret_cast<MultiProcessTest::ChildFunctionPtr>( + dlsym(exobj, func_name.c_str())); +#endif // defined(OS_LINUX) + if (func) - return func(); + return (*func)(); return -1; } -#endif - +#endif // defined(OS_WIN) || defined(OS_LINUX) int result = RUN_ALL_TESTS(); Shutdown(); |