/[ascend]/trunk/base/generic/test/test_ascend_base.c
ViewVC logotype

Contents of /trunk/base/generic/test/test_ascend_base.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 935 - (show annotations) (download) (as text)
Fri Nov 24 00:37:11 2006 UTC (13 years, 3 months ago) by johnpye
File MIME type: text/x-csrc
File size: 4672 byte(s)
Adopted suggestions wrt Py_None on Windows platform (extpy)
Fixed up default values of CUNIT_PREFIX (needs testing for case where missing)
1 /*
2 * Test runner for ASCEND base library.
3 *
4 * Copyright (C) 2005 Jerry St.Clair
5 *
6 * This file is part of the Ascend Environment.
7 *
8 * The Ascend Environment is free software; you can redistribute it
9 * and/or modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * The Ascend Environment is distributed in hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with the program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
21 * COPYING.
22 */
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27
28 #include <utilities/ascConfig.h>
29 #include <utilities/error.h>
30 #include <compiler/redirectFile.h>
31 #include <utilities/ascMalloc.h>
32 #include <printutil.h>
33
34 #include <CUnit/Basic.h>
35 #include <general/test/test_register_general.h>
36 #include <utilities/test/test_register_utilities.h>
37 #include <solver/test/test_register_solver.h>
38
39 int main(int argc, char* argv[])
40 {
41 CU_BasicRunMode mode = CU_BRM_VERBOSE;
42 CU_ErrorAction error_action = CUEA_IGNORE;
43 CU_ErrorCode result;
44 int print_messages = FALSE;
45 int i;
46
47 error_reporter_set_callback(NULL);
48
49 setvbuf(stdout, NULL, _IONBF, 0);
50
51 for (i=1 ; i<argc ; i++) {
52 if (!strcmp("-i", argv[i])) {
53 error_action = CUEA_IGNORE;
54 }
55 else if (0 == strcmp("-f", argv[i])) {
56 error_action = CUEA_FAIL;
57 }
58 else if (0 == strcmp("-A", argv[i])) {
59 error_action = CUEA_ABORT;
60 }
61 else if (0 == strcmp("-s", argv[i])) {
62 mode = CU_BRM_SILENT;
63 }
64 else if (0 == strcmp("-n", argv[i])) {
65 mode = CU_BRM_NORMAL;
66 }
67 else if (0 == strcmp("-v", argv[i])) {
68 mode = CU_BRM_VERBOSE;
69 }
70 else if (0 == strcmp("-d", argv[i])) {
71 print_messages = FALSE;
72 }
73 else if (0 == strcmp("-w", argv[i])) {
74 print_messages = TRUE;
75 }
76 else {
77 printf("\nUsage: %s [options]\n\n"
78 "Options: -i ignore framework errors [default].\n"
79 " -f fail on framework error.\n"
80 " -A abort on framework error.\n\n"
81 " -s silent mode - no output to screen.\n"
82 " -n normal mode - standard output to screen.\n"
83 " -v verbose mode - max output to screen [default].\n\n"
84 " -d hide ASCEND messages [default].\n"
85 " -w print ASCEND messages to console.\n\n"
86 " -h print this message and exit.\n\n"
87 , argv[0]
88 );
89 return 0;
90 }
91 }
92
93 /* initialize testing framework */
94 result = CU_initialize_registry();
95 if (CUE_SUCCESS != result) {
96 fprintf(stderr, "\nInitialization of Test Registry failed - Aborting.");
97 return result;
98 }
99
100 /* register 'general' component */
101 result = test_register_general();
102 if (CUE_SUCCESS != result) {
103 fprintf(stderr, "\nError during registration of general component tests. "
104 "\nError code = %d (%s).",
105 result, CU_get_error_msg());
106 return result;
107 }
108
109 /* register 'utilities' component */
110 result = test_register_utilities();
111 if (CUE_SUCCESS != result) {
112 fprintf(stderr, "\nError during registration of utilities component tests. "
113 "\nError code = %d (%s).",
114 result, CU_get_error_msg());
115 return result;
116 }
117
118 /* register 'solver' component */
119 result = test_register_solver();
120 if (CUE_SUCCESS != result) {
121 fprintf(stderr, "\nError during registration of solver component tests. "
122 "\nError code = %d (%s).",
123 result, CU_get_error_msg());
124 return result;
125 }
126
127 if (TRUE == print_messages) {
128 test_enable_printing();
129 }
130
131 /* Asc_RedirectCompilerDefault(); */ /* direct internal named streams to std streams */
132 CU_basic_set_mode(mode);
133 CU_set_error_action(error_action);
134 result = CU_basic_run_tests();
135 CU_cleanup_registry();
136
137 if (CU_BRM_VERBOSE == mode) {
138 ascshutdown("Testing completed."); /* shut down memory manager */
139 }
140
141 if (TRUE == print_messages) {
142 test_disable_printing();
143 }
144
145 return result;
146 }

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22