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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [infra/] [v2_0/] [include/] [testcase.h] - Blame information for rev 228

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

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

powered by: WebSVN 2.1.0

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