From: Rob Savoye Date: Thu, 6 Jun 2002 15:31:13 +0000 (+0000) Subject: Wed Jun 5 14:52:15 PDT 2002 Joey Ekstrom X-Git-Tag: upstream/1.6.2~566 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b60e445ac5a1a3b611a1671f78d5f2614167c06e;p=platform%2Fupstream%2Fdejagnu.git Wed Jun 5 14:52:15 PDT 2002 Joey Ekstrom * dejagnu.h: modfied C functions to behave like printf. * dejagnu.h: added wait() to fix problem with host_execute() in dejagnu.exp where if skips failed, untested, etc. messages from the executable. --- diff --git a/dejagnu.h b/dejagnu.h index 3e78873..121ab1c 100644 --- a/dejagnu.h +++ b/dejagnu.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000, 2001 Free Software Foundation, Inc. + * Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,34 +20,112 @@ #define __DEJAGNU_H__ #include +#include +#include + +/* If you have problems with dejagnu dropping failed, untested, or + * unresolved messages generated by a unit testcase, + */ + +/* #define _DEJAGNU_WAIT_ + */ + +#ifdef _DEJAGNU_WAIT_ +# include +# include +# include +#endif + +#define _BUFFER_SIZE_ 512 static int passed; static int failed; static int untest; static int unresolve; +static char buffer[ _BUFFER_SIZE_ ]; + +#ifdef _DEJAGNU_WAIT_ +void +wait(void) { + fd_set rfds; + struct timeval tv; + + FD_ZERO(&rfds); + tv.tv_sec = 0; + tv.tv_usec = 1; + + select(0, &rfds, NULL, NULL, &tv); +} +#endif + inline void -pass (const char *s) { +pass (const char* fmt, ... ) { + va_list ap; + passed++; - printf ("\tPASSED: %s\n", s); + va_start( ap, fmt ); + vsnprintf( buffer, _BUFFER_SIZE_, fmt, ap ); + va_end( ap ); + printf ("\tPASSED: %s\n", buffer ); +#ifdef _DEJAGNU_WAIT_ + wait(); +#endif } inline void -fail (const char *s) { +fail (const char* fmt, ... ) { + va_list ap; + failed++; - printf ("\tFAILED: %s\n", s); + va_start( ap, fmt ); + vsnprintf( buffer, _BUFFER_SIZE_, fmt, ap ); + va_end( ap ); + printf ("\tFAILED: %s\n", buffer ); +#ifdef _DEJAGNU_WAIT_ + wait(); +#endif } inline void -untested (const char *s) { +untested (const char* fmt, ... ) { + va_list ap; + untest++; - printf ("\tUNTESTED: %s\n", s); + va_start( ap, fmt ); + vsnprintf( buffer, _BUFFER_SIZE_, fmt, ap ); + va_end( ap ); + printf ("\tUNTESTED: %s\n", buffer ); +#ifdef _DEJAGNU_WAIT_ + wait(); +#endif } inline void -unresolved (const char *s) { +unresolved (const char* fmt, ... ) { + va_list ap; + unresolve++; - printf ("\tUNRESOLVED: %s\n", s); + va_start( ap, fmt ); + vsnprintf( buffer, _BUFFER_SIZE_, fmt, ap ); + va_end( ap ); + printf ("\tUNRESOLVED: %s\n", buffer ); +#ifdef _DEJAGNU_WAIT_ + wait(); +#endif +} + +inline void +note (const char* fmt, ... ) { + va_list ap; + + va_start( ap, fmt ); + vsnprintf( buffer, _BUFFER_SIZE_, fmt, ap ); + va_end( ap ); + printf ("\tNOTE: %s\n", buffer ); +#ifdef _DEJAGNU_WAIT_ + wait(); +#endif } inline void @@ -58,7 +136,7 @@ totals (void) { if (untest) printf ("\t#untested:\t\t%d\n", untest); if (unresolve) - printf ("\t#unresolved:\t\t%d\n", unresolve); + printf ("\t#unresolved:\t\t%d\n", unresolved); } #ifdef __cplusplus