[cogl/cogl-1.16] Use GModule instead of libdl to load unit test symbols



commit e6fb1fb433f3c4dfde024695c3b5cf593a3dd9c8
Author: Neil Roberts <neil linux intel com>
Date:   Mon Jun 10 13:25:15 2013 +0100

    Use GModule instead of libdl to load unit test symbols
    
    Previously the unit tests were using libdl without directly linking to
    it. It looks like this ends up working because one of Cogl's
    dependencies ends up pulling adding -ldl via libtool. However in some
    configurations it looks like this wasn't happening.
    
    To avoid this problem we can just use GModule to resolve the symbols.
    g_module_open is documented to return a handle to the ‘main program’
    when NULL is passed as the filename and looking at the code it seems
    that this ends up using RTLD_DEFAULT so it will have the same effect.
    
    The in-tree copy of glib already has the code for gmodule so this
    shouldn't cause problems for --disable-glib.
    
    Reviewed-by: Robert Bragg <robert linux intel com>
    
    (cherry picked from commit b14ece116ed3e4b18d59b645e77b3449fac51137)

 tests/unit/test-unit-main.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/tests/unit/test-unit-main.c b/tests/unit/test-unit-main.c
index f78399a..92dcec7 100644
--- a/tests/unit/test-unit-main.c
+++ b/tests/unit/test-unit-main.c
@@ -1,12 +1,13 @@
 #include <config.h>
 
-#include <dlfcn.h>
+#include <gmodule.h>
 
 #include <test-fixtures/test-unit.h>
 
 int
 main (int argc, char **argv)
 {
+  GModule *main_module;
   const CoglUnitTest *unit_test;
   int i;
 
@@ -25,8 +26,10 @@ main (int argc, char **argv)
         argv[1][i] = '_';
     }
 
-  unit_test = dlsym (RTLD_DEFAULT, argv[1]);
-  if (!unit_test)
+  main_module = g_module_open (NULL, /* use main module */
+                               0 /* flags */);
+
+  if (!g_module_symbol (main_module, argv[1], (void **) &unit_test))
     {
       g_printerr ("Unknown test name \"%s\"\n", argv[1]);
       return 1;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]