OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [infra/] [testcase.h] - Blame information for rev 656

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
#ifndef CYGONCE_INFRA_TESTCASE_H
2
#define CYGONCE_INFRA_TESTCASE_H
3
//==========================================================================
4
//
5
//        testcase.h
6
//
7
//        Target side interface for tests
8
//
9
//==========================================================================
10
//####COPYRIGHTBEGIN####
11
//                                                                          
12
// ----------------------------------------------------------------------------
13
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
14
//
15
// This file is part of the eCos host tools.
16
//
17
// This program is free software; you can redistribute it and/or modify it 
18
// under the terms of the GNU General Public License as published by the Free 
19
// Software Foundation; either version 2 of the License, or (at your option) 
20
// any later version.
21
// 
22
// This program is distributed in the hope that it will be useful, but WITHOUT 
23
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
24
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
25
// more details.
26
// 
27
// You should have received a copy of the GNU General Public License along with
28
// this program; if not, write to the Free Software Foundation, Inc., 
29
// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
30
//
31
// ----------------------------------------------------------------------------
32
//                                                                          
33
//####COPYRIGHTEND####
34
//==========================================================================
35
//#####DESCRIPTIONBEGIN####
36
//
37
// Author(s):       ctarpy
38
// Contributors:    ctarpy, jlarmour
39
// Date:            1999-02-16
40
//
41
//
42
//####DESCRIPTIONEND####
43
 
44
#include <cyg/infra/cyg_type.h> // Common type definitions and support
45
 
46
 
47
// CONSTANTS
48
 
49
// Status codes
50
 
51
typedef enum {
52
    CYGNUM_TEST_FAIL,
53
    CYGNUM_TEST_PASS,
54
    CYGNUM_TEST_EXIT,
55
    CYGNUM_TEST_INFO,
56
    CYGNUM_TEST_GDBCMD,
57
    CYGNUM_TEST_NA
58
} Cyg_test_code;
59
 
60
// FUNCTION PROTOTYPES
61
 
62
externC void
63
cyg_test_output(Cyg_test_code _status_, const char* _msg_, int _line_number_,
64
                const char* _file_);
65
 
66
// This should be called at the start of each test file
67
externC void
68
cyg_test_init(void);
69
 
70
// This causes the test to exit
71
externC void
72
cyg_test_exit(void) CYGBLD_ATTRIB_NORET;
73
 
74
// GLOBALS
75
 
76
externC int cyg_test_is_simulator;    // infrastructure changes as necessary
77
 
78
// MACROS
79
 
80
// ----------- Info -----------
81
//
82
// Any macro with EXIT in it should only be used in a panic situation. It
83
// is synonymous with assert. If the test behaves as expected, it
84
// should call one of the FINISH macros.
85
//
86
// - Compound testcases
87
// If a testcase is capable of being part of a compound, then the following
88
// rules apply:
89
// - The testcase must only ever call one of the EXIT macros if it decides
90
//   the state of the system is such that further testing is meaningless;
91
//   such a call would prevent subsequent tests in the compound from being
92
//   run.
93
// - In order to terminate the test, the testcase should call one of the
94
//   FINISH macros. This must be done from within main().
95
 
96
 
97
 
98
 
99
// The following is the testcase API to be used by testcases.
100
 
101
#define CYG_TEST_INIT() cyg_test_init()
102
 
103
#define CYG_TEST_INFO( _msg_ ) \
104
 cyg_test_output(CYGNUM_TEST_INFO, _msg_, __LINE__, __FILE__)
105
 
106
#define CYG_TEST_PASS( _msg_ ) \
107
 cyg_test_output(CYGNUM_TEST_PASS, _msg_, __LINE__, __FILE__)
108
 
109
#define CYG_TEST_FAIL( _msg_ ) \
110
 cyg_test_output(CYGNUM_TEST_FAIL, _msg_, __LINE__, __FILE__)
111
 
