report: introduce report_info
Subsystems (2)
PATCH 1/1 report: introduce report_info
Test writers sometimes want to output informational messages, but they don't want to use printf because they want the prefixes as well. Rather than creating "fake" tests that always pass, with report(fmt, true, ...), provide report_info(fmt, ...). This generates 'INFO: prefixes...: message'
While touching report code also add the lock to report_abort to ensure its output line integrity.
--- lib/libcflat.h | 1 + lib/report.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)
lib/libcflat.h +1 -0
@@ -82,6 +82,7 @@ extern void report(const char *msg_fmt, bool pass, ...);extern void report_xfail (const char *msg_fmt,bool xfail,bool pass, ...);extern void report_abort (const char *msg_fmt, ...);extern void report_skip (const char *msg_fmt, ...); +extern void report_info (const char *msg_fmt, ...);extern int report_summary (void );extern void dump_stack (void );
lib/report.c +16 -0
@@ -91,6 +91,20 @@ void report_skip(const char *msg_fmt, ...)va_end (va); } +void report_info (const char *msg_fmt, ...) +{ +va_list va; + +spin_lock (&lock); +puts ("INFO: " ); +puts (prefixes); +va_start (va, msg_fmt); +vprintf (msg_fmt, va); +va_end (va); +puts ("\n" ); +spin_unlock (&lock); +} +int report_summary (void ) {spin_lock (&lock);
@@ -118,12 +132,14 @@ void report_abort(const char *msg_fmt, ...) {va_list va; +spin_lock (&lock);puts ("ABORT: " );puts (prefixes);va_start (va, msg_fmt);vprintf (msg_fmt, va);va_end (va);puts ("\n" ); +spin_unlock (&lock);report_summary ();abort (); }
Signature · 1 line
2.7.4
Quoted 8 lines · Andrew Jones
Test writers sometimes want to output informational messages, but they don't want to use printf because they want the prefixes as well. Rather than creating "fake" tests that always pass, with
report(fmt, true, ...), providereport_info(fmt, ...). This generates 'INFO: prefixes...: message'While touching report code also add the lock to
report_abortto ensure its output line integrity.
Since repor_abort() is a different topic, I'd suggest to move that hunk into a different patch instead.
Thomas
Quoted 7 lines · Thomas Huth
Quoted 6 lines · Andrew Jones
Test writers sometimes want to output informational messages, but they don't want to use printf because they want the prefixes as well. Rather than creating "fake" tests that always pass, with
report(fmt, true, ...), providereport_info(fmt, ...). This generates 'INFO: prefixes...: message'
Quoted 5 lines
Quoted 2 lines
While touching report code also add the lock to
report_abortto ensure its output line integrity.Since
repor_abort()is a different topic, I'd suggest to move that hunk into a different patch instead.
Yeah, I was being a big lazy there. I can respin with lazy-mode disabled, if you like, but I'll stay lazy just a little longer to see if Radim/Paolo take it as is :-)
Thanks,
drew
Quoted 7 lines
Thomas
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
2016-11-18 15:26+0100, Andrew Jones:
Quoted 11 lines · Thomas Huth
Quoted 10 lines · Andrew Jones
Quoted 8 lines
Test writers sometimes want to output informational messages, but they don't want to use printf because they want the prefixes as well. Rather than creating "fake" tests that always pass, with
report(fmt, true, ...), providereport_info(fmt, ...). This generates 'INFO: prefixes...: message'While touching report code also add the lock to
report_abortto ensure its output line integrity.
Quoted 6 lines
Quoted 2 lines
Since
repor_abort()is a different topic, I'd suggest to move that hunk into a different patch instead.Yeah, I was being a big lazy there. I can respin with lazy-mode disabled, if you like, but I'll stay lazy just a little longer to see if Radim/Paolo take it as is :-)
I'd prefer two patches as well. Laziness is good, though ... If you stay lazy for more than a week from now, I'll apply v1 with a note that we all agreed that this is not how patches should be split.