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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 400 - (hide annotations) (download) (as text)
Fri Mar 31 10:59:36 2006 UTC (16 years, 10 months ago) by johnpye
File MIME type: text/x-csrc
File size: 4577 byte(s)
Almost there with getting Jerry's tests to run. Just sorting out the linking.
1 jds 59 /*
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 johnpye 400 * You should have received a copy of the GNU General Public License
19 jds 59 * 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 johnpye 399 #include <utilities/ascConfig.h>
29     #include <compiler/redirectFile.h>
30     #include <utilities/ascMalloc.h>
31 johnpye 400 #include <printutil.h>
32 jds 59
33     #include "CUnit/Basic.h"
34 johnpye 399 #include <general/test/test_register_general.h>
35     #include <utilities/test/test_register_utilities.h>
36     #include <solver/test/test_register_solver.h>
37 jds 59
38     int main(int argc, char* argv[])
39     {
40     CU_BasicRunMode mode = CU_BRM_VERBOSE;
41     CU_ErrorAction error_action = CUEA_IGNORE;
42     CU_ErrorCode result;
43     int print_messages = FALSE;
44     int i;
45    
46     setvbuf(stdout, NULL, _IONBF, 0);
47    
48     for (i=1 ; i<argc ; i++) {
49     if (!strcmp("-i", argv[i])) {
50     error_action = CUEA_IGNORE;
51     }
52     else if (0 == strcmp("-f", argv[i])) {
53     error_action = CUEA_FAIL;
54     }
55     else if (0 == strcmp("-A", argv[i])) {
56     error_action = CUEA_ABORT;
57     }
58     else if (0 == strcmp("-s", argv[i])) {
59     mode = CU_BRM_SILENT;
60     }
61     else if (0 == strcmp("-n", argv[i])) {
62     mode = CU_BRM_NORMAL;
63     }
64     else if (0 == strcmp("-v", argv[i])) {
65     mode = CU_BRM_VERBOSE;
66     }
67     else if (0 == strcmp("-d", argv[i])) {
68     print_messages = FALSE;
69     }
70     else if (0 == strcmp("-w", argv[i])) {
71     print_messages = TRUE;
72     }
73     else {
74     printf("\nUsage: test_ascend [options]\n\n"
75     "Options: -i ignore framework errors [default].\n"
76     " -f fail on framework error.\n"
77     " -A abort on framework error.\n\n"
78     " -s silent mode - no output to screen.\n"
79     " -n normal mode - standard output to screen.\n"
80     " -v verbose mode - max output to screen [default].\n\n"
81     " -d hide ASCEND messages [default].\n"
82     " -w print ASCEND messages to console.\n\n"
83     " -h print this message and exit.\n\n");
84     return 0;
85     }
86     }
87    
88     /* initialize testing framework */
89     result = CU_initialize_registry();
90     if (CUE_SUCCESS != result) {
91     fprintf(stderr, "\nInitialization of Test Registry failed - Aborting.");
92     return result;
93     }
94    
95     /* register general component */
96     result = test_register_general();
97     if (CUE_SUCCESS != result) {
98     fprintf(stderr, "\nError during registration of general component tests. "
99     "\nError code = %d (%s).",
100     result, CU_get_error_msg());
101     return result;
102     }
103    
104     /* register utilities component */
105     result = test_register_utilities();
106     if (CUE_SUCCESS != result) {
107     fprintf(stderr, "\nError during registration of utilities component tests. "
108     "\nError code = %d (%s).",
109     result, CU_get_error_msg());
110     return result;
111     }
112    
113     /* register solver component */
114     result = test_register_solver();
115     if (CUE_SUCCESS != result) {
116     fprintf(stderr, "\nError during registration of solver component tests. "
117     "\nError code = %d (%s).",
118     result, CU_get_error_msg());
119     return result;
120     }
121    
122     if (TRUE == print_messages) {
123     test_enable_printing();
124     }
125    
126     Asc_RedirectCompilerDefault(); /* direct internal named streams to std streams */
127     CU_basic_set_mode(mode);
128     CU_set_error_action(error_action);
129     result = CU_basic_run_tests();
130     CU_cleanup_registry();
131 johnpye 400
132 jds 59 if (CU_BRM_VERBOSE == mode) {
133     ascshutdown("Testing completed."); /* shut down memory manager */
134     }
135    
136     if (TRUE == print_messages) {
137     test_disable_printing();
138     }
139    
140     return result;
141     }

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