From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: rkrcmar@redhat.com, pbonzini@redhat.com, lvivier@redhat.com,
thuth@redhat.com, andre.przywara@arm.com
Subject: [kvm-unit-tests PATCH] report: introduce report_info
Date: Fri, 18 Nov 2016 14:35:54 +0100 [thread overview]
Message-ID: <1479476154-25596-1-git-send-email-drjones@redhat.com> (raw)
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
next reply other threads:[~2016-11-18 13:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-18 13:35 Andrew Jones [this message]
2016-11-18 14:20 ` [kvm-unit-tests PATCH] report: introduce report_info Thomas Huth
2016-11-18 14:26 ` Andrew Jones
2016-11-22 13:32 ` Radim Krčmář
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1479476154-25596-1-git-send-email-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=andre.przywara@arm.com \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox