Skip to contentSkip to conversation

Improve the output of test runners

PATCH Superseded Radim Krčmář 3 participants 33 messages Apr 15, 2016 – May 10, 2016

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Improve the output of test runners

v2: http://www.spinics.net/lists/kvm/msg125429.html

mkstandalone is using generic code now, so v3 focuses on the output again. And the output looks like in v2. Since v2, I've
* removed svm-disabled [3/7]
* reworked summary reporting [8/9] (it's a nice feature, but still ugly)
* turned all cases when QEMU won't run the test into SKIP [6/7]
* preserved check_param (it's not used, though)
* stopped returning 77 on all SKIPs [7/7] (a sacrifice to prevent another refactoring of our scripts)

I didn't manage to look at the comment from Lukáš's patches, but I don't expect that v3 will be the last one ... a lot has changed since v2.

Radim Krčmář (9):
lib/report: allow test skipping
x86/*: report skipped tests
x86/unittests: remove svm-disabled
x86/pmu: expect failure with nmi_watchdog
lib/report: don't print 0 failed tests
scripts/runtime: skip tests that cannot run
scripts/runtime: consolidate summary tags
run_tests: print summary
run_tests: log stderr

 lib/libcflat.h          |  1 +
 lib/report.c            | 49 ++++++++++++++++++++++++++++++++++---------------
 run_tests.sh            |  7 ++++---
 scripts/mkstandalone.sh |  4 ++++
 scripts/runtime.bash    | 32 +++++++++++++++++++++++++-------
 x86/apic.c              |  7 +++----
 x86/emulator.c          |  2 +-
 x86/hyperv_synic.c      |  2 +-
 x86/pku.c               |  2 +-
 x86/pmu.c               | 11 +++++++++--
 x86/smap.c              |  2 +-
 x86/svm.c               |  2 +-
 x86/tsc.c               |  2 +-
 x86/unittests.cfg       |  9 +--------
 14 files changed, 87 insertions(+), 45 deletions(-)
Signature · 1 line
2.8.1
#1 lore raw

PATCH v3 1/9 lib/report: allow test skipping

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.

---
 lib/libcflat.h       |  1 +
 lib/report.c         | 45 +++++++++++++++++++++++++++++++--------------
 scripts/runtime.bash |  2 ++
 3 files changed, 34 insertions(+), 14 deletions(-)
lib/libcflat.h +1 -0
index df50615b4366..582e3fc60e28 100644
@@ -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);
lib/report.c +31 -14

84 lines not on this page · raw message

scripts/runtime.bash +2 -0
index 0e055f0dddc2..ed073721216c 100644
@@ -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
Signature · 1 line
2.8.1
Reviewed-by on v3 1/9
#2 lore raw

Re: [PATCH v3 1/9] lib/report: allow test skipping

Quoted 109 lines · Radim Krčmář

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.

---
 lib/libcflat.h       |  1 +
 lib/report.c         | 45 +++++++++++++++++++++++++++++++--------------
 scripts/runtime.bash |  2 ++
 3 files changed, 34 insertions(+), 14 deletions(-)
lib/libcflat.h +1 -0
index df50615b4366..582e3fc60e28 100644
@@ -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);
lib/report.c +21 -13
index 9e45781ee2ab..430b2aeaecbd 100644
@@ -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

lib/report.c int report_summary(void) · line 108

Quoted 10 lines
lib/report.c +9 -1
-		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;

Might be nicer to have something like '#define DEBUGEXIT_77 38', but this is also fine by me.

Quoted 19 lines
lib/report.c +1 -0
+
 	return failures > 0 ? 1 : 0;
 
 	spin_unlock(&lock);
scripts/runtime.bash +2 -0
index 0e055f0dddc2..ed073721216c 100644
@@ -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
Signature · 1 line
2.8.1
#3 lore raw

PATCH v3 2/9 x86/*: report skipped tests

In reply to Radim Krčmář

No care to consistency or exhaustivity was given.

---
 x86/apic.c         | 7 +++----
 x86/emulator.c     | 2 +-
 x86/hyperv_synic.c | 2 +-
 x86/pku.c          | 2 +-
 x86/pmu.c          | 2 +-
 x86/smap.c         | 2 +-
 x86/svm.c          | 2 +-
 x86/tsc.c          | 2 +-
 8 files changed, 10 insertions(+), 11 deletions(-)
x86/apic.c +3 -4
index 61a0a7659805..8b08a950a0c7 100644
@@ -27,7 +27,7 @@ static void tsc_deadline_timer_isr(isr_regs_t *regs)
     ++tdt_count;
 }
 
-static void start_tsc_deadline_timer(void)
+static void __test_tsc_deadline_timer(void)
 {
     handle_irq(TSC_DEADLINE_TIMER_VECTOR, tsc_deadline_timer_isr);
     irq_enable();
@@ -45,7 +45,6 @@ static int enable_tsc_deadline_timer(void)
     if (cpuid(1).c & (1 << 24)) {
         lvtt = TSC_DEADLINE_TIMER_MODE | TSC_DEADLINE_TIMER_VECTOR;
         apic_write(APIC_LVTT, lvtt);
-        start_tsc_deadline_timer();
         return 1;
     } else {
         return 0;
@@ -55,9 +54,9 @@ static int enable_tsc_deadline_timer(void)
 static void test_tsc_deadline_timer(void)
 {
     if(enable_tsc_deadline_timer()) {
-        printf("tsc deadline timer enabled\n");
+        __test_tsc_deadline_timer();
     } else {
-        printf("tsc deadline timer not detected\n");
+        report_skip("tsc deadline timer not detected");
     }
 }
 
x86/emulator.c +1 -1
index 3730721258bc..8d262d832112 100644
@@ -1082,7 +1082,7 @@ static void illegal_movbe_handler(struct ex_regs *regs)
 static void test_illegal_movbe(void)
 {
 	if (!(cpuid(1).c & (1 << 22))) {
-		printf("SKIP: illegal movbe\n");
+		report_skip("illegal movbe");
 		return;
 	}
 
x86/hyperv_synic.c +1 -1
index 6e088944be1f..f5eb82bb7336 100644
@@ -202,7 +202,7 @@ int main(int ac, char **av)
 
         report("Hyper-V SynIC test", ok);
     } else {
-        report("Hyper-V SynIC is not supported", true);
+        report_skip("Hyper-V SynIC is not supported");
     }
 
     return report_summary();
x86/pku.c +1 -1
index df51d1b59048..6214f0bc151f 100644
@@ -68,7 +68,7 @@ int main(int ac, char **av)
 
     if (!(cpuid_indexed(7, 0).c & (1 << X86_FEATURE_PKU))) {
         printf("PKU not enabled, aborting\n");
-        abort();
+        return report_summary();
     }
 
     setup_vm();
x86/pmu.c +1 -1
index 03f80190bb25..c68980044dee 100644
@@ -387,7 +387,7 @@ int main(int ac, char **av)
 
 	if (!eax.split.version_id) {
 		printf("No pmu is detected!\n");
-		return 1;
+		return report_summary();
 	}
 	printf("PMU version:         %d\n", eax.split.version_id);
 	printf("GP counters:         %d\n", eax.split.num_counters);
x86/smap.c +1 -1
index 69e71864dc9b..c9de081a474b 100644
@@ -93,7 +93,7 @@ int main(int ac, char **av)
 
 	if (!(cpuid_indexed(7, 0).b & (1 << X86_FEATURE_SMAP))) {
 		printf("SMAP not enabled, aborting\n");
-		abort();
+		return report_summary();
 	}
 
 	setup_vm();
x86/svm.c +1 -1
index 934b2ae91fa8..301cf8cb2d6b 100644
@@ -1064,7 +1064,7 @@ int main(int ac, char **av)
 
     if (!(cpuid(0x80000001).c & 4)) {
         printf("SVM not availble\n");
-        return 0;
+        return report_summary();
     }
 
     setup_svm();
x86/tsc.c +1 -1
index 6f89c911c2bc..62450e71725c 100644
@@ -43,5 +43,5 @@ int main()
 		test_rdtscp(0x100);
 	} else
 		printf("rdtscp not supported\n");
-	return 0;
+	return report_summary();
 }
Signature · 1 line
2.8.1
#4 lore raw

Re: [PATCH v3 2/9] x86/*: report skipped tests

Quoted 1 line · Radim Krčmář

No care to consistency or exhaustivity was given.

Me neither, but I see that x86/tscdeadline_latency.c could use similar updates too.

drew

Quoted 142 lines
---
 x86/apic.c         | 7 +++----
 x86/emulator.c     | 2 +-
 x86/hyperv_synic.c | 2 +-
 x86/pku.c          | 2 +-
 x86/pmu.c          | 2 +-
 x86/smap.c         | 2 +-
 x86/svm.c          | 2 +-
 x86/tsc.c          | 2 +-
 8 files changed, 10 insertions(+), 11 deletions(-)
x86/apic.c +3 -4
index 61a0a7659805..8b08a950a0c7 100644
@@ -27,7 +27,7 @@ static void tsc_deadline_timer_isr(isr_regs_t *regs)
     ++tdt_count;
 }
 
-static void start_tsc_deadline_timer(void)
+static void __test_tsc_deadline_timer(void)
 {
     handle_irq(TSC_DEADLINE_TIMER_VECTOR, tsc_deadline_timer_isr);
     irq_enable();
@@ -45,7 +45,6 @@ static int enable_tsc_deadline_timer(void)
     if (cpuid(1).c & (1 << 24)) {
         lvtt = TSC_DEADLINE_TIMER_MODE | TSC_DEADLINE_TIMER_VECTOR;
         apic_write(APIC_LVTT, lvtt);
-        start_tsc_deadline_timer();
         return 1;
     } else {
         return 0;
@@ -55,9 +54,9 @@ static int enable_tsc_deadline_timer(void)
 static void test_tsc_deadline_timer(void)
 {
     if(enable_tsc_deadline_timer()) {
-        printf("tsc deadline timer enabled\n");
+        __test_tsc_deadline_timer();
     } else {
-        printf("tsc deadline timer not detected\n");
+        report_skip("tsc deadline timer not detected");
     }
 }
 
x86/emulator.c +1 -1
index 3730721258bc..8d262d832112 100644
@@ -1082,7 +1082,7 @@ static void illegal_movbe_handler(struct ex_regs *regs)
 static void test_illegal_movbe(void)
 {
 	if (!(cpuid(1).c & (1 << 22))) {
-		printf("SKIP: illegal movbe\n");
+		report_skip("illegal movbe");
 		return;
 	}
 
x86/hyperv_synic.c +1 -1
index 6e088944be1f..f5eb82bb7336 100644
@@ -202,7 +202,7 @@ int main(int ac, char **av)
 
         report("Hyper-V SynIC test", ok);
     } else {
-        report("Hyper-V SynIC is not supported", true);
+        report_skip("Hyper-V SynIC is not supported");
     }
 
     return report_summary();
x86/pku.c +1 -1
index df51d1b59048..6214f0bc151f 100644
@@ -68,7 +68,7 @@ int main(int ac, char **av)
 
     if (!(cpuid_indexed(7, 0).c & (1 << X86_FEATURE_PKU))) {
         printf("PKU not enabled, aborting\n");
-        abort();
+        return report_summary();
     }
 
     setup_vm();
x86/pmu.c +1 -1
index 03f80190bb25..c68980044dee 100644
@@ -387,7 +387,7 @@ int main(int ac, char **av)
 
 	if (!eax.split.version_id) {
 		printf("No pmu is detected!\n");
-		return 1;
+		return report_summary();
 	}
 	printf("PMU version:         %d\n", eax.split.version_id);
 	printf("GP counters:         %d\n", eax.split.num_counters);
x86/smap.c +1 -1
index 69e71864dc9b..c9de081a474b 100644
@@ -93,7 +93,7 @@ int main(int ac, char **av)
 
 	if (!(cpuid_indexed(7, 0).b & (1 << X86_FEATURE_SMAP))) {
 		printf("SMAP not enabled, aborting\n");
-		abort();
+		return report_summary();
 	}
 
 	setup_vm();
x86/svm.c +1 -1
index 934b2ae91fa8..301cf8cb2d6b 100644
@@ -1064,7 +1064,7 @@ int main(int ac, char **av)
 
     if (!(cpuid(0x80000001).c & 4)) {
         printf("SVM not availble\n");
-        return 0;
+        return report_summary();
     }
 
     setup_svm();
x86/tsc.c +1 -1
index 6f89c911c2bc..62450e71725c 100644
@@ -43,5 +43,5 @@ int main()
 		test_rdtscp(0x100);
 	} else
 		printf("rdtscp not supported\n");
-	return 0;
+	return report_summary();
 }
Signature · 6 lines
2.8.1

--
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
#5 lore raw

Re: [PATCH v3 2/9] x86/*: report skipped tests

2016-04-19 08:34+0200, Andrew Jones:

Quoted 5 lines · Radim Krčmář
Quoted 1 line

No care to consistency or exhaustivity was given.

Me neither, but I see that x86/tscdeadline_latency.c could use similar updates too.

Thanks, I'll change it in v2.
(I missed it, because it's not a test that is run with ./run_tests.sh.)

#6 lore raw

PATCH v3 3/9 x86/unittests: remove svm-disabled

In reply to Radim Krčmář

svm-disabled says SKIP after the last patch. It's better than the FAIL it returned before (QEMU warns, so return 0 is treated as an error), but I don't think that the test is useful enough to be fixed to return PASS.

---
 x86/unittests.cfg | 6 ------
 1 file changed, 6 deletions(-)
x86/unittests.cfg +0 -6
index fcee6f98c598..60747cfca94e 100644
@@ -159,12 +159,6 @@ smp = 2
 extra_params = -cpu qemu64,+svm
 arch = x86_64
 
-[svm-disabled]
-file = svm.flat
-smp = 2
-extra_params = -cpu qemu64,-svm
-arch = x86_64
-
 [taskswitch]
 file = taskswitch.flat
 arch = i386
Signature · 1 line
2.8.1
#7 lore raw

PATCH v3 4/9 x86/pmu: expect failure with nmi_watchdog

In reply to Radim Krčmář

Host's nmi_watchdog takes one slot, making the "all counters" unit-test fail. We know exactly what happens, mark it as expected failure.

PMU test is now executed regardless of host_nmi_watchdog.

---
 x86/pmu.c         | 9 ++++++++-
 x86/unittests.cfg | 3 +--
 2 files changed, 9 insertions(+), 3 deletions(-)
x86/pmu.c +8 -1
index c68980044dee..70e9b3a41e96 100644
@@ -92,6 +92,7 @@ struct pmu_event {
 };
 
 static int num_counters;
+static bool host_nmi_watchdog;
 
 char *buf;
 
@@ -291,7 +292,7 @@ static void check_counters_many(void)
 		if (!verify_counter(&cnt[i]))
 			break;
 
-	report("all counters", i == n);
+	report_xfail("all counters", host_nmi_watchdog, i == n);
 }
 
 static void check_counter_overflow(void)
@@ -374,6 +375,7 @@ static void check_rdpmc(void)
 
 int main(int ac, char **av)
 {
+	int i;
 	struct cpuid id = cpuid(10);
 
 	setup_vm();
@@ -385,6 +387,11 @@ int main(int ac, char **av)
 	ebx.full = id.b;
 	edx.full = id.d;
 
+	/* XXX: horrible command line parsing */
+	for (i = 1; i < ac; i++)
+		if (!strcmp(av[i], "host_nmi_watchdog=1"))
+			host_nmi_watchdog = true;
+
 	if (!eax.split.version_id) {
 		printf("No pmu is detected!\n");
 		return report_summary();
x86/unittests.cfg +1 -2
index 60747cfca94e..3852b40a2927 100644
@@ -121,8 +121,7 @@ file = msr.flat
 
 [pmu]
 file = pmu.flat
-extra_params = -cpu host
-check = /proc/sys/kernel/nmi_watchdog=0
+extra_params = -cpu host -append "host_nmi_watchdog=`cat /proc/sys/kernel/nmi_watchdog`"
 
 [port80]
 file = port80.flat
Signature · 1 line
2.8.1
#8 lore raw

Re: [PATCH v3 4/9] x86/pmu: expect failure with nmi_watchdog

Quoted 41 lines · Radim Krčmář

Host's nmi_watchdog takes one slot, making the "all counters" unit-test fail. We know exactly what happens, mark it as expected failure.

PMU test is now executed regardless of host_nmi_watchdog.

---
 x86/pmu.c         | 9 ++++++++-
 x86/unittests.cfg | 3 +--
 2 files changed, 9 insertions(+), 3 deletions(-)
x86/pmu.c +3 -1
index c68980044dee..70e9b3a41e96 100644
@@ -92,6 +92,7 @@ struct pmu_event {
 };
 
 static int num_counters;
+static bool host_nmi_watchdog;
 
 char *buf;
 
@@ -291,7 +292,7 @@ static void check_counters_many(void)
 		if (!verify_counter(&cnt[i]))
 			break;
 
-	report("all counters", i == n);
+	report_xfail("all counters", host_nmi_watchdog, i == n);
 }
 
 static void check_counter_overflow(void)
@@ -374,6 +375,7 @@ static void check_rdpmc(void)
 
 int main(int ac, char **av)
 {
+	int i;
 	struct cpuid id = cpuid(10);
 
 	setup_vm();

x86/pmu.c int main(int ac, char **av) · line 391

Quoted 5 lines
x86/pmu.c +2 -0
@@ -385,6 +387,11 @@ int main(int ac, char **av)
 	ebx.full = id.b;
 	edx.full = id.d;
 
+	/* XXX: horrible command line parsing */
+	for (i = 1; i < ac; i++)

This should be i = 0. Yes, I know, that's a crappy inconsistency we have. I have somewhere low on the todo an item to try and find a way for argv[0] to be the testname, but it's probably not worth it... Hmm, an easy good 'nuff solution might be to always have argv[0] be "TEST" or some such though.

x86/pmu.c int main(int ac, char **av) · line 393

Quoted 2 lines
x86/pmu.c +2 -0
+		if (!strcmp(av[i], "host_nmi_watchdog=1"))
+			host_nmi_watchdog = true;

You could use lib/util's parse_keyval here instead.

Quoted 25 lines
x86/pmu.c +1 -0
+
 	if (!eax.split.version_id) {
 		printf("No pmu is detected!\n");
 		return report_summary();
x86/unittests.cfg +1 -2
index 60747cfca94e..3852b40a2927 100644
@@ -121,8 +121,7 @@ file = msr.flat
 
 [pmu]
 file = pmu.flat
-extra_params = -cpu host
-check = /proc/sys/kernel/nmi_watchdog=0
+extra_params = -cpu host -append "host_nmi_watchdog=`cat /proc/sys/kernel/nmi_watchdog`"
 
 [port80]
 file = port80.flat
Signature · 6 lines
2.8.1

--
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
#9 lore raw

Re: [PATCH v3 4/9] x86/pmu: expect failure with nmi_watchdog

2016-04-19 08:44+0200, Andrew Jones:

Quoted 45 lines · Radim Krčmář
Quoted 44 lines

Host's nmi_watchdog takes one slot, making the "all counters" unit-test fail. We know exactly what happens, mark it as expected failure.

PMU test is now executed regardless of host_nmi_watchdog.

---
 x86/pmu.c         | 9 ++++++++-
 x86/unittests.cfg | 3 +--
 2 files changed, 9 insertions(+), 3 deletions(-)
x86/pmu.c +3 -1
index c68980044dee..70e9b3a41e96 100644
@@ -92,6 +92,7 @@ struct pmu_event {
 };
 
 static int num_counters;
+static bool host_nmi_watchdog;
 
 char *buf;
 
@@ -291,7 +292,7 @@ static void check_counters_many(void)
 		if (!verify_counter(&cnt[i]))
 			break;
 
-	report("all counters", i == n);
+	report_xfail("all counters", host_nmi_watchdog, i == n);
 }
 
 static void check_counter_overflow(void)
@@ -374,6 +375,7 @@ static void check_rdpmc(void)
 
 int main(int ac, char **av)
 {
+	int i;
 	struct cpuid id = cpuid(10);
 
 	setup_vm();
@@ -385,6 +387,11 @@ int main(int ac, char **av)
 	ebx.full = id.b;
 	edx.full = id.d;
 
Quoted 8 lines

x86/pmu.c int main(int ac, char **av) · line 391

Quoted 2 lines
x86/pmu.c +2 -0
+	/* XXX: horrible command line parsing */
+	for (i = 1; i < ac; i++)

This should be i = 0. Yes, I know, that's a crappy inconsistency we have. I have somewhere low on the todo an item to try and find a way for argv[0] to be the testname, but it's probably not worth it... Hmm, an easy good 'nuff solution might be to always have argv[0] be "TEST" or some such though.

argv[0] is the test name for me ... if I modify the loop to print them all, then

% /x86-run x86/pmu.flat -append "a b c"
0: x86/pmu.flat
1: a
2: b
3: c

Quoted 4 lines

x86/pmu.c int main(int ac, char **av) · line 393

Quoted 2 lines
x86/pmu.c +2 -0
+		if (!strcmp(av[i], "host_nmi_watchdog=1"))
+			host_nmi_watchdog = true;

You could use lib/util's parse_keyval here instead.

Wow, so it didn't have to be horrible ...

#10 lore raw

Re: [PATCH v3 4/9] x86/pmu: expect failure with nmi_watchdog

Quoted 55 lines · Radim Krčmář

2016-04-19 08:44+0200, Andrew Jones:

Quoted 45 lines · Radim Krčmář
Quoted 44 lines

Host's nmi_watchdog takes one slot, making the "all counters" unit-test fail. We know exactly what happens, mark it as expected failure.

PMU test is now executed regardless of host_nmi_watchdog.

---
 x86/pmu.c         | 9 ++++++++-
 x86/unittests.cfg | 3 +--
 2 files changed, 9 insertions(+), 3 deletions(-)
x86/pmu.c +3 -1
index c68980044dee..70e9b3a41e96 100644
@@ -92,6 +92,7 @@ struct pmu_event {
 };
 
 static int num_counters;
+static bool host_nmi_watchdog;
 
 char *buf;
 
@@ -291,7 +292,7 @@ static void check_counters_many(void)
 		if (!verify_counter(&cnt[i]))
 			break;
 
-	report("all counters", i == n);
+	report_xfail("all counters", host_nmi_watchdog, i == n);
 }
 
 static void check_counter_overflow(void)
@@ -374,6 +375,7 @@ static void check_rdpmc(void)
 
 int main(int ac, char **av)
 {
+	int i;
 	struct cpuid id = cpuid(10);
 
 	setup_vm();
@@ -385,6 +387,11 @@ int main(int ac, char **av)
 	ebx.full = id.b;
 	edx.full = id.d;
 
Quoted 8 lines

x86/pmu.c int main(int ac, char **av) · line 391

Quoted 2 lines
x86/pmu.c +2 -0
+	/* XXX: horrible command line parsing */
+	for (i = 1; i < ac; i++)

This should be i = 0. Yes, I know, that's a crappy inconsistency we have. I have somewhere low on the todo an item to try and find a way for argv[0] to be the testname, but it's probably not worth it... Hmm, an easy good 'nuff solution might be to always have argv[0] be "TEST" or some such though.

Quoted 8 lines

argv[0] is the test name for me ... if I modify the loop to print them all, then

% /x86-run x86/pmu.flat -append "a b c"
0: x86/pmu.flat
1: a
2: b
3: c

Ohhhh.... I thought for sure that all arches had this wrong. Looks like, thanks to seabios, x86 is right. That now raises the priority of getting arm and powerpc right too. I'll send patches soon.

Quoted 11 lines
Quoted 5 lines

x86/pmu.c int main(int ac, char **av) · line 393

Quoted 3 lines
x86/pmu.c +2 -0
+		if (!strcmp(av[i], "host_nmi_watchdog=1"))
+			host_nmi_watchdog = true;

You could use lib/util's parse_keyval here instead.

Wow, so it didn't have to be horrible ...
--
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

#11 lore raw

PATCH v3 5/9 lib/report: don't print 0 failed tests

In reply to Radim Krčmář
---
 lib/report.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/report.c +3 -1
index 430b2aeaecbd..4cd75534f978 100644
@@ -95,7 +95,9 @@ int report_summary(void)
 {
 	spin_lock(&lock);
 
-	printf("\nSUMMARY: %d tests, %d unexpected failures", tests, failures);
+	printf("\nSUMMARY: %d tests", tests);
+	if (failures)
+		printf(", %d unexpected failures", failures);
 	if (xfailures)
 		printf(", %d expected failures", xfailures);
 	if (skipped)
Signature · 1 line
2.8.1
Reviewed-by on v3 5/9
#12 lore raw

Re: [PATCH v3 5/9] lib/report: don't print 0 failed tests

Quoted 23 lines · Radim Krčmář
---
 lib/report.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/report.c +3 -1
index 430b2aeaecbd..4cd75534f978 100644
@@ -95,7 +95,9 @@ int report_summary(void)
 {
 	spin_lock(&lock);
 
-	printf("\nSUMMARY: %d tests, %d unexpected failures", tests, failures);
+	printf("\nSUMMARY: %d tests", tests);
+	if (failures)
+		printf(", %d unexpected failures", failures);
 	if (xfailures)
 		printf(", %d expected failures", xfailures);
 	if (skipped)
Signature · 1 line
2.8.1
#13 lore raw

PATCH v3 6/9 scripts/runtime: skip tests that cannot run

In reply to Radim Krčmář

A case where QEMU won't run the kernel should be considered as skipped. Hyper-V tests used to FAIL on old QEMUs. The infamous QEMU=/dev/null FAIL streak is covered too.

---
 scripts/runtime.bash | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/runtime.bash +6 -0
index ed073721216c..4f29a59307f3 100644
@@ -39,6 +39,12 @@ function run()
         fi
     done
 
+    cmdline="TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run /dev/null -smp $smp $opts"
+    eval $cmdline |& grep -q "could not load kernel" || {
+        echo "skip $1 (QEMU won't run)"
+        return 2
+    }
+
     cmdline="TESTNAME=$testname TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts"
     if [ "$verbose" = "yes" ]; then
         echo $cmdline
Signature · 1 line
2.8.1
#14 lore raw

Re: [PATCH v3 6/9] scripts/runtime: skip tests that cannot run

Quoted 14 lines · Radim Krčmář

A case where QEMU won't run the kernel should be considered as skipped. Hyper-V tests used to FAIL on old QEMUs. The infamous QEMU=/dev/null FAIL streak is covered too.

---
 scripts/runtime.bash | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/runtime.bash +0 -0
index ed073721216c..4f29a59307f3 100644

scripts/runtime.bash function run() · line 46

Quoted 8 lines
scripts/runtime.bash +5 -0
@@ -39,6 +39,12 @@ function run()
         fi
     done
 
+    cmdline="TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run /dev/null -smp $smp $opts"
+    eval $cmdline |& grep -q "could not load kernel" || {
+        echo "skip $1 (QEMU won't run)"
+        return 2
+    }

This doesn't seem to work for arm; qemu just hangs with a /dev/null kernel. Also, this will echo an extra command line per test to the test.log.

$(TEST_DIR)/run scripts already do some qemu testing to make sure their machine model and testdevs are available. If not, they return 2. Isn't that good enough? Don't we just need to add a '$ret = 2' condition in run()?

Quoted 11 lines
scripts/runtime.bash +1 -0
+
     cmdline="TESTNAME=$testname TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts"
     if [ "$verbose" = "yes" ]; then
         echo $cmdline
Signature · 6 lines
2.8.1

--
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
#15 lore raw

Re: [PATCH v3 6/9] scripts/runtime: skip tests that cannot run

2016-04-19 09:01+0200, Andrew Jones:

Quoted 18 lines · Radim Krčmář
Quoted 17 lines

A case where QEMU won't run the kernel should be considered as skipped. Hyper-V tests used to FAIL on old QEMUs. The infamous QEMU=/dev/null FAIL streak is covered too.

---
 scripts/runtime.bash | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/runtime.bash +0 -0
index ed073721216c..4f29a59307f3 100644
@@ -39,6 +39,12 @@ function run()
         fi
     done
 
Quoted 8 lines

scripts/runtime.bash function run() · line 46

Quoted 5 lines
scripts/runtime.bash +5 -0
+    cmdline="TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run /dev/null -smp $smp $opts"
+    eval $cmdline |& grep -q "could not load kernel" || {
+        echo "skip $1 (QEMU won't run)"
+        return 2
+    }

This doesn't seem to work for arm; qemu just hangs with a /dev/null kernel.

Thanks, I'll be using _NO_FILE_4Uhere_, like scripts/runtime does.

Quoted 2 lines

Also, this will echo an extra command line per test to the
test.log.

Changing the logging mechanism in [8/9] got rid of it, but I forgot to mention it. Patches need a bit of reshufling to make it logical ...

Quoted 3 lines

$(TEST_DIR)/run scripts already do some qemu testing to make sure their machine model and testdevs are available. If not, they return 2. Isn't that good enough?

QEMU can fail, because we appended something that isn't supported, like hyperv tests do. Then the test is a FAIL.

Quoted 2 lines

Don't we just need to add a '$ret = 2' condition in
run()?

What if we changed that return value to 77? The test wasn't really run.

#16 lore raw

PATCH v3 7/9 scripts/runtime: consolidate summary tags

In reply to Radim Krčmář

Turn skip into yellow SKIP and add reusable definitions of all tags.

---
 scripts/runtime.bash | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
scripts/runtime.bash +11 -7
index 4f29a59307f3..59f0df080988 100644
@@ -2,6 +2,10 @@
 : ${MAX_SMP:=$(getconf _NPROCESSORS_CONF)}
 : ${TIMEOUT:=90s}
 
+PASS() { echo -ne "\e[32mPASS\e[0m"; }
+SKIP() { echo -ne "\e[33mSKIP\e[0m"; }
+FAIL() { echo -ne "\e[31mFAIL\e[0m"; }
+
 function run()
 {
     local testname="$1"
@@ -23,7 +27,7 @@ function run()
     fi
 
     if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
-        echo "skip $1 ($arch only)"
+        echo "`SKIP` $1 ($arch only)"
         return 2
     fi
 
@@ -34,14 +38,14 @@ function run()
         path=${check_param%%=*}
         value=${check_param#*=}
         if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then
-            echo "skip $1 ($path not equal to $value)"
+            echo "`SKIP` $1 ($path not equal to $value)"
             return 2
         fi
     done
 
     cmdline="TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run /dev/null -smp $smp $opts"
     eval $cmdline |& grep -q "could not load kernel" || {
-        echo "skip $1 (QEMU won't run)"
+        echo "`SKIP` $1 (QEMU won't run)"
         return 2
     }
 
@@ -56,13 +60,13 @@ function run()
     ret=$?
 
     if [ $ret -eq 0 ]; then
-        echo -e "\e[32mPASS\e[0m $1"
+        echo "`PASS` $1"
     elif [ $ret -eq 77 ]; then
-        echo -e "\e[33mSKIP\e[0m $1"
+        echo "`SKIP` $1"
     elif [ $ret -eq 124 ]; then
-        echo -e "\e[31mFAIL\e[0m $1 (timeout; duration=$timeout)"
+        echo "`FAIL` $1 (timeout; duration=$timeout)"
     else
-        echo -e "\e[31mFAIL\e[0m $1"
+        echo "`FAIL` $1"
     fi
 
     return $ret
Signature · 1 line
2.8.1
Reviewed-by on v3 7/9
#17 lore raw

Re: [PATCH v3 7/9] scripts/runtime: consolidate summary tags

Quoted 69 lines · Radim Krčmář

Turn skip into yellow SKIP and add reusable definitions of all tags.

---
 scripts/runtime.bash | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
scripts/runtime.bash +11 -7
index 4f29a59307f3..59f0df080988 100644
@@ -2,6 +2,10 @@
 : ${MAX_SMP:=$(getconf _NPROCESSORS_CONF)}
 : ${TIMEOUT:=90s}
 
+PASS() { echo -ne "\e[32mPASS\e[0m"; }
+SKIP() { echo -ne "\e[33mSKIP\e[0m"; }
+FAIL() { echo -ne "\e[31mFAIL\e[0m"; }
+
 function run()
 {
     local testname="$1"
@@ -23,7 +27,7 @@ function run()
     fi
 
     if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
-        echo "skip $1 ($arch only)"
+        echo "`SKIP` $1 ($arch only)"
         return 2
     fi
 
@@ -34,14 +38,14 @@ function run()
         path=${check_param%%=*}
         value=${check_param#*=}
         if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then
-            echo "skip $1 ($path not equal to $value)"
+            echo "`SKIP` $1 ($path not equal to $value)"
             return 2
         fi
     done
 
     cmdline="TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run /dev/null -smp $smp $opts"
     eval $cmdline |& grep -q "could not load kernel" || {
-        echo "skip $1 (QEMU won't run)"
+        echo "`SKIP` $1 (QEMU won't run)"
         return 2
     }
 
@@ -56,13 +60,13 @@ function run()
     ret=$?
 
     if [ $ret -eq 0 ]; then
-        echo -e "\e[32mPASS\e[0m $1"
+        echo "`PASS` $1"
     elif [ $ret -eq 77 ]; then
-        echo -e "\e[33mSKIP\e[0m $1"
+        echo "`SKIP` $1"
     elif [ $ret -eq 124 ]; then
-        echo -e "\e[31mFAIL\e[0m $1 (timeout; duration=$timeout)"
+        echo "`FAIL` $1 (timeout; duration=$timeout)"
     else
-        echo -e "\e[31mFAIL\e[0m $1"
+        echo "`FAIL` $1"
     fi
 
     return $ret
Signature · 1 line
2.8.1
#18 lore raw

PATCH v3 8/9 run_tests: print summary

In reply to Radim Krčmář

SUMMARY line is present if the test uses lib/report. Summary contains some interesting information, so duplicating the output isn't that big of a cost. Our log redirection got more complicated, though.

---
 run_tests.sh            |  6 +++---
 scripts/mkstandalone.sh |  3 +++
 scripts/runtime.bash    | 15 ++++++++++-----
 3 files changed, 16 insertions(+), 8 deletions(-)
run_tests.sh +3 -3
index 7e0237f3aa11..2a0082163423 100755
@@ -25,6 +25,7 @@ specify the appropriate qemu binary for ARCH-run.
 EOF
 }
 
+RUNTIME_log_stdout="/dev/null"
 RUNTIME_arch_run="./$TEST_DIR/run"
 source scripts/runtime.bash
 
@@ -47,12 +48,11 @@ while getopts "g:hv" opt; do
 done
 
 if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
-	log_redir="> >(./scripts/pretty_print_stacks.py \$kernel >> test.log)"
+	RUNTIME_log_stdout='>(./scripts/pretty_print_stacks.py $kernel >> test.log)'
 else
-	log_redir=">> test.log"
+	RUNTIME_log_stdout='test.log'
 fi
 
-RUNTIME_arch_run="./$TEST_DIR/run $log_redir"
 config=$TEST_DIR/unittests.cfg
 rm -f test.log
 printf "BUILD_HEAD=$(cat build-head)\n\n" > test.log
scripts/mkstandalone.sh +3 -0
index ef15bc88a22a..ee01fe0c7777 100755
@@ -68,6 +68,9 @@ generate_test ()
 	(echo "#!/bin/bash"
 	 cat scripts/arch-run.bash "$TEST_DIR/run") | temp_file RUNTIME_arch_run
 
+	echo "exec {stdout}>&1"
+	echo "RUNTIME_log_stdout='>(cat >&\$stdout)'"
+
 	cat scripts/runtime.bash
 
 	echo "run ${args[@]}"
scripts/runtime.bash +10 -5
index 59f0df080988..fc4be91d8727 100644
@@ -6,6 +6,11 @@ PASS() { echo -ne "\e[32mPASS\e[0m"; }
 SKIP() { echo -ne "\e[33mSKIP\e[0m"; }
 FAIL() { echo -ne "\e[31mFAIL\e[0m"; }
 
+extract_summary()
+{
+    tail -1 | grep '^SUMMARY: ' | sed 's/^SUMMARY: /(/;s/$/)/'
+}
+
 function run()
 {
     local testname="$1"
@@ -55,18 +60,18 @@ function run()
     fi
 
     # extra_params in the config file may contain backticks that need to be
-    # expanded, so use eval to start qemu
-    eval $cmdline
+    # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.
+    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary))
     ret=$?
 
     if [ $ret -eq 0 ]; then
-        echo "`PASS` $1"
+        echo "`PASS` $1 $summary"
     elif [ $ret -eq 77 ]; then
-        echo "`SKIP` $1"
+        echo "`SKIP` $1 $summary"
     elif [ $ret -eq 124 ]; then
         echo "`FAIL` $1 (timeout; duration=$timeout)"
     else
-        echo "`FAIL` $1"
+        echo "`FAIL` $1 $summary"
     fi
 
     return $ret
Signature · 1 line
2.8.1
Reviewed-by on v3 8/9
#19 lore raw

Re: [PATCH v3 8/9] run_tests: print summary

Quoted 69 lines · Radim Krčmář

SUMMARY line is present if the test uses lib/report. Summary contains some interesting information, so duplicating the output isn't that big of a cost. Our log redirection got more complicated, though.

---
 run_tests.sh            |  6 +++---
 scripts/mkstandalone.sh |  3 +++
 scripts/runtime.bash    | 15 ++++++++++-----
 3 files changed, 16 insertions(+), 8 deletions(-)
run_tests.sh +3 -3
index 7e0237f3aa11..2a0082163423 100755
@@ -25,6 +25,7 @@ specify the appropriate qemu binary for ARCH-run.
 EOF
 }
 
+RUNTIME_log_stdout="/dev/null"
 RUNTIME_arch_run="./$TEST_DIR/run"
 source scripts/runtime.bash
 
@@ -47,12 +48,11 @@ while getopts "g:hv" opt; do
 done
 
 if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
-	log_redir="> >(./scripts/pretty_print_stacks.py \$kernel >> test.log)"
+	RUNTIME_log_stdout='>(./scripts/pretty_print_stacks.py $kernel >> test.log)'
 else
-	log_redir=">> test.log"
+	RUNTIME_log_stdout='test.log'
 fi
 
-RUNTIME_arch_run="./$TEST_DIR/run $log_redir"
 config=$TEST_DIR/unittests.cfg
 rm -f test.log
 printf "BUILD_HEAD=$(cat build-head)\n\n" > test.log
scripts/mkstandalone.sh +3 -0
index ef15bc88a22a..ee01fe0c7777 100755
@@ -68,6 +68,9 @@ generate_test ()
 	(echo "#!/bin/bash"
 	 cat scripts/arch-run.bash "$TEST_DIR/run") | temp_file RUNTIME_arch_run
 
+	echo "exec {stdout}>&1"
+	echo "RUNTIME_log_stdout='>(cat >&\$stdout)'"
+
 	cat scripts/runtime.bash
 
 	echo "run ${args[@]}"
scripts/runtime.bash +5 -0
index 59f0df080988..fc4be91d8727 100644
@@ -6,6 +6,11 @@ PASS() { echo -ne "\e[32mPASS\e[0m"; }
 SKIP() { echo -ne "\e[33mSKIP\e[0m"; }
 FAIL() { echo -ne "\e[31mFAIL\e[0m"; }
 
+extract_summary()
+{
+    tail -1 | grep '^SUMMARY: ' | sed 's/^SUMMARY: /(/;s/$/)/'
+}
+
 function run()
 {
     local testname="$1"

scripts/runtime.bash function run() · line 64

Quoted 7 lines
scripts/runtime.bash +2 -2
@@ -55,18 +60,18 @@ function run()
     fi
 
     # extra_params in the config file may contain backticks that need to be
-    # expanded, so use eval to start qemu
-    eval $cmdline
+    # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.
+    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary))

The depth of our stdout resolution is getting insane. Oh well, let's see how deep we can go before we throw our hands up and just rewrite all these bash scripts in python.

Quoted 19 lines
scripts/runtime.bash +3 -3
     ret=$?
 
     if [ $ret -eq 0 ]; then
-        echo "`PASS` $1"
+        echo "`PASS` $1 $summary"
     elif [ $ret -eq 77 ]; then
-        echo "`SKIP` $1"
+        echo "`SKIP` $1 $summary"
     elif [ $ret -eq 124 ]; then
         echo "`FAIL` $1 (timeout; duration=$timeout)"
     else
-        echo "`FAIL` $1"
+        echo "`FAIL` $1 $summary"
     fi
 
     return $ret
Signature · 1 line
2.8.1
maintainer
#20 lore raw

Re: [PATCH v3 8/9] run_tests: print summary

Quoted 72 lines · Andrew Jones
Quoted 71 lines · Radim Krčmář

SUMMARY line is present if the test uses lib/report. Summary contains some interesting information, so duplicating the output isn't that big of a cost. Our log redirection got more complicated, though.

---
 run_tests.sh            |  6 +++---
 scripts/mkstandalone.sh |  3 +++
 scripts/runtime.bash    | 15 ++++++++++-----
 3 files changed, 16 insertions(+), 8 deletions(-)
run_tests.sh +3 -3
index 7e0237f3aa11..2a0082163423 100755
@@ -25,6 +25,7 @@ specify the appropriate qemu binary for ARCH-run.
 EOF
 }
 
+RUNTIME_log_stdout="/dev/null"
 RUNTIME_arch_run="./$TEST_DIR/run"
 source scripts/runtime.bash
 
@@ -47,12 +48,11 @@ while getopts "g:hv" opt; do
 done
 
 if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
-	log_redir="> >(./scripts/pretty_print_stacks.py \$kernel >> test.log)"
+	RUNTIME_log_stdout='>(./scripts/pretty_print_stacks.py $kernel >> test.log)'
 else
-	log_redir=">> test.log"
+	RUNTIME_log_stdout='test.log'
 fi
 
-RUNTIME_arch_run="./$TEST_DIR/run $log_redir"
 config=$TEST_DIR/unittests.cfg
 rm -f test.log
 printf "BUILD_HEAD=$(cat build-head)\n\n" > test.log
scripts/mkstandalone.sh +3 -0
index ef15bc88a22a..ee01fe0c7777 100755
@@ -68,6 +68,9 @@ generate_test ()
 	(echo "#!/bin/bash"
 	 cat scripts/arch-run.bash "$TEST_DIR/run") | temp_file RUNTIME_arch_run
 
+	echo "exec {stdout}>&1"
+	echo "RUNTIME_log_stdout='>(cat >&\$stdout)'"
+
 	cat scripts/runtime.bash
 
 	echo "run ${args[@]}"
scripts/runtime.bash +5 -0
index 59f0df080988..fc4be91d8727 100644
@@ -6,6 +6,11 @@ PASS() { echo -ne "\e[32mPASS\e[0m"; }
 SKIP() { echo -ne "\e[33mSKIP\e[0m"; }
 FAIL() { echo -ne "\e[31mFAIL\e[0m"; }
 
+extract_summary()
+{
+    tail -1 | grep '^SUMMARY: ' | sed 's/^SUMMARY: /(/;s/$/)/'
+}
+
 function run()
 {
     local testname="$1"
@@ -55,18 +60,18 @@ function run()
     fi
 
Quoted 9 lines

scripts/runtime.bash function run() · line 64

Quoted 5 lines
scripts/runtime.bash +2 -2
     # extra_params in the config file may contain backticks that need to be
-    # expanded, so use eval to start qemu
-    eval $cmdline
+    # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.
+    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary))

The depth of our stdout resolution is getting insane. Oh well, let's see how deep we can go before we throw our hands up and just rewrite all these bash scripts in python.

Why not just use a pipe here?

eval $cmdline 2>> $RUNTIME_log_stderr \
| eval tee -a "$RUNTIME_log_stdout" | extract_summary

Anything I am missing?

Paolo

Quoted 22 lines
Quoted 19 lines
scripts/runtime.bash +3 -3
     ret=$?
 
     if [ $ret -eq 0 ]; then
-        echo "`PASS` $1"
+        echo "`PASS` $1 $summary"
     elif [ $ret -eq 77 ]; then
-        echo "`SKIP` $1"
+        echo "`SKIP` $1 $summary"
     elif [ $ret -eq 124 ]; then
         echo "`FAIL` $1 (timeout; duration=$timeout)"
     else
-        echo "`FAIL` $1"
+        echo "`FAIL` $1 $summary"
     fi
 
     return $ret
Signature · 1 line
2.8.1
#21 lore raw

Re: [PATCH v3 8/9] run_tests: print summary

2016-05-10 13:45+0200, Paolo Bonzini:

Quoted 12 lines · Andrew Jones
Quoted 10 lines · Radim Krčmář

scripts/runtime.bash function run() · line 64

Quoted 5 lines
     # extra_params in the config file may contain backticks that need to be
scripts/runtime.bash +2 -2
-    # expanded, so use eval to start qemu
-    eval $cmdline
+    # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.
+    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary))

The depth of our stdout resolution is getting insane. Oh well, let's see how deep we can go before we throw our hands up and just rewrite all these bash scripts in python.

Quoted 8 lines

Why not just use a pipe here?

eval $cmdline 2>> $RUNTIME_log_stderr \
| eval tee -a "$RUNTIME_log_stdout" | extract_summary

Anything I am missing?

Quoted 1 line
Quoted 1 line
     ret=$?

Simple pipeline would not return the return value of eval $cmdline, so it seemed nicer with a redirection.

maintainer
#22 lore raw

Re: [PATCH v3 8/9] run_tests: print summary

Quoted 8 lines · Radim Krčmář
Quoted 6 lines
Quoted 6 lines

eval $cmdline 2>> $RUNTIME_log_stderr \
| eval tee -a "$RUNTIME_log_stdout" | extract_summary

Anything I am missing?

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
     ret=$?

Simple pipeline would not return the return value of eval $cmdline, so it seemed nicer with a redirection.

Right... Two more attempts:

eval "$cmdline 2>> $RUNTIME_log_stderr
> >(tee -a $RUNTIME_log_stdout | extract_summary)"

(eval $cmdline) 2> >($RUNTIME_cmd_stderr)
> >(tee >($RUNTIME_cmd_stdout) | extract_summary)"

(The latter requiring an extra useless uses of cat for test.log).

Would any of these work fine?

Paolo

#23 lore raw

Re: [PATCH v3 8/9] run_tests: print summary

2016-05-10 16:32+0200, Paolo Bonzini:

Quoted 15 lines · Radim Krčmář
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

eval $cmdline 2>> $RUNTIME_log_stderr \
| eval tee -a "$RUNTIME_log_stdout" | extract_summary

Anything I am missing?

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
     ret=$?

Simple pipeline would not return the return value of eval $cmdline, so it seemed nicer with a redirection.

Right... Two more attempts:

eval "$cmdline 2>> $RUNTIME_log_stderr
> >(tee -a $RUNTIME_log_stdout | extract_summary)"

Quoted 6 lines

(eval $cmdline) 2> >($RUNTIME_cmd_stderr)
> >(tee >($RUNTIME_cmd_stdout) | extract_summary)"

(The latter requiring an extra useless uses of cat for test.log).

Would any of these work fine?

The former one works. The latter would work if $RUNTIME_cmd_stdout accepted $kernel as an argument.

  summary=$(eval $cmdline
            > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary))

Is that acceptable?
(I will gladly degrade performance to have less code in eval.)

Thanks.

maintainer
#24 lore raw

Re: [PATCH v3 8/9] run_tests: print summary

Quoted 8 lines · Radim Krčmář

The former one works. The latter would work if $RUNTIME_cmd_stdout accepted $kernel as an argument.

  summary=$(eval $cmdline
            > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary))

Is that acceptable?
(I will gladly degrade performance to have less code in eval.)

Yeah, same here. Also "2> >(RUNTIME_log_stderr)"?

Thanks,

Paolo

#25 lore raw

Re: [PATCH v3 8/9] run_tests: print summary

2016-05-10 17:46+0200, Paolo Bonzini:

Quoted 11 lines · Radim Krčmář
Quoted 8 lines

The former one works. The latter would work if $RUNTIME_cmd_stdout accepted $kernel as an argument.

  summary=$(eval $cmdline
            > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary))

Is that acceptable?
(I will gladly degrade performance to have less code in eval.)

Yeah, same here. Also "2> >(RUNTIME_log_stderr)"?

Yes. Time to rewrite it all!

#26 lore raw

PATCH v3 9/9 run_tests: log stderr

In reply to Radim Krčmář

After recent changes to logging, seeing it all the time doesn't help. We could print one line in summary if stderr is missed.

---
 run_tests.sh            | 1 +
 scripts/mkstandalone.sh | 1 +
 scripts/runtime.bash    | 3 ++-
 3 files changed, 4 insertions(+), 1 deletion(-)
run_tests.sh +1 -0
index 2a0082163423..3592db317897 100755
@@ -47,6 +47,7 @@ while getopts "g:hv" opt; do
     esac
 done
 
+RUNTIME_log_stderr='test.log'
 if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
 	RUNTIME_log_stdout='>(./scripts/pretty_print_stacks.py $kernel >> test.log)'
 else
scripts/mkstandalone.sh +1 -0
index ee01fe0c7777..af2b8f43743c 100755
@@ -70,6 +70,7 @@ generate_test ()
 
 	echo "exec {stdout}>&1"
 	echo "RUNTIME_log_stdout='>(cat >&\$stdout)'"
+	echo "RUNTIME_log_stderr=>(cat >&2)"
 
 	cat scripts/runtime.bash
 
scripts/runtime.bash +2 -1
index fc4be91d8727..ff2d98b547b5 100644
@@ -61,7 +61,8 @@ function run()
 
     # extra_params in the config file may contain backticks that need to be
     # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.
-    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary))
+    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary) \
+                            2>> $RUNTIME_log_stderr)
     ret=$?
 
     if [ $ret -eq 0 ]; then
Signature · 1 line
2.8.1
#27 lore raw

Re: [PATCH v3 9/9] run_tests: log stderr

Quoted 2 lines · Radim Krčmář

After recent changes to logging, seeing it all the time doesn't help. We could print one line in summary if stderr is missed.

I miss it already :-)

I like stderr coming to the terminal from which run_tests.sh is run, because it should be rare and probably important to see. I'd rather this patch at least include the one summary line now, rather than wait and see if we want it later. Or maybe just drop this patch?

One more comment below.

Quoted 25 lines
---
 run_tests.sh            | 1 +
 scripts/mkstandalone.sh | 1 +
 scripts/runtime.bash    | 3 ++-
 3 files changed, 4 insertions(+), 1 deletion(-)
run_tests.sh +1 -0
index 2a0082163423..3592db317897 100755
@@ -47,6 +47,7 @@ while getopts "g:hv" opt; do
     esac
 done
 
+RUNTIME_log_stderr='test.log'
 if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
 	RUNTIME_log_stdout='>(./scripts/pretty_print_stacks.py $kernel >> test.log)'
 else
scripts/mkstandalone.sh +0 -0
index ee01fe0c7777..af2b8f43743c 100755

scripts/mkstandalone.sh generate_test () · line 73

Quoted 4 lines
scripts/mkstandalone.sh +1 -0
@@ -70,6 +70,7 @@ generate_test ()
 
 	echo "exec {stdout}>&1"
 	echo "RUNTIME_log_stdout='>(cat >&\$stdout)'"
+	echo "RUNTIME_log_stderr=>(cat >&2)"

No need for the single quotes like RUNTIME_log_stdout has? Or does RUNTIME_log_stdout not need them?

Quoted 20 lines
scripts/mkstandalone.sh +0 -0
 	cat scripts/runtime.bash
 
scripts/runtime.bash +2 -1
index fc4be91d8727..ff2d98b547b5 100644
@@ -61,7 +61,8 @@ function run()
 
     # extra_params in the config file may contain backticks that need to be
     # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.
-    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary))
+    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary) \
+                            2>> $RUNTIME_log_stderr)
     ret=$?
 
     if [ $ret -eq 0 ]; then
Signature · 1 line
2.8.1

Thanks,
drew

#28 lore raw

Re: [PATCH v3 9/9] run_tests: log stderr

2016-04-19 09:26+0200, Andrew Jones:

Quoted 10 lines · Radim Krčmář
Quoted 2 lines

After recent changes to logging, seeing it all the time doesn't help. We could print one line in summary if stderr is missed.

I miss it already :-)

I like stderr coming to the terminal from which run_tests.sh is run, because it should be rare and probably important to see. I'd rather this patch at least include the one summary line now, rather than wait and see if we want it later.

Messages in stderr aren't rare, though ... we see several of them on every batch:

warning: host doesn't support requested feature: CPUID.80000001H:ECX.svm [bit 2]
warning: host doesn't support requested feature: CPUID.80000001H:ECX.svm [bit 2]
warning: host doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]

(Warnings already screw up our FAIL heuristic, so we'd better do
something with them ...)

Quoted 1 line

Or maybe just drop this patch?

I'll drop this patch, it was borderline acceptable and making the summary bearable would might be out of my league.

Quoted 9 lines

scripts/mkstandalone.sh generate_test () · line 70

Quoted 6 lines
run_tests.sh +1 -0
@@ -47,6 +47,7 @@ while getopts "g:hv" opt; do
+RUNTIME_log_stderr='test.log'
scripts/mkstandalone.sh +1 -0
@@ -70,6 +70,7 @@ generate_test ()
+	echo "RUNTIME_log_stderr=>(cat >&2)"

No need for the single quotes like RUNTIME_log_stdout has? Or does RUNTIME_log_stdout not need them?

*evil laugh*, both of them need quotes just where they are.

RUNTIME_log_stdout is used in a subshell that wouldn't have access to the fd if we evaluated it here.
RUNTIME_log_stderr has to be evaluated into the fd here, because it wouldn't be evaluated in the future.

(Take a while to apprectiate this hellspawn.)

Quoted 5 lines
Quoted 5 lines
scripts/runtime.bash +2 -1
@@ -61,7 +61,8 @@ function run()
-    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary))
+    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary) \
+                            2>> $RUNTIME_log_stderr)
maintainer
#29 lore raw

Re: [PATCH v3 9/9] run_tests: log stderr

In reply to Radim Krčmář
Quoted 11 lines · Radim Krčmář
scripts/mkstandalone.sh +1 -0
 	echo "exec {stdout}>&1"
 	echo "RUNTIME_log_stdout='>(cat >&\$stdout)'"
+	echo "RUNTIME_log_stderr=>(cat >&2)"
 
 	cat scripts/runtime.bash
scripts/runtime.bash +0 -0
index fc4be91d8727..ff2d98b547b5 100644

scripts/runtime.bash function run() · line 65

Quoted 6 lines
scripts/runtime.bash +2 -1
@@ -61,7 +61,8 @@ function run()
 
     # extra_params in the config file may contain backticks that need to be
     # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.
-    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary))
+    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary) \
+                            2>> $RUNTIME_log_stderr)

Whoa, so this uses the outer eval? Perhaps the 2>> should move before the >.

Paolo

#30 lore raw

Re: [PATCH v3 9/9] run_tests: log stderr

2016-05-10 13:41+0200, Paolo Bonzini:

Quoted 13 lines · Radim Krčmář
Quoted 12 lines
scripts/mkstandalone.sh +1 -0
 	echo "exec {stdout}>&1"
 	echo "RUNTIME_log_stdout='>(cat >&\$stdout)'"
+	echo "RUNTIME_log_stderr=>(cat >&2)"
 
 	cat scripts/runtime.bash
