Date: Tuesday, April 17, 2007 @ 15:58:38
Author: marc
Path: /cvsroot/carob/libmysequoia/ldtest
Modified: main.cpp (1.11 -> 1.12)
Added (disabled) code to test RTLD_GLOBAL flag
----------+
main.cpp | 42 +++++++++++++++++++++++++++++++++++-------
1 files changed, 35 insertions(+), 7 deletions(-)
Index: libmysequoia/ldtest/main.cpp
diff -u libmysequoia/ldtest/main.cpp:1.11 libmysequoia/ldtest/main.cpp:1.12
--- libmysequoia/ldtest/main.cpp:1.11 Tue Apr 17 12:59:18 2007
+++ libmysequoia/ldtest/main.cpp Tue Apr 17 15:58:38 2007
@@ -35,7 +35,8 @@
-int testso(void * sohandle)
+bool
+testso(void * sohandle)
{
std::cout << " ";
const char *functions[2] = { "intercepted", "orig_calling_intercepted" };
@@ -46,8 +47,8 @@
const char *error = dlerror();
if (error) {
- std::cerr << "failed to find plugin function: " << error << std::endl;
- exit(2);
+ std::cerr << "Test failed to find plugin function: " << error <<
std::endl;
+ return false;
}
std::cout << functions[i] << "() = "
@@ -55,10 +56,13 @@
<< " " ;
}
+
+ return true;
+
}
-int
+bool
test(bool global, bool deepbind = false)
{
@@ -77,13 +81,37 @@
void *plugin = dlopen("./plugin.so", flags);
if (!plugin) {
- std::cerr << "failed to open plugin: " << dlerror() << std::endl;
- exit (1);
+ std::cerr << "Test failed to open plugin: " << dlerror() << std::endl;
+ return false;
}
std::cout << "...completed." << std::endl;
+#if 1
testso(plugin);
+#else // test RTLD_GLOBAL flag
+ void *globalscope = dlopen( (const char*) NULL, RTLD_NOW);
+ if (!globalscope) {
+ std::cerr << "failed to open global scope: " << dlerror() << std::endl;
+ exit (1);
+ }
+
+ // if (!global) -> expect to fail/return 1
+
+ if (global) {
+ if (! testso(globalscope)) {
+ std::cerr << " ERROR: RTLD_GLOBAL+globalscope test failed" <<
std::endl;
+ return false;
+ }
+ } else
+ if ( testso(globalscope)) {
+ std::cerr << " WARNING: RTLD_LOCAL+globalscope test succeeded"
+ << "(this is ok when plugin is LD_PRELOADed)"
+ << std::endl;
+ }
+
+ dlclose(globalscope);
+#endif
std::cout << std::endl;
@@ -92,7 +120,7 @@
dlclose(plugin);
std::cout << "...completed " << std::endl;
- return 0;
+ return true;
}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits