3 * @author Adenilson Cavalcanti da Silva <adenilson.silva@indt.org.br>
4 * @date Mon Mar 3 20:14:13 2008
6 * @brief Unit test module.
8 * All units goes here (they are useful to help refine the API of library
9 * and also provide a way to validate/document the code).
19 #include "utest_gcal.h"
20 #include "utest_xpath.h"
21 #include "utest_edit.h"
22 #include "utest_contact.h"
23 #include "utest_debug.h"
24 #include "utest_query.h"
25 #include "utest_userapi.h"
26 #include "utest_xmlmode.h"
27 #include "utest_screw.h"
29 static Suite
*core_suite(void)
34 s
= suite_create("core");
35 test_var
= getenv("GCALTEST");
38 if (!(strcmp(test_var
, "gcal")))
39 suite_add_tcase(s
, gcal_tcase_create());
40 else if (!(strcmp(test_var
, "xpath")))
41 suite_add_tcase(s
, xpath_tcase_create());
42 else if (!(strcmp(test_var
, "edit")))
43 suite_add_tcase(s
, edit_tcase_create());
44 else if (!(strcmp(test_var
, "contact")))
45 suite_add_tcase(s
, gcontact_tcase_create());
46 else if (!(strcmp(test_var
, "debug")))
47 suite_add_tcase(s
, gcaldebug_tcase_create());
48 else if (!(strcmp(test_var
, "query")))
49 suite_add_tcase(s
, gcal_query_tcase_create());
57 suite_add_tcase(s
, gcal_tcase_create());
58 suite_add_tcase(s
, xpath_tcase_create());
59 suite_add_tcase(s
, edit_tcase_create());
60 suite_add_tcase(s
, gcontact_tcase_create());
61 suite_add_tcase(s
, gcaldebug_tcase_create());
62 suite_add_tcase(s
, gcal_query_tcase_create());
68 static Suite
*user_api(void)
71 s
= suite_create("userapi");
72 suite_add_tcase(s
, gcal_userapi());
76 static Suite
*xml_api(void)
79 s
= suite_create("xmlapi");
80 suite_add_tcase(s
, xmlmode_tcase_create());
85 static Suite
*screw_api(void)
88 s
= suite_create("screwapi");
89 suite_add_tcase(s
, gcal_screw());
94 static void run_and_clean(SRunner
*runner
)
96 /* TODO: use it to determine exit status */
101 srunner_run_all(runner
, CK_VERBOSE
);
102 number_failed
= srunner_ntests_failed(runner
);
103 srunner_free(runner
);
110 Suite
*s
, *sapi
, *sxml
, *s_screw
;
111 SRunner
*core
, *userapi
, *xmlapi
, *screwtest
;
113 s
= sapi
= sxml
= s_screw
= NULL
;
114 core
= userapi
= xmlapi
= screwtest
= NULL
;
116 env_var
= getenv("GCAL");
118 if (!strcmp("core", env_var
)) {
121 core
= srunner_create(s
);
122 } else if(!strcmp("user", env_var
)) {
124 userapi
= srunner_create(sapi
);
125 /* I will not fork the userapi, since I need to
127 * between each running test.
129 srunner_set_fork_status(userapi
, CK_NOFORK
);
131 } else if (!strcmp("xml", env_var
)) {
132 /* This one tests for XML api mode */
134 xmlapi
= srunner_create(sxml
);
135 } else if (!strcmp("screw", env_var
)) {
136 /* Tests trying to break libgcal */
137 s_screw
= screw_api();
138 screwtest
= srunner_create(s_screw
);
140 } else { /* Run all tests */
142 core
= srunner_create(s
);
145 userapi
= srunner_create(sapi
);
146 srunner_set_fork_status(userapi
, CK_NOFORK
);
149 xmlapi
= srunner_create(sxml
);
151 s_screw
= screw_api();
152 screwtest
= srunner_create(s_screw
);
156 run_and_clean(userapi
);
157 run_and_clean(xmlapi
);
158 run_and_clean(screwtest
);
160 /* TODO: use number of failures to decide exit status, it can
161 * be either EXIT_FAILURE or ...