scripts/runtime.bash +0 -0
index fc4be91d8727..ff2d98b547b5 100644
@@ -61,7 +61,8 @@ function run()
 
Quoted 7 lines

scripts/runtime.bash function run() · line 65

Quoted 5 lines
scripts/runtime.bash +2 -1
     # extra_params in the config file may contain backticks that need to be
     # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.
-    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary))
+    summary=$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout" | extract_summary) \
+                            2>> $RUNTIME_log_stderr)

Whoa, so this uses the outer eval?

No, RUNTIME_log_stderr is evaluated only at the time of definition, which makes it inconsistent with RUNTIME_log_stdout.

Quoted 2 lines

Perhaps the 2>> should move before
the >.

I will drop this patch ... it's too insane and Drew liked stderr in ./run_tests.sh output. Sorry.

#31 lore raw
In reply to Radim Krčmář
Quoted 11 lines · Radim Krčmář

v2: http://www.spinics.net/lists/kvm/msg125429.html

mkstandalone is using generic code now, so v3 focuses on the output again. And the output looks like in v2. Since v2, I've
* removed svm-disabled [3/7]
* reworked summary reporting [8/9] (it's a nice feature, but still ugly)
* turned all cases when QEMU won't run the test into SKIP [6/7]
* preserved check_param (it's not used, though)
* stopped returning 77 on all SKIPs [7/7] (a sacrifice to prevent another refactoring of our scripts)

Quoted 2 lines

I didn't manage to look at the comment from Lukáš's patches, but I don't expect that v3 will be the last one ... a lot has changed since v2.

Lukas' comment was that the skip due to a test needing KVM (i.e. not possible to run with TCG) should get a more informative summary. He wanted something along the lines of 'kvm test only, and this system doesn't have kvm', rather than just 'kvm only'.

Oh, actually those summaries are arm and powerpc run script summaries, not common runtime. They could still be improved with this series :-)

Thanks,
drew

Quoted 36 lines

Radim Krčmář (9):
lib/report: allow test skipping
x86/*: report skipped tests
x86/unittests: remove svm-disabled
x86/pmu: expect failure with nmi_watchdog
lib/report: don't print 0 failed tests
scripts/runtime: skip tests that cannot run
scripts/runtime: consolidate summary tags
run_tests: print summary
run_tests: log stderr

 lib/libcflat.h          |  1 +
 lib/report.c            | 49 ++++++++++++++++++++++++++++++++++---------------
 run_tests.sh            |  7 ++++---
 scripts/mkstandalone.sh |  4 ++++
 scripts/runtime.bash    | 32 +++++++++++++++++++++++++-------
 x86/apic.c              |  7 +++----
 x86/emulator.c          |  2 +-
 x86/hyperv_synic.c      |  2 +-
 x86/pku.c               |  2 +-
 x86/pmu.c               | 11 +++++++++--
 x86/smap.c              |  2 +-
 x86/svm.c               |  2 +-
 x86/tsc.c               |  2 +-
 x86/unittests.cfg       |  9 +--------
 14 files changed, 87 insertions(+), 45 deletions(-)
Signature · 6 lines
2.8.1

--
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
#32 lore raw

2016-04-19 09:31+0200, Andrew Jones:

Quoted 15 lines · Radim Krčmář
Quoted 11 lines

v2: http://www.spinics.net/lists/kvm/msg125429.html

mkstandalone is using generic code now, so v3 focuses on the output again. And the output looks like in v2. Since v2, I've
* removed svm-disabled [3/7]
* reworked summary reporting [8/9] (it's a nice feature, but still ugly)
* turned all cases when QEMU won't run the test into SKIP [6/7]
* preserved check_param (it's not used, though)
* stopped returning 77 on all SKIPs [7/7] (a sacrifice to prevent another refactoring of our scripts)

Quoted 2 lines

I didn't manage to look at the comment from Lukáš's patches, but I don't expect that v3 will be the last one ... a lot has changed since v2.

Quoted 7 lines

Lukas' comment was that the skip due to a test needing KVM (i.e. not possible to run with TCG) should get a more informative summary. He wanted something along the lines of 'kvm test only, and this system doesn't have kvm', rather than just 'kvm only'.

Oh, actually those summaries are arm and powerpc run script summaries, not common runtime. They could still be improved with this series :-)

Thanks for reviews ... I'll handle it.