Mercurial > ecos
annotate packages/infra/current/include/testcase.h @ 2729:74dbf4c3f2e1 after-copyright-change-20090129
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
| author | jlarmour |
|---|---|
| date | Thu, 29 Jan 2009 17:47:46 +0000 |
| parents | d2c90368aeef |
| children |
| rev | line source |
|---|---|
| 0 | 1 #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 //========================================================================== | |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
10 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
11 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
12 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
66
diff
changeset
|
14 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
15 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
16 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
17 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
18 // version. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
66
diff
changeset
|
19 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
20 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
21 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
22 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
23 // for more details. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
66
diff
changeset
|
24 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
25 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
26 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
27 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
66
diff
changeset
|
28 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
29 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
30 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
31 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
32 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
33 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
34 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
35 // General Public License v2. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
66
diff
changeset
|
36 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
37 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
38 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
39 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
40 // ####ECOSGPLCOPYRIGHTEND#### |
| 0 | 41 //========================================================================== |
| 42 //#####DESCRIPTIONBEGIN#### | |
| 43 // | |
| 2 | 44 // Author(s): ctarpy |
| 45 // Contributors: ctarpy, jlarmour | |
| 46 // Date: 1999-02-16 | |
| 0 | 47 // |
| 48 // | |
| 49 //####DESCRIPTIONEND#### | |
| 50 | |
| 51 #include <cyg/infra/cyg_type.h> // Common type definitions and support | |
| 52 | |
| 53 | |
| 2 | 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 | |
| 0 | 69 externC void |
| 2 | 70 cyg_test_output(Cyg_test_code _status_, const char* _msg_, int _line_number_, |
| 71 const char* _file_); | |
| 0 | 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 | |
| 2 | 79 cyg_test_exit(void) CYGBLD_ATTRIB_NORET; |
| 80 | |
| 81 // GLOBALS | |
| 0 | 82 |
| 2 | 83 externC int cyg_test_is_simulator; // infrastructure changes as necessary |
| 84 | |
| 85 // MACROS | |
| 0 | 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_ ) \ | |
| 2 | 111 cyg_test_output(CYGNUM_TEST_INFO, _msg_, __LINE__, __FILE__) |
| 0 | 112 |
| 113 #define CYG_TEST_PASS( _msg_ ) \ | |
| 2 | 114 cyg_test_output(CYGNUM_TEST_PASS, _msg_, __LINE__, __FILE__) |
| 0 | 115 |
| 116 #define CYG_TEST_FAIL( _msg_ ) \ | |
| 2 | 117 cyg_test_output(CYGNUM_TEST_FAIL, _msg_, __LINE__, __FILE__) |
| 0 | 118 |
| 119 #define CYG_TEST_EXIT( _msg_ ) \ | |
| 2 | 120 (cyg_test_output(CYGNUM_TEST_EXIT, _msg_, __LINE__, __FILE__), \ |
| 0 | 121 cyg_test_exit()) |
| 122 | |
| 2 | 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 | |
| 0 | 145 #ifdef CYG_COMPOUND_TEST |
| 2 | 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 | |
| 0 | 151 #else |
| 2 | 152 # define CYG_TEST_FINISH( _msg_ ) CYG_TEST_EXIT( _msg_ ) |
| 0 | 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_ ) \ | |
| 2 | 161 CYG_MACRO_START \ |
| 162 CYG_TEST_PASS( _msg_ ); \ | |
| 163 CYG_TEST_FINISH("done"); \ | |
| 164 CYG_MACRO_END | |
| 0 | 165 |
| 166 #define CYG_TEST_FAIL_FINISH( _msg_ ) \ | |
| 2 | 167 CYG_MACRO_START \ |
| 168 CYG_TEST_FAIL( _msg_ ); \ | |
| 169 CYG_TEST_FINISH("done"); \ | |
| 170 CYG_MACRO_END | |
| 0 | 171 |
| 172 | |
| 2 | 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 | |
| 0 | 177 |
| 2 | 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 | |
| 0 | 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. | |
| 2 | 188 #define CYG_TEST_PASS_EXIT( _msg_ ) \ |
| 189 (cyg_test_output(CYGNUM_TEST_PASS, _msg_, __LINE__, __FILE__), \ | |
| 0 | 190 CYG_TEST_EXIT("done")) |
| 191 | |
| 2 | 192 #define CYG_TEST_FAIL_EXIT( _msg_ ) \ |
| 193 (cyg_test_output(CYGNUM_TEST_FAIL, _msg_, __LINE__, __FILE__), \ | |
| 0 | 194 CYG_TEST_EXIT("done")) |
| 195 | |
| 196 | |
| 197 #endif // CYGONCE_INFRA_TESTCASE_H | |
| 198 // EOF testcase.h |
