public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH kvm-unit-tests] report: add report_xfail for expected failures
@ 2014-06-17 14:36 Andrew Jones
  2014-06-17 18:46 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Jones @ 2014-06-17 14:36 UTC (permalink / raw)
  To: pbonzini, jan.kiszka; +Cc: kvm

Add report_xfail(), which is report(), but with another condition
allowing it to output PASS/FAIL/XPASS/XFAIL, rather than only
PASS/FAIL. This allows report output to stay more consistent
between systems/configurations that may or may not support all
tests.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/libcflat.h |  1 +
 lib/report.c   | 37 +++++++++++++++++++++++++++++--------
 2 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/lib/libcflat.h b/lib/libcflat.h
index cb6663d33ef5a..c9577350ec275 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -63,5 +63,6 @@ extern long atol(const char *ptr);
 #define NULL ((void *)0UL)
 
 void report(const char *msg_fmt, bool pass, ...);
+void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
 int report_summary(void);
 #endif
diff --git a/lib/report.c b/lib/report.c
index ff562a13c541e..43d7a65ec8812 100644
--- a/lib/report.c
+++ b/lib/report.c
@@ -5,32 +5,53 @@
  *
  * Authors:
  *  Jan Kiszka <jan.kiszka@siemens.com>
+ *  Andrew Jones <drjones@redhat.com>
  *
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
 
 #include "libcflat.h"
 
-static unsigned int tests, failures;
+static unsigned int tests, failures, xfailures;
 
-void report(const char *msg_fmt, bool pass, ...)
+void va_report_xfail(const char *msg_fmt, bool xfail, bool cond, va_list va)
 {
+	char *pass = xfail ? "XPASS" : "PASS";
+	char *fail = xfail ? "XFAIL" : "FAIL";
 	char buf[2000];
-	va_list va;
 
 	tests++;
-	printf("%s: ", pass ? "PASS" : "FAIL");
-	va_start(va, pass);
+	printf("%s: ", cond ? pass : fail);
 	vsnprintf(buf, sizeof(buf), msg_fmt, va);
-	va_end(va);
 	puts(buf);
 	puts("\n");
-	if (!pass)
+	if (xfail && cond)
+		failures++;
+	else if (xfail)
+		xfailures++;
+	else if (!cond)
 		failures++;
 }
 
+void report(const char *msg_fmt, bool pass, ...)
+{
+	va_list va;
+	va_start(va, pass);
+	va_report_xfail(msg_fmt, false, pass, va);
+	va_end(va);
+}
+
+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_end(va);
+}
+
 int report_summary(void)
 {
-	printf("\nSUMMARY: %d tests, %d failures\n", tests, failures);
+	printf("\nSUMMARY: %d tests, %d failures, %d xfailures\n",
+		tests, failures, xfailures);
 	return failures > 0 ? 1 : 0;
 }
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH kvm-unit-tests] report: add report_xfail for expected failures
  2014-06-17 14:36 [PATCH kvm-unit-tests] report: add report_xfail for expected failures Andrew Jones
@ 2014-06-17 18:46 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2014-06-17 18:46 UTC (permalink / raw)
  To: Andrew Jones, jan.kiszka; +Cc: kvm

Il 17/06/2014 16:36, Andrew Jones ha scritto:
> Add report_xfail(), which is report(), but with another condition
> allowing it to output PASS/FAIL/XPASS/XFAIL, rather than only
> PASS/FAIL. This allows report output to stay more consistent
> between systems/configurations that may or may not support all
> tests.
>
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  lib/libcflat.h |  1 +
>  lib/report.c   | 37 +++++++++++++++++++++++++++++--------
>  2 files changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/lib/libcflat.h b/lib/libcflat.h
> index cb6663d33ef5a..c9577350ec275 100644
> --- a/lib/libcflat.h
> +++ b/lib/libcflat.h
> @@ -63,5 +63,6 @@ extern long atol(const char *ptr);
>  #define NULL ((void *)0UL)
>
>  void report(const char *msg_fmt, bool pass, ...);
> +void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
>  int report_summary(void);
>  #endif
> diff --git a/lib/report.c b/lib/report.c
> index ff562a13c541e..43d7a65ec8812 100644
> --- a/lib/report.c
> +++ b/lib/report.c
> @@ -5,32 +5,53 @@
>   *
>   * Authors:
>   *  Jan Kiszka <jan.kiszka@siemens.com>
> + *  Andrew Jones <drjones@redhat.com>
>   *
>   * This work is licensed under the terms of the GNU LGPL, version 2.
>   */
>
>  #include "libcflat.h"
>
> -static unsigned int tests, failures;
> +static unsigned int tests, failures, xfailures;
>
> -void report(const char *msg_fmt, bool pass, ...)
> +void va_report_xfail(const char *msg_fmt, bool xfail, bool cond, va_list va)
>  {
> +	char *pass = xfail ? "XPASS" : "PASS";
> +	char *fail = xfail ? "XFAIL" : "FAIL";
>  	char buf[2000];
> -	va_list va;
>
>  	tests++;
> -	printf("%s: ", pass ? "PASS" : "FAIL");
> -	va_start(va, pass);
> +	printf("%s: ", cond ? pass : fail);
>  	vsnprintf(buf, sizeof(buf), msg_fmt, va);
> -	va_end(va);
>  	puts(buf);
>  	puts("\n");
> -	if (!pass)
> +	if (xfail && cond)
> +		failures++;
> +	else if (xfail)
> +		xfailures++;
> +	else if (!cond)
>  		failures++;
>  }
>
> +void report(const char *msg_fmt, bool pass, ...)
> +{
> +	va_list va;
> +	va_start(va, pass);
> +	va_report_xfail(msg_fmt, false, pass, va);
> +	va_end(va);
> +}
> +
> +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_end(va);
> +}
> +
>  int report_summary(void)
>  {
> -	printf("\nSUMMARY: %d tests, %d failures\n", tests, failures);
> +	printf("\nSUMMARY: %d tests, %d failures, %d xfailures\n",
> +		tests, failures, xfailures);
>  	return failures > 0 ? 1 : 0;
>  }
>

Looks good, will apply in the next few days.

Paolo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-17 18:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-17 14:36 [PATCH kvm-unit-tests] report: add report_xfail for expected failures Andrew Jones
2014-06-17 18:46 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox