2 * This file is part of mutest, a simple micro unit testing framework for C.
4 * mutest was written by Leandro Lucarella <llucax@gmail.com> and is released
5 * under the BOLA license, please see the LICENSE file or visit:
6 * http://blitiri.com.ar/p/bola/
8 * This is the main program, it runs all the test suites and shows the
9 * results. The main work (of running the test suite) is done by the (usually)
10 * synthesized mu_run_suites() function, which can be generated using the
11 * mkmutest script (or written manually).
13 * Please, read the README file for more details.
16 #include "mutest.h" /* MU_* constants, mu_print() */
17 #include <stdio.h> /* printf(), fprintf() */
18 #include <string.h> /* strncmp() */
21 * note that all global variables are public because they need to be accessed
22 * from other modules, like the test suites or the module implementing
26 /* globals for managing test suites */
27 const char* mutest_suite_name;
28 int mutest_failed_suites;
29 int mutest_passed_suites;
30 int mutest_skipped_suites;
31 int mutest_suite_failed;
34 /* globals for managing test cases */
35 const char* mutest_case_name;
36 int mutest_failed_cases;
37 int mutest_passed_cases;
38 int mutest_case_failed;
41 /* globals for managing checks */
42 int mutest_failed_checks;
43 int mutest_passed_checks;
46 /* verbosity level, see mutest.h */
47 int mutest_verbose_level = 1; /* exported for use in test suites */
52 * only -v is supported right now, both "-v -v" and "-vv" are accepted for
53 * increasing the verbosity by 2.
55 void parse_args(int argc, char* argv[]) {
57 if (strncmp(*argv, "-v", 2) == 0) {
58 ++mutest_verbose_level;
59 char* c = (*argv) + 1;
63 ++mutest_verbose_level;
70 int main(int argc, char* argv[]) {
72 parse_args(argc, argv);
76 mu_print(MU_SUMMARY, "\n"
78 "\t%d test suite(s) passed, %d failed, %d skipped.\n"
79 "\t%d test case(s) passed, %d failed.\n"
80 "\t%d check(s) passed, %d failed.\n"
82 mutest_passed_suites, mutest_failed_suites,
83 mutest_skipped_suites,
84 mutest_passed_cases, mutest_failed_cases,
85 mutest_passed_checks, mutest_failed_checks);
87 return (mutest_failed_suites + mutest_skipped_suites) ? 1 : 0;