2
* Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
/* If you have problems with dejagnu dropping failed, untested, or
27
* unresolved messages generated by a unit testcase,
30
/* #define _DEJAGNU_WAIT_
34
# include <sys/time.h>
35
# include <sys/types.h>
39
#define _BUFFER_SIZE_ 512
46
static char buffer[ _BUFFER_SIZE_ ];
58
select(0, &rfds, NULL, NULL, &tv);
63
pass (const char* fmt, ... ) {
68
vsnprintf( buffer, _BUFFER_SIZE_, fmt, ap );
70
printf ("\tPASSED: %s\n", buffer );
77
fail (const char* fmt, ... ) {
82
vsnprintf( buffer, _BUFFER_SIZE_, fmt, ap );
84
printf ("\tFAILED: %s\n", buffer );
91
untested (const char* fmt, ... ) {
96
vsnprintf( buffer, _BUFFER_SIZE_, fmt, ap );
98
printf ("\tUNTESTED: %s\n", buffer );
105
unresolved (const char* fmt, ... ) {
110
vsnprintf( buffer, _BUFFER_SIZE_, fmt, ap );
112
printf ("\tUNRESOLVED: %s\n", buffer );
113
#ifdef _DEJAGNU_WAIT_
119
note (const char* fmt, ... ) {
123
vsnprintf( buffer, _BUFFER_SIZE_, fmt, ap );
125
printf ("\tNOTE: %s\n", buffer );
126
#ifdef _DEJAGNU_WAIT_
133
printf ("\nTotals:\n");
134
printf ("\t#passed:\t\t%d\n", passed);
135
printf ("\t#failed:\t\t%d\n", failed);
137
printf ("\t#untested:\t\t%d\n", untest);
139
printf ("\t#unresolved:\t\t%d\n", unresolved);
157
const char *outstate_list[] = {
164
const char ** outstate = outstate_list;
167
extern ios& __iomanip_testout (ios&, int);
168
inline smanip<int> testout (int n) {
169
return smanip<int> (__iomanip_testout, n);
171
ios & __iomanip_testout (ios& i, int x) {
179
ostream &(*f)(ostream&, T);
181
OMANIP(ostream& (*ff)(ostream&, T), T ii) : f(ff), i(ii) {
183
friend ostream operator<<(ostream& us, OMANIP& m) {
189
freakout(ostream& os, int x) {
190
return os << "FREAKOUT" ;
191
// return x << "TESTOUT " << x ;
194
OMANIP<int> testout(int i) {
195
return OMANIP<int>(&freakout,i);
199
enum teststate {FAILED, PASSED,UNTESTED,UNRESOLVED} laststate;
216
void testrun (bool b, std::string s) {
223
void pass (std::string s) {
227
std::cout << "\t" << outstate[PASSED] << s << std::endl;
229
void pass (const char *c) {
234
void fail (std::string s) {
238
std::cout << "\t" << outstate[FAILED] << s << std::endl;
240
void fail (const char *c) {
245
void untested (std::string s) {
247
laststate = UNTESTED;
249
std::cout << "\t" << outstate[UNTESTED] << s << std::endl;
251
void untested (const char *c) {
256
void unresolved (std::string s) {
258
laststate = UNRESOLVED;
260
std::cout << "\t" << outstate[UNRESOLVED] << s << std::endl;
262
void unresolved (const char *c) {
268
std::cout << "\t#passed:\t\t" << passed << std::endl;
269
std::cout << "\t#failed:\t\t" << failed << std::endl;
271
std::cout << "\t#untested:\t\t" << untest << std::endl;
273
std::cout << "\t#unresolved:\t\t" << unresolve << std::endl;
276
// This is so this class can be printed in an ostream.
277
friend std::ostream & operator << (std::ostream &os, TestState& t) {
278
return os << "\t" << outstate[t.laststate] << t.lastmsg ;
284
std::string GetMsg(void) {
289
#endif // __cplusplus
290
#endif // _DEJAGNU_H_