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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [infra/] [current/] [include/] [testcase.h] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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