Wed Jun 5 14:52:15 PDT 2002 Joey Ekstrom <joey@ekstrom.org>
authorRob Savoye <rob@welcomehome.org>
Thu, 6 Jun 2002 15:31:13 +0000 (15:31 +0000)
committerRob Savoye <rob@welcomehome.org>
Thu, 6 Jun 2002 15:31:13 +0000 (15:31 +0000)
       * 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.

dejagnu.h

index 3e78873..121ab1c 100644 (file)
--- 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
 #define __DEJAGNU_H__
 
 #include <stdio.h>
+#include <stdarg.h> 
+#include <string.h>
+
+/* If you have problems with dejagnu dropping failed, untested, or 
+ * unresolved messages generated by a unit testcase, 
+ */
+
+/* #define _DEJAGNU_WAIT_ 
+ */
+
+#ifdef _DEJAGNU_WAIT_
+#      include <sys/time.h>
+#      include <sys/types.h>
+#      include <unistd.h>
+#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