From d807904c119232226a7f644b6a5ebdbb1ed2a67d Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Tue, 20 Dec 2022 22:27:28 -0600 Subject: Add support for reporting errors and warnings in dejagnu.h --- dejagnu.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'dejagnu.h') diff --git a/dejagnu.h b/dejagnu.h index 282b072..140e3e9 100644 --- a/dejagnu.h +++ b/dejagnu.h @@ -177,6 +177,34 @@ note (const char* fmt, ...) } static inline void +DG_error (const char* fmt, ...) +{ + va_list ap; + + DG__init (); + + flockfile (stdout); + fputs ("\tERROR: ", stdout); + va_start (ap, fmt); vfprintf (stdout, fmt, ap); va_end (ap); + fputc ('\n', stdout); + funlockfile (stdout); +} + +static inline void +DG_warning (const char* fmt, ...) +{ + va_list ap; + + DG__init (); + + flockfile (stdout); + fputs ("\tWARNING: ", stdout); + va_start (ap, fmt); vfprintf (stdout, fmt, ap); va_end (ap); + fputc ('\n', stdout); + funlockfile (stdout); +} + +static inline void totals (void) { printf ("\nTotals:\n"); @@ -316,6 +344,16 @@ class TestState { std::cout << "\t" << "NOTE: " << s << std::endl; } + void error (std::string s) + { + std::cout << "\t" << "ERROR: " << s << std::endl; + } + + void warning (std::string s) + { + std::cout << "\t" << "WARNING: " << s << std::endl; + } + void totals (void) { std::cout << std::endl << "Totals:" << std::endl; -- cgit v1.1