|
GnuCash 2.4.99
|
00001 /********************************************************************* 00002 * test-dynload.c 00003 * test the ability to dlopen the gnc_module library and initialize 00004 * it via dlsym 00005 *********************************************************************/ 00006 00007 #include "config.h" 00008 #include <stdio.h> 00009 #include <gmodule.h> 00010 #include <libguile.h> 00011 #include <unittest-support.h> 00012 00013 #include "gnc-module.h" 00014 00015 static void 00016 guile_main(void *closure, int argc, char ** argv) 00017 { 00018 GModule *gmodule; 00019 gchar *msg = "Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n"; 00020 gchar *logdomain = "gnc.module"; 00021 guint loglevel = G_LOG_LEVEL_WARNING; 00022 TestErrorStruct check = { loglevel, logdomain, msg }; 00023 g_log_set_handler (logdomain, loglevel, 00024 (GLogFunc)test_checked_handler, &check); 00025 00026 g_test_message(" test-dynload.c: testing dynamic linking of libgnc-module ..."); 00027 gmodule = g_module_open("libgnc-module", 0); 00028 00029 /* Maybe MacOS? */ 00030 if (!gmodule) 00031 gmodule = g_module_open("libgnc-module.dylib", 0); 00032 00033 if (gmodule) 00034 { 00035 gpointer ptr; 00036 if (g_module_symbol(gmodule, "gnc_module_system_init", &ptr)) 00037 { 00038 void (* fn)(void) = ptr; 00039 fn(); 00040 printf(" OK\n"); 00041 exit(0); 00042 } 00043 else 00044 { 00045 printf(" failed to find gnc_module_system_init\n"); 00046 exit(-1); 00047 } 00048 } 00049 else 00050 { 00051 printf(" failed to open library.\n"); 00052 printf("%s\n", g_module_error()); 00053 exit(-1); 00054 } 00055 } 00056 00057 int 00058 main(int argc, char ** argv) 00059 { 00060 scm_boot_guile(argc, argv, guile_main, NULL); 00061 return 0; 00062 } 00063
1.7.4