aboutsummaryrefslogtreecommitdiff
path: root/dejagnu.h
diff options
context:
space:
mode:
authorRob Savoye <rob@welcomehome.org>2002-06-06 15:31:13 +0000
committerRob Savoye <rob@welcomehome.org>2002-06-06 15:31:13 +0000
commitb60e445ac5a1a3b611a1671f78d5f2614167c06e (patch)
tree0a6dc9416c946cac1c02ade6eec44946b6403da0 /dejagnu.h
parent206ac19bab8dbc170bc453da106bb803ac665aa4 (diff)
downloaddejagnu-b60e445ac5a1a3b611a1671f78d5f2614167c06e.zip
dejagnu-b60e445ac5a1a3b611a1671f78d5f2614167c06e.tar.gz
dejagnu-b60e445ac5a1a3b611a1671f78d5f2614167c06e.tar.bz2
Wed Jun 5 14:52:15 PDT 2002 Joey Ekstrom <joey@ekstrom.org>
* 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.
Diffstat (limited to 'dejagnu.h')
-rw-r--r--dejagnu.h98
1 files changed, 88 insertions, 10 deletions
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 <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