112
#define CYG_TEST_EXIT( _msg_ ) \
113
 (cyg_test_output(CYGNUM_TEST_EXIT, _msg_, __LINE__, __FILE__), \
114
  cyg_test_exit())
115
 
116
// Use the following macro to instruct GDB to run a command when using
117
// the automatic testing infrastructure. This must be used *before*
118
// CYG_TEST_INIT() is called
119
 
120
#define CYG_TEST_GDBCMD( _command_ )                                     \
121
     CYG_MACRO_START                                                     \
122
     cyg_test_output(CYGNUM_TEST_GDBCMD, _command_, __LINE__, __FILE__); \
123
     CYG_MACRO_END
124
 
125
// Use the following macro to declare that a test is not applicable for
126
// some reason - perhaps not appropriate due to chosen hardware,
127
// configuration options governing the presence of a tested feature, or
128
// even configuration options governing the presence of a feature the
129
// test relies on _in_order_ to test the feature (despite being
130
// unrelated!)
131
 
132
#define CYG_TEST_NA( _msg_ )                                         \
133
     CYG_MACRO_START                                                 \
134
     cyg_test_output(CYGNUM_TEST_NA, _msg_, __LINE__, __FILE__);     \
135
     cyg_test_exit();                                                \
136
     CYG_MACRO_END
137
 
138
#ifdef CYG_COMPOUND_TEST
139
#  define CYG_TEST_FINISH( _msg_ )                                  \
140
     CYG_MACRO_START                                                \
141
     cyg_test_output(CYGNUM_TEST_EXIT, _msg_, __LINE__, __FILE__);  \
142
     return 0;                                                      \
143
     CYG_MACRO_END
144
#else
145
#  define CYG_TEST_FINISH( _msg_ ) CYG_TEST_EXIT( _msg_ )
146
#endif
147
 
148
#define CYG_TEST_STILL_ALIVE( _ctr_ , _msg_ ) CYG_TEST_INFO( _msg_ )
149
 
150
 
151
// ----- The following are convenience functions
152
 
153
#define CYG_TEST_PASS_FINISH( _msg_ ) \
154
    CYG_MACRO_START                   \
155
    CYG_TEST_PASS( _msg_ );           \
156
    CYG_TEST_FINISH("done");          \
157
    CYG_MACRO_END
158
 
159
#define CYG_TEST_FAIL_FINISH( _msg_ ) \
160
    CYG_MACRO_START                   \
161
    CYG_TEST_FAIL( _msg_ );           \
162
    CYG_TEST_FINISH("done");          \
163
    CYG_MACRO_END
164
 
165
 
166
#define CYG_TEST_CHECK( _chk_ , _msg_)                                   \
167
    CYG_MACRO_START                                                      \
168
    (void)(( _chk_ ) || ( CYG_TEST_FAIL( _msg_ ) , cyg_test_exit(), 1)); \
169
    CYG_MACRO_END
170
 
171
#define CYG_TEST_PASS_FAIL( _cdn_, _msg_ )                            \
172
    CYG_MACRO_START                                                   \
173
    if ( _cdn_ ) CYG_TEST_PASS( _msg_ ); else CYG_TEST_FAIL( _msg_ ); \
174
    CYG_MACRO_END
175
 
176
 
177
// CYG_TEST_PASS_EXIT and CYG_TEST_FAIL_EXIT are now obscelete, 
178
// but are here for now
179
// to avoid breaking testcases which still use them. They will
180
// soon go away.
181
#define CYG_TEST_PASS_EXIT( _msg_ )                             \
182
 (cyg_test_output(CYGNUM_TEST_PASS, _msg_, __LINE__, __FILE__), \
183
 CYG_TEST_EXIT("done"))
184
 
185
#define CYG_TEST_FAIL_EXIT( _msg_ )                             \
186
 (cyg_test_output(CYGNUM_TEST_FAIL, _msg_, __LINE__, __FILE__), \
187
 CYG_TEST_EXIT("done"))
188
 
189
 
190
#endif // CYGONCE_INFRA_TESTCASE_H
191
// EOF testcase.h

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.