1 /*
2  *  CUnit - A Unit testing framework library for C.
3  *  Copyright (C) 2001  Anil Kumar
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Library General Public
7  *  License as published by the Free Software Foundation; either
8  *  version 2 of the License, or (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *  Library General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Library General Public
16  *  License along with this library; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 
24 #include "Console.h"
25 #include "ExampleTests.h"
26 
main(int argc,char * argv[])27 int main(int argc, char* argv[])
28 {
29   CU_BOOL Run = CU_FALSE ;
30 
31   setvbuf(stdout, NULL, _IONBF, 0);
32 
33   if (argc > 1) {
34     if (!strcmp("-i", argv[1])) {
35       Run = CU_TRUE ;
36       CU_set_error_action(CUEA_IGNORE);
37     }
38     else if (!strcmp("-f", argv[1])) {
39       Run = CU_TRUE ;
40       CU_set_error_action(CUEA_FAIL);
41     }
42     else if (!strcmp("-A", argv[1])) {
43       Run = CU_TRUE ;
44       CU_set_error_action(CUEA_ABORT);
45     }
46     else if (!strcmp("-e", argv[1])) {
47       print_example_results();
48     }
49     else {
50       printf("\nUsage:  ConsoleTest [option]\n\n"
51                "Options:   -i   Run, ignoring framework errors [default].\n"
52                "           -f   Run, failing on framework error.\n"
53                "           -A   run, aborting on framework error.\n"
54                "           -e   Print expected test results and exit.\n"
55                "           -h   Print this message.\n\n");
56     }
57   }
58   else {
59     Run = CU_TRUE;
60     CU_set_error_action(CUEA_IGNORE);
61   }
62 
63   if (CU_TRUE == Run) {
64     if (CU_initialize_registry()) {
65       printf("\nInitialization of Test Registry failed.");
66     }
67     else {
68       AddTests();
69       CU_console_run_tests();
70       CU_cleanup_registry();
71     }
72   }
73 
74   return 0;
75 }
76