/*
- * 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
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