> -----Original Message-----
> From: Martin Sebor [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 03, 2006 5:48 PM
> To: [email protected]
> Subject: Re: testsuite process helpers
>
[...]
> Okay, let's go with it. How about
>
> rw_enable(int(*)(int, int, const char*, const char*, ...),
> bool = true);
>
> so that we can simply call it like so:
>
> rw_enable(rw_error, false); // disable errors
> rw_enable(rw_note); // enable notes
>
> and we don't have to move diag_t into driver.h.
The patch is attached.
ChangeLog:
* driver.h (rw_enable): New function to enable/disable
specified diagnostics
* driver.cpp (rw_enable): New function to enable/disable
specified diagnostics
(_rw_vdiag): Added checking whether the diagnostic
is enabled or disabled
* opt_trace.h: Added declaration of the _rw_ignore_mask variable
* opt_trace.cpp: Added definition of the _rw_ignore_mask variable
Farid.
Index: include/driver.h
===================================================================
--- include/driver.h (revision 465232)
+++ include/driver.h (working copy)
@@ -151,4 +151,14 @@
_TEST_EXPORT int
rw_info (int, const char*, int, const char*, ...);
+/**
+* Enable/disable the specified diagnostics
+*
+* Example:
+* rw_enable (rw_error, false); // disable all rw_error diagnostics
+* rw_enable (rw_error); // enable all rw_error diagnostics
+*/
+_TEST_EXPORT void
+rw_enable (int (*) (int, const char*, int, const char*, ...), bool = true);
+
#endif // RW_DRIVER_H_INCLUDED
Index: src/driver.cpp
===================================================================
--- src/driver.cpp (revision 465232)
+++ src/driver.cpp (working copy)
@@ -1378,6 +1378,9 @@
_rw_vdiag (diag_t diag, int severity, const char *file, int line,
const char *fmt, va_list va)
{
+ if (_rw_ignore_mask & (1 << diag))
+ return;
+
CHECK_INIT (true, "_rw_vdiag()");
// check if the diagnostic is expected
@@ -1535,3 +1538,36 @@
return success;
}
+
+/************************************************************************/
+
+_TEST_EXPORT void
+rw_enable (int (*fun) (int, const char*, int, const char*, ...), bool enable)
+{
+ diag_t diag;
+
+ if (&rw_fatal == fun)
+ diag = diag_fatal;
+ else if (&rw_error == fun)
+ diag = diag_error;
+ else if (&rw_assert == fun)
+ diag = diag_assert;
+ else if (&rw_warn == fun)
+ diag = diag_warn;
+ else if (&rw_note == fun)
+ diag = diag_note;
+ else if (&rw_info == fun)
+ diag = diag_info;
+ else {
+ RW_ASSERT (!"Invalid function in rw_enable");
+ return;
+ }
+
+ //
+ //if (enable)
+ // _rw_ignore_mask &= ~(1 << diag);
+ //else
+ // _rw_ignore_mask |= 1 << diag;
+ //
+ _rw_ignore_mask ^= (-enable ^ _rw_ignore_mask) & (1 << diag);
+}
Index: src/opt_trace.cpp
===================================================================
--- src/opt_trace.cpp (revision 465232)
+++ src/opt_trace.cpp (working copy)
@@ -33,7 +33,10 @@
// masked diagnostics (those that shouldn't be issued)
int _rw_diag_mask = 1 << diag_trace;
+// masked diagnostics (those that should be ignored)
+int _rw_ignore_mask = 0;
+
int
_rw_setopt_trace_mask (int argc, char *argv[])
{
Index: src/opt_trace.h
===================================================================
--- src/opt_trace.h (revision 465232)
+++ src/opt_trace.h (working copy)
@@ -30,7 +30,11 @@
extern int
_rw_diag_mask;
+// ignored diagnostics mask
+extern int
+_rw_ignore_mask;
+
int
_rw_setopt_trace_mask (int argc, char *argv[]);