All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Andrew Jones <drjones@redhat.com>
Subject: [kvm-unit-tests PATCH v4 01/13] lib/report: allow test skipping
Date: Wed, 11 May 2016 18:12:43 +0200	[thread overview]
Message-ID: <1462983171-4208-2-git-send-email-rkrcmar@redhat.com> (raw)
In-Reply-To: <1462983171-4208-1-git-send-email-rkrcmar@redhat.com>

We can now explicitly mark a unit-test as skipped.
If all unit-tests were skipped, the whole test is reported as skipped as
well.  This also includes the case where no tests were run, but still
ended with report_summary().

When the whole test is skipped, ./run_tests.sh prints yellow "SKIP"
instead of green "PASS".

Return value of 77 is used to please Autotools.  I also renamed few
things in reporting code and chose to refactor a logic while at it.

Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 lib/libcflat.h       |  1 +
 lib/report.c         | 45 +++++++++++++++++++++++++++++++--------------
 scripts/runtime.bash |  2 ++
 3 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/lib/libcflat.h b/lib/libcflat.h
index df50615b4366..582e3fc60e28 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -79,6 +79,7 @@ extern void report_prefix_pop(void);
 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 int report_summary(void);
 
 extern void dump_stack(void);
diff --git a/lib/report.c b/lib/report.c
index 9e45781ee2ab..430b2aeaecbd 100644
--- a/lib/report.c
+++ b/lib/report.c
@@ -13,7 +13,7 @@
 #include "libcflat.h"
 #include "asm/spinlock.h"
 
-static unsigned int tests, failures, xfailures;
+static unsigned int tests, failures, xfailures, skipped;
 static char prefixes[256];
 static struct spinlock lock;
 
@@ -43,23 +43,25 @@ void report_prefix_pop(void)
 	spin_unlock(&lock);
 }
 
-void va_report_xfail(const char *msg_fmt, bool xfail, bool cond, va_list va)
+static void va_report(const char *msg_fmt,
+		bool pass, bool xfail, bool skip, va_list va)
 {
-	char *pass = xfail ? "XPASS" : "PASS";
-	char *fail = xfail ? "XFAIL" : "FAIL";
+	char *prefix = skip ? "SKIP"
+	                    : xfail ? (pass ? "XPASS" : "XFAIL")
+	                            : (pass ? "PASS"  : "FAIL");
 
 	spin_lock(&lock);
 
 	tests++;
-	printf("%s: ", cond ? pass : fail);
+	printf("%s: ", prefix);
 	puts(prefixes);
 	vprintf(msg_fmt, va);
 	puts("\n");
-	if (xfail && cond)
-		failures++;
-	else if (xfail)
+	if (skip)
+		skipped++;
+	else if (xfail && !pass)
 		xfailures++;
-	else if (!cond)
+	else if (xfail || !pass)
 		failures++;
 
 	spin_unlock(&lock);
@@ -69,7 +71,7 @@ void report(const char *msg_fmt, bool pass, ...)
 {
 	va_list va;
 	va_start(va, pass);
-	va_report_xfail(msg_fmt, false, pass, va);
+	va_report(msg_fmt, pass, false, false, va);
 	va_end(va);
 }
 
@@ -77,7 +79,15 @@ void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...)
 {
 	va_list va;
 	va_start(va, pass);
-	va_report_xfail(msg_fmt, xfail, pass, va);
+	va_report(msg_fmt, pass, xfail, false, va);
+	va_end(va);
+}
+
+void report_skip(const char *msg_fmt, ...)
+{
+	va_list va;
+	va_start(va, msg_fmt);
+	va_report(msg_fmt, false, false, true, va);
 	va_end(va);
 }
 
@@ -87,9 +97,16 @@ int report_summary(void)
 
 	printf("\nSUMMARY: %d tests, %d unexpected failures", tests, failures);
 	if (xfailures)
-		printf(", %d expected failures\n", xfailures);
-	else
-		printf("\n");
+		printf(", %d expected failures", xfailures);
+	if (skipped)
+		printf(", %d skipped", skipped);
+	printf("\n");
+
+	if (tests == skipped)
+		/* Blame AUTOTOOLS for using 77 for skipped test and QEMU for
+		 * mangling error codes in a way that gets 77 if we ... */
+		return 77 >> 1;
+
 	return failures > 0 ? 1 : 0;
 
 	spin_unlock(&lock);
diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index 0e055f0dddc2..ed073721216c 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -51,6 +51,8 @@ function run()
 
     if [ $ret -eq 0 ]; then
         echo -e "\e[32mPASS\e[0m $1"
+    elif [ $ret -eq 77 ]; then
+        echo -e "\e[33mSKIP\e[0m $1"
     elif [ $ret -eq 124 ]; then
         echo -e "\e[31mFAIL\e[0m $1 (timeout; duration=$timeout)"
     else
-- 
2.8.2


  reply	other threads:[~2016-05-11 16:13 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 16:12 [kvm-unit-tests PATCH v4 00/13] Improve the output of test runners Radim Krčmář
2016-05-11 16:12 ` Radim Krčmář [this message]
2016-05-11 16:12 ` [kvm-unit-tests PATCH v4 02/13] x86/*: report skipped tests Radim Krčmář
2016-05-17 12:19   ` Paolo Bonzini
2016-05-25 17:19     ` Radim Krčmář
2016-05-25 17:23       ` Radim Krčmář
2016-05-26  7:22         ` Paolo Bonzini
2016-05-11 16:12 ` [kvm-unit-tests PATCH v4 03/13] x86/unittests: remove svm-disabled Radim Krčmář
2016-05-11 16:12 ` [kvm-unit-tests PATCH v4 04/13] lib/string: add strncmp Radim Krčmář
2016-05-11 16:33   ` Andrew Jones
2016-05-11 16:12 ` [kvm-unit-tests PATCH v4 05/13] lib/util: add args_parse_keyval Radim Krčmář
2016-05-11 16:58   ` Andrew Jones
2016-05-11 17:19     ` Radim Krčmář
2016-05-11 17:23   ` Andrew Jones
2016-05-11 16:12 ` [kvm-unit-tests PATCH v4 06/13] x86/pmu: expect failure with nmi_watchdog Radim Krčmář
2016-05-11 17:00   ` Andrew Jones
2016-05-11 16:12 ` [kvm-unit-tests PATCH v4 07/13] lib/report: don't print 0 failed tests Radim Krčmář
2016-05-11 16:12 ` [kvm-unit-tests PATCH v4 08/13] scripts/runtime: consolidate summary tags Radim Krčmář
2016-05-17 12:22   ` Paolo Bonzini
2016-05-25 17:46     ` Radim Krčmář
2016-05-11 16:12 ` [kvm-unit-tests PATCH v4 09/13] run_tests: print SUMMARY line in summary Radim Krčmář
2016-05-11 17:10   ` Andrew Jones
2016-05-17 12:32   ` Paolo Bonzini
2016-05-25 17:41     ` Radim Krčmář
2016-05-11 16:30 ` [kvm-unit-tests PATCH v4 10/13] run_tests: log stderr Radim Krčmář
2016-05-11 16:30   ` [kvm-unit-tests PATCH v4 11/13] scripts/runtime: skip tests that cannot run Radim Krčmář
2016-05-11 17:20     ` Andrew Jones
2016-05-11 16:30   ` [kvm-unit-tests PATCH v4 12/13] scripts/arch-run: change QEMU failure detection Radim Krčmář
2016-05-11 17:24     ` Andrew Jones
2016-05-11 16:30   ` [kvm-unit-tests PATCH v4 13/13] scripts/run: generalize check Radim Krčmář
2016-05-11 17:31     ` Andrew Jones
2016-05-11 17:11   ` [kvm-unit-tests PATCH v4 10/13] run_tests: log stderr Andrew Jones
2016-05-17 12:29 ` [kvm-unit-tests PATCH v4 00/13] Improve the output of test runners Paolo Bonzini
2016-05-25 17:49   ` Radim Krčmář
2016-05-26  7:25     ` Paolo Bonzini

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=1462983171-4208-2-git-send-email-rkrcmar@redhat.com \
    --to=rkrcmar@redhat.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.