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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [infra/] [testcase.h] - Blame information for rev 839

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

powered by: WebSVN 2.1.0

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