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 #include "test/mod-ordinary/ordinary.h"
26 #include "test/mod-withdep/withdep.h"
27
28 #include "gnc-module.h"
29
30 int
main(int argc,char ** argv)31 main(int argc, char ** argv)
32 {
33 gint retval = 0;
34 GNCModule testmod;
35
36 gnc_module_system_init();
37
38 g_test_message(" test-load-c.c: load module gnucash/ordinary from C ... ");
39 testmod = gnc_module_load("gnucash/ordinary", 0);
40 if (!testmod)
41 {
42 g_test_message(" failed\n");
43 exit(-1);
44 }
45 g_test_message(" ok\n");
46
47 g_test_message(" test-load-c.c: call function ordinary_hello in module gnucash/ordinary ... ");
48 retval = ordinary_hello();
49 if (retval != 10)
50 {
51 g_test_message(" failed. Expected 10, got %i\n", retval);
52 exit(-1);
53 }
54 g_test_message(" ok\n");
55
56 g_test_message(" test-load-c.c: unload module gnucash/ordinary from C ... ");
57 if (!gnc_module_unload(testmod))
58 {
59 g_test_message(" failed\n");
60 exit(-1);
61 }
62 g_test_message(" ok.\n");
63
64 g_test_message(" test-load-c.c: load module gnucash/withdep from C ... ");
65 testmod = gnc_module_load("gnucash/withdep", 0);
66 if (!testmod)
67 {
68 g_test_message(" failed\n");
69 exit(-1);
70 }
71 g_test_message(" ok\n");
72
73 g_test_message(" test-load-c.c: call function withdep_hello in module gnucash/withdep ... ");
74 retval = withdep_hello();
75 if (retval != 11)
76 {
77 g_test_message(" failed. Expected 11, got %i\n", retval);
78 exit(-1);
79 }
80 g_test_message(" ok\n");
81
82 g_test_message(" test-load-c.c: call function ordinary_hello in depended on module gnucash/ordinary ... ");
83 retval = ordinary_hello();
84 if (retval != 10)
85 {
86 g_test_message(" failed. Expected 10, got %i\n", retval);
87 exit(-1);
88 }
89 g_test_message(" ok\n");
90
91 g_test_message(" test-load-c.c: unload module gnucash/withdep from C ... ");
92 if (!gnc_module_unload(testmod))
93 {
94 g_test_message(" failed\n");
95 exit(-1);
96 }
97 g_test_message(" ok.\n");
98
99 exit(0);
100 }
101