* [kvm-unit-tests PATCH] report: introduce report_info
@ 2016-11-18 13:35 Andrew Jones
2016-11-18 14:20 ` Thomas Huth
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Jones @ 2016-11-18 13:35 UTC (permalink / raw)
To: kvm; +Cc: rkrcmar, pbonzini, lvivier, thuth, andre.przywara
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.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
lib/libcflat.h | 1 +
lib/report.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/lib/libcflat.h b/lib/libcflat.h
index 72b1bf9668ef..c622198677c1 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -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);
diff --git a/lib/report.c b/lib/report.c
index 4cd75534f978..fc0ef494f412 100644
--- a/lib/report.c
+++ b/lib/report.c
@@ -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();
}
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [kvm-unit-tests PATCH] report: introduce report_info
2016-11-18 13:35 [kvm-unit-tests PATCH] report: introduce report_info Andrew Jones
@ 2016-11-18 14:20 ` Thomas Huth
2016-11-18 14:26 ` Andrew Jones
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Huth @ 2016-11-18 14:20 UTC (permalink / raw)
To: Andrew Jones, kvm; +Cc: rkrcmar, pbonzini, lvivier, andre.przywara
On 18.11.2016 14:35, Andrew Jones wrote:
> 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.
Since repor_abort() is a different topic, I'd suggest to move that hunk
into a different patch instead.
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [kvm-unit-tests PATCH] report: introduce report_info
2016-11-18 14:20 ` Thomas Huth
@ 2016-11-18 14:26 ` Andrew Jones
2016-11-22 13:32 ` Radim Krčmář
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Jones @ 2016-11-18 14:26 UTC (permalink / raw)
To: Thomas Huth; +Cc: kvm, rkrcmar, pbonzini, lvivier, andre.przywara
On Fri, Nov 18, 2016 at 03:20:24PM +0100, Thomas Huth wrote:
> On 18.11.2016 14:35, Andrew Jones wrote:
> > 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.
>
> 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
>
> Thomas
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [kvm-unit-tests PATCH] report: introduce report_info
2016-11-18 14:26 ` Andrew Jones
@ 2016-11-22 13:32 ` Radim Krčmář
0 siblings, 0 replies; 4+ messages in thread
From: Radim Krčmář @ 2016-11-22 13:32 UTC (permalink / raw)
To: Andrew Jones; +Cc: Thomas Huth, kvm, pbonzini, lvivier, andre.przywara
2016-11-18 15:26+0100, Andrew Jones:
> On Fri, Nov 18, 2016 at 03:20:24PM +0100, Thomas Huth wrote:
>> On 18.11.2016 14:35, Andrew Jones wrote:
>> > 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.
>>
>> 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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-22 13:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-18 13:35 [kvm-unit-tests PATCH] report: introduce report_info Andrew Jones
2016-11-18 14:20 ` Thomas Huth
2016-11-18 14:26 ` Andrew Jones
2016-11-22 13:32 ` Radim Krčmář
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox