r21677 - gnucash/trunk/src/gnc-module/test - [Testing] Gnc-module: Provide checked error messages to replace noted warnings (c-files only)

John Ralls jralls at code.gnucash.org
Sun Dec 4 19:08:10 EST 2011


Author: jralls
Date: 2011-12-04 19:08:10 -0500 (Sun, 04 Dec 2011)
New Revision: 21677
Trac: http://svn.gnucash.org/trac/changeset/21677

Modified:
   gnucash/trunk/src/gnc-module/test/misc-mods/Makefile.am
   gnucash/trunk/src/gnc-module/test/test-agedver.c
   gnucash/trunk/src/gnc-module/test/test-dynload.c
   gnucash/trunk/src/gnc-module/test/test-incompatdep.c
   gnucash/trunk/src/gnc-module/test/test-load-c.c
   gnucash/trunk/src/gnc-module/test/test-modsysver.c
Log:
[Testing] Gnc-module: Provide checked error messages to replace noted warnings (c-files only)


Much better for expected warnings to be tested for than to have a lead-in message saying that they're really OK.

Don't have the test utilities in Scheme yet.

Set the phony modules in misc-modules to be libtool modules instead of shared libraries. Aside from being more correct, this ensures that they'll have the same name on Linux and OSX.

Modified: gnucash/trunk/src/gnc-module/test/misc-mods/Makefile.am
===================================================================
--- gnucash/trunk/src/gnc-module/test/misc-mods/Makefile.am	2011-12-05 00:08:01 UTC (rev 21676)
+++ gnucash/trunk/src/gnc-module/test/misc-mods/Makefile.am	2011-12-05 00:08:10 UTC (rev 21677)
@@ -10,18 +10,18 @@
 check_LTLIBRARIES=libgncmod_futuremodsys.la libgncmod_incompatdep.la libgncmod_agedver.la
 
 libgncmod_futuremodsys_la_SOURCES=futuremodsys.c
-libgncmod_futuremodsys_la_LDFLAGS=-rpath ${PWD} -avoid-version
+libgncmod_futuremodsys_la_LDFLAGS=-rpath ${PWD} -avoid-version -module
 libgncmod_futuremodsys_la_LIBADD = \
   $(GLIB_LIBS)
 
 libgncmod_incompatdep_la_SOURCES=incompatdep.c
-libgncmod_incompatdep_la_LDFLAGS=--rpath ${PWD} -avoid-version
+libgncmod_incompatdep_la_LDFLAGS=--rpath ${PWD} -avoid-version -module
 libgncmod_incompatdep_la_LIBADD = \
   ../../libgnc-module.la \
   $(GLIB_LIBS)
 
 libgncmod_agedver_la_SOURCES=agedver.c
-libgncmod_agedver_la_LDFLAGS=-rpath ${PWD} -avoid-version
+libgncmod_agedver_la_LDFLAGS=-rpath ${PWD} -avoid-version -module
 libgncmod_agedver_la_LIBADD = \
   $(GLIB_LIBS)
 

Modified: gnucash/trunk/src/gnc-module/test/test-agedver.c
===================================================================
--- gnucash/trunk/src/gnc-module/test/test-agedver.c	2011-12-05 00:08:01 UTC (rev 21676)
+++ gnucash/trunk/src/gnc-module/test/test-agedver.c	2011-12-05 00:08:10 UTC (rev 21677)
@@ -1,3 +1,4 @@
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <libguile.h>
@@ -3,12 +4,18 @@
 
 #include "gnc-module.h"
+#include <test-stuff.h>
 
 static void
 guile_main(void *closure, int argc, char ** argv)
 {
     GNCModule foo;
+    gchar *msg = "Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
+    gchar *logdomain = "gnc.module";
+    guint loglevel = G_LOG_LEVEL_WARNING;
+    TestErrorStruct check = { loglevel, logdomain, msg };
+    g_log_set_handler (logdomain, loglevel,
+		       (GLogFunc)test_checked_handler, &check);
+    g_test_message("  test-agedver.c:  asking for an old but supported interface ...");
 
-    printf("  test-agedver.c:  asking for an old but supported interface ...");
-
     gnc_module_system_init();
 

Modified: gnucash/trunk/src/gnc-module/test/test-dynload.c
===================================================================
--- gnucash/trunk/src/gnc-module/test/test-dynload.c	2011-12-05 00:08:01 UTC (rev 21676)
+++ gnucash/trunk/src/gnc-module/test/test-dynload.c	2011-12-05 00:08:10 UTC (rev 21677)
@@ -4,9 +4,11 @@
  * it via dlsym
  *********************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 #include <gmodule.h>
 #include <libguile.h>
+#include <test-stuff.h>
 
 #include "gnc-module.h"
 
@@ -14,8 +16,14 @@
 guile_main(void *closure, int argc, char ** argv)
 {
     GModule *gmodule;
+    gchar *msg = "Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
+    gchar *logdomain = "gnc.module";
+    guint loglevel = G_LOG_LEVEL_WARNING;
+    TestErrorStruct check = { loglevel, logdomain, msg };
+    g_log_set_handler (logdomain, loglevel,
+		       (GLogFunc)test_checked_handler, &check);
 
-    printf("  test-dynload.c: testing dynamic linking of libgnc-module ...");
+    g_test_message("  test-dynload.c: testing dynamic linking of libgnc-module ...");
     gmodule = g_module_open("libgnc-module", 0);
 
     /* Maybe MacOS? */

Modified: gnucash/trunk/src/gnc-module/test/test-incompatdep.c
===================================================================
--- gnucash/trunk/src/gnc-module/test/test-incompatdep.c	2011-12-05 00:08:01 UTC (rev 21676)
+++ gnucash/trunk/src/gnc-module/test/test-incompatdep.c	2011-12-05 00:08:10 UTC (rev 21677)
@@ -1,6 +1,8 @@
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <libguile.h>
+#include <test-stuff.h>
 
 #include "gnc-module.h"
 
@@ -8,8 +10,18 @@
 guile_main(void *closure, int argc, char ** argv)
 {
     GNCModule foo;
+    gchar *msg1 = "Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
+    gchar *msg2 = "Could not locate module gnucash/incompatdep interface v.0";
+    gchar *logdomain = "gnc.module";
+    guint loglevel = G_LOG_LEVEL_WARNING;
+    TestErrorStruct check1 = { loglevel, logdomain, msg1 };
+    TestErrorStruct check2 = { loglevel, logdomain, msg2 };
+    test_add_error (&check1);
+    test_add_error (&check2);
+    g_log_set_handler (logdomain, loglevel,
+		       (GLogFunc)test_list_handler, NULL);
 
-    printf("  test-incompatdep.c:  loading a module with bad deps ...\n");
+    g_test_message("  test-incompatdep.c:  loading a module with bad deps ...\n");
 
     gnc_module_system_init();
 

Modified: gnucash/trunk/src/gnc-module/test/test-load-c.c
===================================================================
--- gnucash/trunk/src/gnc-module/test/test-load-c.c	2011-12-05 00:08:01 UTC (rev 21676)
+++ gnucash/trunk/src/gnc-module/test/test-load-c.c	2011-12-05 00:08:10 UTC (rev 21677)
@@ -1,7 +1,8 @@
-
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <libguile.h>
+#include <test-stuff.h>
 
 #include "gnc-module.h"
 
@@ -9,8 +10,14 @@
 guile_main(void *closure, int argc, char ** argv)
 {
     GNCModule foo;
+    gchar *msg = "Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
+    gchar *logdomain = "gnc.module";
+    guint loglevel = G_LOG_LEVEL_WARNING;
+    TestErrorStruct check = { loglevel, logdomain, msg };
+    g_log_set_handler (logdomain, loglevel,
+		       (GLogFunc)test_checked_handler, &check);
 
-    printf("  test-load-c.c: testing module load/unload from C ... ");
+    g_test_message("  test-load-c.c: testing module load/unload from C ... ");
 
     gnc_module_system_init();
 
@@ -18,16 +25,16 @@
 
     if (!foo)
     {
-        printf("  Failed to load foo\n");
+        g_test_message("  Failed to load foo\n");
         exit(-1);
     }
 
     if (!gnc_module_unload(foo))
     {
-        printf("  Failed to unload foo\n");
+        g_test_message("  Failed to unload foo\n");
         exit(-1);
     }
-    printf(" successful.\n");
+    g_test_message(" successful.\n");
 
     exit(0);
 }

Modified: gnucash/trunk/src/gnc-module/test/test-modsysver.c
===================================================================
--- gnucash/trunk/src/gnc-module/test/test-modsysver.c	2011-12-05 00:08:01 UTC (rev 21676)
+++ gnucash/trunk/src/gnc-module/test/test-modsysver.c	2011-12-05 00:08:10 UTC (rev 21677)
@@ -1,6 +1,8 @@
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <libguile.h>
+#include <test-stuff.h>
 
 #include "gnc-module.h"
 
@@ -8,8 +10,18 @@
 guile_main(void *closure, int argc, char ** argv)
 {
     GNCModule foo;
+    gchar *msg1 = "Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
+    gchar *msg2 = "Could not locate module gnucash/futuremodsys interface v.0";
+    gchar *logdomain = "gnc.module";
+    guint loglevel = G_LOG_LEVEL_WARNING;
+    TestErrorStruct check1 = { loglevel, logdomain, msg1 };
+    TestErrorStruct check2 = { loglevel, logdomain, msg2 };
+    test_add_error (&check1);
+    test_add_error (&check2);
+    g_log_set_handler (logdomain, loglevel,
+		       (GLogFunc)test_list_handler, NULL);
 
-    printf("  test-modsysver.c: checking for a module we shouldn't find ...\n");
+    g_test_message("  test-modsysver.c: checking for a module we shouldn't find ...\n");
 
     gnc_module_system_init();
 
@@ -25,6 +37,7 @@
         printf("  oops! loaded incompatible module\n");
         exit(-1);
     }
+    test_error_clear_list ();
 }
 
 int



More information about the gnucash-changes mailing list