1 /********************************************************************\
2  * This program is free software; you can redistribute it and/or    *
3  * modify it under the terms of the GNU General Public License as   *
4  * published by the Free Software Foundation; either version 2 of   *
5  * the License, or (at your option) any later version.              *
6  *                                                                  *
7  * This program is distributed in the hope that it will be useful,  *
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
10  * GNU General Public License for more details.                     *
11  *                                                                  *
12  * You should have received a copy of the GNU General Public License*
13  * along with this program; if not, contact:                        *
14  *                                                                  *
15  * Free Software Foundation           Voice:  +1-617-542-5942       *
16  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
17  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
18  *                                                                  *
19 \********************************************************************/
20 
21 #include <config.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <unittest-support.h>
25 
26 #include "gnc-module.h"
27 
28 
29 int
main(int argc,char ** argv)30 main(int argc, char ** argv)
31 {
32     GNCModule foo;
33     gchar *msg1 = "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
34     gchar *msg2 = "Could not locate module gnucash/futuremodsys interface v.0";
35     gchar *logdomain = "gnc.module";
36     guint loglevel = G_LOG_LEVEL_WARNING;
37     TestErrorStruct check1 = { loglevel, logdomain, msg1 };
38     TestErrorStruct check2 = { loglevel, logdomain, msg2 };
39     test_add_error (&check1);
40     test_add_error (&check2);
41     g_log_set_handler (logdomain, loglevel,
42                        (GLogFunc)test_list_handler, NULL);
43 
44     g_test_message("  test-modsysver.c: checking for a module we shouldn't find ...\n");
45 
46     gnc_module_system_init();
47 
48     foo = gnc_module_load("gnucash/futuremodsys", 0);
49 
50     if (!foo)
51     {
52         printf("  ok\n");
53         exit(0);
54     }
55     else
56     {
57         printf("  oops! loaded incompatible module\n");
58         exit(-1);
59     }
60     test_clear_error_list ();
61 }
62