Improve the output of test runners
Subsystems (4)
v4 cover Improve the output of test runners
v3: http://www.spinics.net/lists/kvm/msg130911.html
Changes are described in each changed patch.
The output differs a bit from v3, because SKIP when QEMU didn't have a chance to run the test now prints the last line of stdout + stderr in summary.
PASS apic (14 tests)
PASS emulator (131 tests, 1 skipped)
PASS pmu (67 tests, 1 expected failures)
SKIP svm (0 tests)
SKIP taskswitch (i386 only)
PASS kvmclock_test
SKIP hyperv_synic (qemu-kvm: Property '.hv-synic' not found)
Radim Krčmář (13):
lib/report: allow test skipping
x86/*: report skipped tests
x86/unittests: remove svm-disabled
lib/string: add strncmp
lib/util: add args_parse_keyval
x86/pmu: expect failure with nmi_watchdog
lib/report: don't print 0 failed tests
scripts/runtime: consolidate summary tags
run_tests: print SUMMARY line in summary
run_tests: log stderr
scripts/runtime: skip tests that cannot run
scripts/arch-run: change QEMU failure detection
scripts/run: generalize check
arm/run | 2 +- lib/libcflat.h | 1 + lib/report.c | 49 ++++++++++++++++++++++++----------- lib/string.c | 17 ++++++++----- lib/string.h | 1 + lib/util.c | 17 +++++++++++++ lib/util.h | 10 ++++++++ powerpc/run | 2 +- run_tests.sh | 15 ++++++----- scripts/arch-run.bash | 2 +- scripts/mkstandalone.sh | 4 +++ scripts/runtime.bash | 68 ++++++++++++++++++++++++++++++++++++------------- x86/Makefile.common | 1 + x86/apic.c | 7 +++-- x86/emulator.c | 2 +- x86/hyperv_synic.c | 2 +- x86/pku.c | 2 +- x86/pmu.c | 8 ++++-- x86/smap.c | 2 +- x86/svm.c | 2 +- x86/tsc.c | 2 +- x86/unittests.cfg | 9 +------ 22 files changed, 156 insertions(+), 69 deletions(-)
Signature · 1 line
2.8.2
PATCH v4 1/13 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
@@ -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
@@ -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.2
PATCH v4 2/13 x86/*: report skipped tests
In reply to Radim KrčmářNo care to consistency or exhaustivity was given.
Drew pointed out that tscdeadline_latency.c doesn't report skipped tests. tscdeadline_latency needs complete refactoring and is not run with ./run_tests, so I ignored it.
---
v4: explained the reason behind ignoring v3 review
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.2
Paolo Bonzini
maintainerRe: [kvm-unit-tests PATCH v4 02/13] x86/*: report skipped tests
Review
Quoted 5 lines · Radim Krčmář
if (!(cpuid_indexed(7, 0).c & (1 << X86_FEATURE_PKU))) { printf("PKU not enabled, aborting\n");(quoted diff) +1
-1- abort(); + return report_summary();
Needs report_skip?
x86/pmu.c int main(int ac, char **av) · line 390
Quoted 13 lines
} setup_vm();x86/pmu.c +1
-1@@ -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 ();
Needs report_skip?
x86/smap.c int main(int ac, char **av) · line 96
Quoted 13 lines
x86/pmu.c +0
-0}printf ("PMU version: %d\n" , eax.split.version_id);printf ("GP counters: %d\n" , eax.split.num_counters);x86/smap.c +1
-1@@ -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 ();
Needs report_skip?
x86/svm.c int main(int ac, char **av) · line 1067
Quoted 13 lines
x86/smap.c +0
-0}setup_vm ();x86/svm.c +1
-1@@ -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 ();
Needs report_skip?
x86/tsc.c int main() · line 45
Quoted 11 lines
x86/svm.c +0
-0}setup_svm ();x86/tsc.c +0
-0@@ -43,5 +43,5 @@ int main()test_rdtscp (0x100 ); }else printf ("rdtscp not supported\n" );
Needs report_skip?
x86/tsc.c int main() · line 46
Quoted 2 lines
x86/tsc.c +1
-1-return 0 ; +return report_summary ();
Just sending a fixup patch is enough.
Paolo
Re: [kvm-unit-tests PATCH v4 02/13] x86/*: report skipped tests
2016-05-17 14:19+0200, Paolo Bonzini:
Quoted 39 lines · Radim Krčmář
Review
Quoted 4 lines
if (!(cpuid_indexed(7, 0).c & (1 << X86_FEATURE_PKU))) { printf("PKU not enabled, aborting\n");(quoted diff) +1
-1- abort(); + return report_summary();Needs
report_skip?x86/pmu.c int main(int ac, char **av) · line 389
Quoted 6 lines
x86/pmu.c +1
-1@@ -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 ();Needs
report_skip?x86/smap.c int main(int ac, char **av) · line 95
Quoted 6 lines
x86/smap.c +1
-1@@ -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 ();Needs
report_skip?x86/svm.c
Quoted 5 lines
x86/svm.c +1
-1if (!(cpuid (0x80000001 ).c &4 )) {printf ("SVM not availble\n" ); -return 0 ; +return report_summary ();Needs
report_skip?x86/tsc.c
Quoted 2 lines
x86/tsc.c +0
-0printf ("rdtscp not supported\n" );Needs
report_skip?
Quoted 4 lines
x86/tsc.c
Quoted 2 lines
x86/tsc.c +1
-1-return 0 ; +return report_summary ();Just sending a fixup patch is enough.
report_skip is not needed, because the a test that ended in report_summary without any report is considered as skipped.
The fixup below turns printfs to report_skip is below. The difference is that summary will now print
SKIP pku (1 tests, 1 skipped)
instead of previous
SKIP pku (0 tests)
I like "0 tests" summary better and only x86/hyperv_synic does the opposite, so a fix could go both ways.
---8<---
x86/pku.c +1 -1
@@ -67,7 +67,7 @@ int main(int ac, char **av)unsigned int pkru_wd =0x20 ;if (!(cpuid_indexed (7 ,0 ).c & (1 <<X86_FEATURE_PKU ))) { -printf ("PKU not enabled, aborting\n" ); +report_skip ("PKU not enabled\n" );return report_summary (); }
x86/pmu.c +1 -1
@@ -390,7 +390,7 @@ int main(int ac, char **av) host_nmi_watchdog =atol_keyval (ac, av,"host_nmi_watchdog" );if (!eax.split.version_id) { -printf ("No pmu is detected!\n" ); +report_skip ("No pmu is detected!\n" );return report_summary (); }printf ("PMU version: %d\n" , eax.split.version_id);
x86/smap.c +1 -1
@@ -92,7 +92,7 @@ int main(int ac, char **av)unsigned long i;if (!(cpuid_indexed (7 ,0 ).b & (1 <<X86_FEATURE_SMAP ))) { -printf ("SMAP not enabled, aborting\n" ); +report_skip ("SMAP not enabled\n" );return report_summary (); }
x86/svm.c +1 -1
@@ -1063,7 +1063,7 @@ int main(int ac, char **av)smp_init ();if (!(cpuid (0x80000001 ).c &4 )) { -printf ("SVM not availble\n" ); +report_skip ("SVM not availble\n" );return report_summary (); }
x86/tsc.c +1 -1
@@ -42,6 +42,6 @@ int main()test_rdtscp (10 );test_rdtscp (0x100 ); }else -printf ("rdtscp not supported\n" ); +report_skip ("rdtscp not supported\n" );return report_summary (); }
Re: [kvm-unit-tests PATCH v4 02/13] x86/*: report skipped tests
2016-05-25 19:19+0200, Radim Krčmář:
Quoted 10 lines
is that summary will now print
SKIP pku (1 tests, 1 skipped)
instead of previous
SKIP pku (0 tests)
I like "0 tests" summary better and only x86/hyperv_synic does the opposite, so a fix could go both ways.
The fixup below does the other way. And the commit message could read "Some care to consistency [...]" with either of them. :)
---8<---
x86/hyperv_synic.c +1 -1
@@ -202,7 +202,7 @@ int main(int ac, char **av)report ("Hyper-V SynIC test" , ok); }else { -report_skip ("Hyper-V SynIC is not supported" ); +printf ("Hyper-V SynIC is not supported" ); }return report_summary ();
x86/pku.c +1 -1
@@ -67,7 +67,7 @@ int main(int ac, char **av)unsigned int pkru_wd =0x20 ;if (!(cpuid_indexed (7 ,0 ).c & (1 <<X86_FEATURE_PKU ))) { -printf ("PKU not enabled, aborting\n" ); +printf ("PKU not enabled\n" );return report_summary (); }
x86/smap.c +1 -1
@@ -92,7 +92,7 @@ int main(int ac, char **av)unsigned long i;if (!(cpuid_indexed (7 ,0 ).b & (1 <<X86_FEATURE_SMAP ))) { -printf ("SMAP not enabled, aborting\n" ); +printf ("SMAP not enabled\n" );return report_summary (); }
Paolo Bonzini
maintainerRe: [kvm-unit-tests PATCH v4 02/13] x86/*: report skipped tests
Quoted 31 lines · Radim Krčmář
x86/hyperv_synic.c +1
-1@@ -202,7 +202,7 @@ int main(int ac, char **av)report ("Hyper-V SynIC test" , ok); }else { -report_skip ("Hyper-V SynIC is not supported" ); +printf ("Hyper-V SynIC is not supported" ); }return report_summary ();x86/pku.c +1
-1@@ -67,7 +67,7 @@ int main(int ac, char **av)unsigned int pkru_wd =0x20 ;if (!(cpuid_indexed (7 ,0 ).c & (1 <<X86_FEATURE_PKU ))) { -printf ("PKU not enabled, aborting\n" ); +printf ("PKU not enabled\n" );return report_summary (); }x86/smap.c +0
-0
x86/smap.c int main(int ac, char **av) · line 98
Quoted 8 lines
x86/smap.c +1
-1@@ -92,7 +92,7 @@ int main(int ac, char **av)unsigned long i;if (!(cpuid_indexed (7 ,0 ).b & (1 <<X86_FEATURE_SMAP ))) { -printf ("SMAP not enabled, aborting\n" ); +printf ("SMAP not enabled\n" );return report_summary (); }
This one looks good.
Thanks,
Paolo
PATCH v4 3/13 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
@@ -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.2
PATCH v4 4/13 lib/string: add strncmp
In reply to Radim Krčmář---
v4: new
lib/string.c | 17 ++++++++++------- lib/string.h | 1 + 2 files changed, 11 insertions(+), 7 deletions(-)
lib/string.c +10 -7
@@ -26,15 +26,18 @@ char *strcpy(char *dest, const char *src)return strcat (dest, src); } +int strncmp (const char *a,const char *b,size_t n) +{ +for (; n--; ++a, ++b) +if (*a != *b || *a =='\0' ) +return *a - *b; + +return 0 ; +} +int strcmp (const char *a,const char *b) { -while (*a == *b) { -if (*a =='\0' ) { -break ; - } - ++a, ++b; - } -return *a - *b; +return strncmp (a, b,SIZE_MAX ); }char *strchr (const char *s,int c)
lib/string.h +1 -0
@@ -5,6 +5,7 @@ extern unsigned long strlen(const char *buf);extern char *strcat (char *dest,const char *src);extern char *strcpy (char *dest,const char *src);extern int strcmp (const char *a,const char *b); +extern int strncmp (const char *a,const char *b,size_t n);extern char *strchr (const char *s,int c);extern char *strstr (const char *haystack,const char *needle);extern void *memset (void *s,int c,size_t n);
Signature · 1 line
2.8.2
Re: [kvm-unit-tests PATCH v4 04/13] lib/string: add strncmp
Quoted 7 lines · Radim Krčmář
Signed-off-by Radim Krčmář <[email protected]>---
v4: newlib/string.c | 17 ++++++++++------- lib/string.h | 1 + 2 files changed, 11 insertions(+), 7 deletions(-)
Quoted 46 lines
lib/string.c +10
-7@@ -26,15 +26,18 @@ char *strcpy(char *dest, const char *src)return strcat (dest, src); } +int strncmp (const char *a,const char *b,size_t n) +{ +for (; n--; ++a, ++b) +if (*a != *b || *a =='\0' ) +return *a - *b; + +return 0 ; +} +int strcmp (const char *a,const char *b) { -while (*a == *b) { -if (*a =='\0' ) { -break ; - } - ++a, ++b; - } -return *a - *b; +return strncmp (a, b,SIZE_MAX ); }char *strchr (const char *s,int c)lib/string.h +1
-0@@ -5,6 +5,7 @@ extern unsigned long strlen(const char *buf);extern char *strcat (char *dest,const char *src);extern char *strcpy (char *dest,const char *src);extern int strcmp (const char *a,const char *b); +extern int strncmp (const char *a,const char *b,size_t n);extern char *strchr (const char *s,int c);extern char *strstr (const char *haystack,const char *needle);extern void *memset (void *s,int c,size_t n);Signature · 1 line
2.8.2
PATCH v4 5/13 lib/util: add args_parse_keyval
In reply to Radim KrčmářThe function parses command line arguments in "key=val" format, and treats "key" as "key=1".
---
v4: new
lib/util.c | 17 +++++++++++++++++ lib/util.h | 10 ++++++++++ 2 files changed, 27 insertions(+)
lib/util.c +17 -0
@@ -16,3 +16,20 @@ int parse_keyval(char *s, long *val) *val =atol (p+1 );return p - s; } + +long args_parse_keyval (int argc,char **argv,char *key) +{ +int i; +size_t keylen =strlen (key); + +for (i =1 ; i < argc; i++) { +if (keylen >0 &&strncmp (argv[i], key, keylen -1 )) +continue ; +if (argv[i][keylen] =='\0' ) +return 1 ; +if (argv[i][keylen] =='=' ) +return atol (argv[i] + keylen +1 ); + } + +return 0 ; +}
lib/util.h +10 -0
@@ -20,4 +20,14 @@*/ extern int parse_keyval (char *s,long *val); +/* +* argc and argv are standard C arguments to main(). +* args_parse_keyval looks for an element of argv that matches the key. +* Returns val interpreted as a long if the element is in key=val format. +* Returns 1 if the element is key. +* Returns 0 otherwise. +* +*/ +long args_parse_keyval (int argc,char **argv,char *key); +#endif
Signature · 1 line
2.8.2
Re: [kvm-unit-tests PATCH v4 05/13] lib/util: add args_parse_keyval
Quoted 16 lines · Radim Krčmář
The function parses command line arguments in "key=val" format, and treats "key" as "key=1".
Signed-off-by Radim Krčmář <[email protected]>---
v4: newlib/util.c | 17 +++++++++++++++++ lib/util.h | 10 ++++++++++ 2 files changed, 27 insertions(+)lib/util.c +0
-0
lib/util.c int parse_keyval(char *s, long *val) · line 21
Quoted 6 lines
lib/util.c +3
-0@@ -16,3 +16,20 @@ int parse_keyval(char *s, long *val) *val =atol (p+1 );return p - s; } + +long args_parse_keyval (int argc,char **argv,char *key) +{
I like this better than parse_keyval, except for...
lib/util.c int parse_keyval(char *s, long *val) · line 34
Quoted 13 lines
lib/util.c +13
-0+int i; +size_t keylen =strlen (key); + +for (i =1 ; i < argc; i++) { +if (keylen >0 &&strncmp (argv[i], key, keylen -1 )) +continue ; +if (argv[i][keylen] =='\0' ) +return 1 ; +if (argv[i][keylen] =='=' ) +return atol (argv[i] + keylen +1 ); + } + +return 0 ;
...this. Here we have ambiguous results. Either key was there and had a value of 0, or wasn't there, and we still get zero. How about merging the two, and then fixing-up the arm and powerpc uses of the old one. I'd drop the "args_" from the name then too.
Thanks,
drew
Quoted 27 lines
lib/util.c +1
-0+}lib/util.h +10
-0@@ -20,4 +20,14 @@*/ extern int parse_keyval (char *s,long *val); +/* +* argc and argv are standard C arguments to main(). +* args_parse_keyval looks for an element of argv that matches the key. +* Returns val interpreted as a long if the element is in key=val format. +* Returns 1 if the element is key. +* Returns 0 otherwise. +* +*/ +long args_parse_keyval (int argc,char **argv,char *key); +#endif Signature · 6 lines
2.8.2 -- 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
Re: [kvm-unit-tests PATCH v4 05/13] lib/util: add args_parse_keyval
2016-05-11 18:58+0200, Andrew Jones:
Quoted 26 lines · Radim Krčmář
Quoted 16 lines
The function parses command line arguments in "key=val" format, and treats "key" as "key=1".
Signed-off-by Radim Krčmář <[email protected]>---
v4: newlib/util.c | 17 +++++++++++++++++ lib/util.h | 10 ++++++++++ 2 files changed, 27 insertions(+)lib/util.c +0
-0lib/util.c int parse_keyval(char *s, long *val) · line 21
Quoted 6 lines
lib/util.c +3
-0@@ -16,3 +16,20 @@ int parse_keyval(char *s, long *val) *val =atol (p+1 );return p - s; } + +long args_parse_keyval (int argc,char **argv,char *key) +{I like this better than
parse_keyval, except for...
Quoted 16 lines
lib/util.c int parse_keyval(char *s, long *val) · line 34
Quoted 13 lines
lib/util.c +13
-0+int i; +size_t keylen =strlen (key); + +for (i =1 ; i < argc; i++) { +if (keylen >0 &&strncmp (argv[i], key, keylen -1 )) +continue ; +if (argv[i][keylen] =='\0' ) +return 1 ; +if (argv[i][keylen] =='=' ) +return atol (argv[i] + keylen +1 ); + } + +return 0 ;...this. Here we have ambiguous results. Either key was there and had a value of 0, or wasn't there, and we still get zero.
Yes, I implied a boolean key.
Quoted 3 lines
How about merging the two, and then fixing-up the arm and powerpc uses of the old one. I'd drop the "
args_" from the name then too.
Seems reasonable. I'll make a new series:
[1/3] add strncmp
[2/3] add a slightly modified args_parse_keyval,
int __parse_keyval(int argc, char **argv, char *key, long *val) that will return -1/0/1 on !key/key/key=val
[3/3] replace parse_keyval with renamed __parse_keyval
([2/3] and [3/3] may be squished) The series will depend on your "make argv[0] the program name" and v5 of mine will depend on it.
Re: [kvm-unit-tests PATCH v4 05/13] lib/util: add args_parse_keyval
In reply to Radim KrčmářQuoted 16 lines · Radim Krčmář
The function parses command line arguments in "key=val" format, and treats "key" as "key=1".
Signed-off-by Radim Krčmář <[email protected]>---
v4: newlib/util.c | 17 +++++++++++++++++ lib/util.h | 10 ++++++++++ 2 files changed, 27 insertions(+)lib/util.c +0
-0
lib/util.c int parse_keyval(char *s, long *val) · line 25
Quoted 10 lines
lib/util.c +7
-0@@ -16,3 +16,20 @@ int parse_keyval(char *s, long *val) *val =atol (p+1 );return p - s; } + +long args_parse_keyval (int argc,char **argv,char *key) +{ +int i; +size_t keylen =strlen (key); + +for (i =1 ; i < argc; i++) {
Forgot to mention that I like this 'i = 1' here because it's motivation to merge a series[*] I have in flight :-)
Quoted 36 lines
lib/util.c +10
-0+if (keylen >0 &&strncmp (argv[i], key, keylen -1 )) +continue ; +if (argv[i][keylen] =='\0' ) +return 1 ; +if (argv[i][keylen] =='=' ) +return atol (argv[i] + keylen +1 ); + } + +return 0 ; +}lib/util.h +10
-0@@ -20,4 +20,14 @@*/ extern int parse_keyval (char *s,long *val); +/* +* argc and argv are standard C arguments to main(). +* args_parse_keyval looks for an element of argv that matches the key. +* Returns val interpreted as a long if the element is in key=val format. +* Returns 1 if the element is key. +* Returns 0 otherwise. +* +*/ +long args_parse_keyval (int argc,char **argv,char *key); +#endif Signature · 6 lines
2.8.2 -- 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
PATCH v4 6/13 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.
---
v4: improved command line parsing [Drew]
x86/Makefile.common | 1 + x86/pmu.c | 6 +++++- x86/unittests.cfg | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-)
x86/Makefile.common +1 -0
@@ -3,6 +3,7 @@ all: test_cases cflatobjs += lib/pci.o +cflatobjs += lib/util.o cflatobjs += lib/x86/io.o cflatobjs += lib/x86/smp.o cflatobjs += lib/x86/vm.o
x86/pmu.c +5 -1
@@ -8,6 +8,7 @@#include "x86/vm.h" #include "libcflat.h" +#include <util.h> #include <stdint.h> #define FIXED_CNT_INDEX 32
@@ -92,6 +93,7 @@ struct pmu_event { };static int num_counters; +static bool host_nmi_watchdog;char *buf;
@@ -291,7 +293,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 )
@@ -385,6 +387,8 @@ int main(int ac, char **av) ebx.full = id.b; edx.full = id.d; + host_nmi_watchdog =args_parse_keyval (ac, av,"host_nmi_watchdog" ); +if (!eax.split.version_id) {printf ("No pmu is detected!\n" );return report_summary ();
x86/unittests.cfg +1 -2
@@ -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.2
Re: [kvm-unit-tests PATCH v4 06/13] x86/pmu: expect failure with nmi_watchdog
Quoted 5 lines · Radim Krčmář
Host's
nmi_watchdogtakes 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.
Quoted 8 lines
Signed-off-by Radim Krčmář <[email protected]>---
v4: improved command line parsing [Drew]x86/Makefile.common | 1 + x86/pmu.c | 6 +++++- x86/unittests.cfg | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-)
Quoted 72 lines
x86/Makefile.common +1
-0@@ -3,6 +3,7 @@ all: test_cases cflatobjs += lib/pci.o +cflatobjs += lib/util.o cflatobjs += lib/x86/io.o cflatobjs += lib/x86/smp.o cflatobjs += lib/x86/vm.ox86/pmu.c +5
-1@@ -8,6 +8,7 @@#include "x86/vm.h" #include "libcflat.h" +#include <util.h> #include <stdint.h> #define FIXED_CNT_INDEX 32@@ -92,6 +93,7 @@ struct pmu_event { };static int num_counters; +static bool host_nmi_watchdog;char *buf;@@ -291,7 +293,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 )@@ -385,6 +387,8 @@ int main(int ac, char **av) ebx.full = id.b; edx.full = id.d; + host_nmi_watchdog =args_parse_keyval (ac, av,"host_nmi_watchdog" ); +if (!eax.split.version_id) {printf ("No pmu is detected!\n" );return report_summary ();x86/unittests.cfg +1
-2@@ -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.flatSignature · 6 lines
2.8.2 -- 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
PATCH v4 7/13 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
@@ -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.2
PATCH v4 8/13 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 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
scripts/runtime.bash +10 -6
@@ -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,7 +38,7 @@ 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
@@ -50,13 +54,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.2
Paolo Bonzini
maintainerRe: [kvm-unit-tests PATCH v4 08/13] scripts/runtime: consolidate summary tags
Quoted 13 lines · Radim Krčmář
Turn skip into yellow SKIP and add reusable definitions of all tags.
Reviewed-by Andrew Jones <[email protected]>Signed-off-by Radim Krčmář <[email protected]>--- scripts/runtime.bash | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)scripts/runtime.bash +0
-0
scripts/runtime.bash line 7
Quoted 6 lines
scripts/runtime.bash +3
-0@@ -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"; }
If you use for example $'\e[32mPASS\e[0m', then you can use variables instead of functions.
Quoted 41 lines
scripts/runtime.bash +7
-6+ 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,7 +38,7 @@ 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@@ -50,13 +54,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
Re: [kvm-unit-tests PATCH v4 08/13] scripts/runtime: consolidate summary tags
2016-05-17 14:22+0200, Paolo Bonzini:
Quoted 17 lines · Radim Krčmář
Quoted 16 lines
Turn skip into yellow SKIP and add reusable definitions of all tags.
Reviewed-by Andrew Jones <[email protected]>Signed-off-by Radim Krčmář <[email protected]>--- scripts/runtime.bash | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)scripts/runtime.bash +0
-0@@ -2,6 +2,10 @@ : ${MAX_SMP:=$(getconf _NPROCESSORS_CONF)} : ${TIMEOUT:=90s}
Quoted 6 lines
scripts/runtime.bash line 7
Quoted 3 lines
scripts/runtime.bash +3
-0+PASS() { echo -ne "\e[32mPASS\e[0m"; } +SKIP() { echo -ne "\e[33mSKIP\e[0m"; } +FAIL() { echo -ne "\e[31mFAIL\e[0m"; }If you use for example $'\e[32mPASS\e[0m', then you can use variables instead of functions.
Great, thanks. A fixup is below
---8<---
scripts/runtime.bash +10 -10
@@ -2,9 +2,9 @@ : ${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"; } +PASS=$'\e[32mPASS\e[0m' +SKIP=$'\e[33mSKIP\e[0m' +FAIL=$'\e[31mFAIL\e[0m' extract_summary() {
@@ -53,18 +53,18 @@ function run() fi if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then - echo "`SKIP` $1 ($arch only)" + echo "$SKIP $1 ($arch only)" return 2 fi eval $check || { echo "skipped $testname (\`$check\` returned $?)" | RUNTIME_log_stderr - echo "`SKIP` $testname (check failed)" + echo "$SKIP $testname (check failed)" return 77 } last_line=$(premature_failure) && { - echo "`SKIP` $1 ($last_line)" + echo "$SKIP $1 ($last_line)" return 77 }
@@ -80,13 +80,13 @@ function run() ret=$? if [ $ret -eq 0 ]; then - echo "`PASS` $1 $summary" + echo "$PASS $1 $summary" elif [ $ret -eq 77 ]; then - echo "`SKIP` $1 $summary" + echo "$SKIP $1 $summary" elif [ $ret -eq 124 ]; then - echo "`FAIL` $1 (timeout; duration=$timeout)" + echo "$FAIL $1 (timeout; duration=$timeout)" else - echo "`FAIL` $1 $summary" + echo "$FAIL $1 $summary" fi return $ret
PATCH v4 9/13 run_tests: print SUMMARY line in 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.
---
v4:
* less ev[ai]l [Paolo]
* didn't include Drew's r-b
run_tests.sh | 14 ++++++++------ scripts/mkstandalone.sh | 3 +++ scripts/runtime.bash | 15 ++++++++++----- 3 files changed, 21 insertions(+), 11 deletions(-)
run_tests.sh +8 -6
@@ -46,13 +46,15 @@ while getopts "g:hv" opt; do esac done -if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then - log_redir="> >(./scripts/pretty_print_stacks.py \$kernel >> test.log)" -else - log_redir=">> test.log" -fi +RUNTIME_log_stdout () { + if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then + ./scripts/pretty_print_stacks.py $1 >> test.log + else + cat >> 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
@@ -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
@@ -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"
@@ -49,18 +54,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 > >(tee >(RUNTIME_log_stdout $kernel) | 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.2
Re: [kvm-unit-tests PATCH v4 09/13] run_tests: print SUMMARY line in summary
Quoted 10 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.
Signed-off-by Radim Krčmář <[email protected]>---
v4:
* less ev[ai]l [Paolo]
* didn't include Drew's r-b
Quoted 4 lines
run_tests.sh | 14 ++++++++------ scripts/mkstandalone.sh | 3 +++ scripts/runtime.bash | 15 ++++++++++----- 3 files changed, 21 insertions(+), 11 deletions(-)
Quoted 88 lines
run_tests.sh +8
-6@@ -46,13 +46,15 @@ while getopts "g:hv" opt; do esac done -if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then - log_redir="> >(./scripts/pretty_print_stacks.py \$kernel >> test.log)" -else - log_redir=">> test.log" -fi +RUNTIME_log_stdout () { + if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then + ./scripts/pretty_print_stacks.py $1 >> test.log + else + cat >> 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.logscripts/mkstandalone.sh +3
-0@@ -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@@ -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"@@ -49,18 +54,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 > >(tee >(RUNTIME_log_stdout $kernel) | 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 $retSignature · 6 lines
2.8.2 -- 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
Paolo Bonzini
maintainerRe: [kvm-unit-tests PATCH v4 09/13] run_tests: print SUMMARY line in summary
In reply to Radim KrčmářQuoted 1 line · Radim Krčmář
+ # expanded, so use eval to start qemu. Same for $RUNTIME_log_stdout.
Luckily the second part is not true anymore. Fixed it myself.
Paolo
Quoted 1 line
+ summary=$(eval $cmdline > >(tee >(RUNTIME_log_stdout $kernel) |
extract_summary))
Re: [kvm-unit-tests PATCH v4 09/13] run_tests: print SUMMARY line in summary
2016-05-17 14:32+0200, Paolo Bonzini:
Quoted 4 lines · Radim Krčmář
Quoted 1 line
+ # expanded, so use eval to start qemu. Same for $RUNTIME_log_stdout.
Luckily the second part is not true anymore. Fixed it myself.
Thanks.
PATCH v4 10/13 run_tests: log stderr
In reply to Radim KrčmářSummary should provide all important information.
---
v4: new
run_tests.sh | 1 + scripts/mkstandalone.sh | 1 + scripts/runtime.bash | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)
run_tests.sh +1 -0
@@ -46,6 +46,7 @@ while getopts "g:hv" opt; do esac done +RUNTIME_log_stderr () { cat >> test.log; } RUNTIME_log_stdout () { if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then ./scripts/pretty_print_stacks.py $1 >> test.log
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; }" cat scripts/runtime.bash
scripts/runtime.bash +2 -1
@@ -55,7 +55,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 > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary)) + summary=$(eval $cmdline 2> >(RUNTIME_log_stderr) \ + > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary)) ret=$? if [ $ret -eq 0 ]; then
Signature · 1 line
2.8.2
PATCH v4 11/13 scripts/runtime: skip tests that cannot run
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. Some error messages in arch/run were reworded, because they are now visible in summary.
---
v4:
* clarified "kvm only" error message [Drew+Lukáš]
* used _NO_FILE_4Uhere_ instead of /dev/null [Drew]
* completely reworked output, now prints the last line
arm/run | 2 +- powerpc/run | 2 +- scripts/runtime.bash | 28 +++++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-)
arm/run +1 -1
@@ -19,7 +19,7 @@ if [ -c /dev/kvm ]; then fi if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then - echo "skip $TESTNAME (kvm only)" + echo "KVM is needed, but not available on this host" exit 2 fi
powerpc/run +1 -1
@@ -16,7 +16,7 @@ if [ -c /dev/kvm ]; then fi if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then - echo "skip $TESTNAME (kvm only)" + echo "KVM is needed, but not available on this host" exit 2 fi
scripts/runtime.bash +27 -1
@@ -11,6 +11,27 @@ extract_summary() tail -1 | grep '^SUMMARY: ' | sed 's/^SUMMARY: /(/;s/$/)/' } +# We assume that QEMU is going to work if it tried to load the kernel +premature_failure() +{ + local log="$(eval $(get_cmdline _NO_FILE_4Uhere_) 2>&1)" + local last_line=$(tail -1 <<< "$log") + + echo "$last_line" | grep -qi "could not load kernel" && + return 1 + + RUNTIME_log_stderr <<< "$log" + + echo "$last_line" + return 0 +} + +get_cmdline() +{ + local kernel=$1 + echo "TESTNAME=$testname TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts" +} + function run() { local testname="$1"
@@ -48,7 +69,12 @@ function run() fi done - cmdline="TESTNAME=$testname TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts" + last_line=$(premature_failure) && { + echo "`SKIP` $1 ($last_line)" + return 77 + } + + cmdline=$(get_cmdline $kernel) if [ "$verbose" = "yes" ]; then echo $cmdline fi
Signature · 1 line
2.8.2
Re: [kvm-unit-tests PATCH v4 11/13] scripts/runtime: skip tests that cannot run
Quoted 12 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. Some error messages in
arch/runwere reworded, because they are now visible in summary.Signed-off-by Radim Krčmář <[email protected]>---
v4:
* clarified "kvm only" error message [Drew+Lukáš]
* used _NO_FILE_4Uhere_ instead of/dev/null[Drew]
* completely reworked output, now prints the last line
Quoted 4 lines
arm/run | 2 +- powerpc/run | 2 +- scripts/runtime.bash | 28 +++++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-)
Quoted 80 lines
arm/run +1
-1@@ -19,7 +19,7 @@ if [ -c /dev/kvm ]; then fi if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then - echo "skip $TESTNAME (kvm only)" + echo "KVM is needed, but not available on this host" exit 2 fipowerpc/run +1
-1@@ -16,7 +16,7 @@ if [ -c /dev/kvm ]; then fi if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then - echo "skip $TESTNAME (kvm only)" + echo "KVM is needed, but not available on this host" exit 2 fiscripts/runtime.bash +27
-1@@ -11,6 +11,27 @@ extract_summary() tail -1 | grep '^SUMMARY: ' | sed 's/^SUMMARY: /(/;s/$/)/' } +# We assume that QEMU is going to work if it tried to load the kernel +premature_failure() +{ + local log="$(eval $(get_cmdline _NO_FILE_4Uhere_) 2>&1)" + local last_line=$(tail -1 <<< "$log") + + echo "$last_line" | grep -qi "could not load kernel" && + return 1 + + RUNTIME_log_stderr <<< "$log" + + echo "$last_line" + return 0 +} + +get_cmdline() +{ + local kernel=$1 + echo "TESTNAME=$testname TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts" +} + function run() { local testname="$1"@@ -48,7 +69,12 @@ function run() fi done - cmdline="TESTNAME=$testname TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts" + last_line=$(premature_failure) && { + echo "`SKIP` $1 ($last_line)" + return 77 + } + + cmdline=$(get_cmdline $kernel) if [ "$verbose" = "yes" ]; then echo $cmdline fiSignature · 6 lines
2.8.2 -- 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
PATCH v4 12/13 scripts/arch-run: change QEMU failure detection
In reply to Radim KrčmářWe FAIL the test whenever there is an output on stderr. QEMU or its libraries can warn and the test could still work, so ignore any line that has a warning keyword.
---
v4: new
scripts/arch-run.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/arch-run.bash +1 -1
@@ -55,7 +55,7 @@ run_qemu () # Even when ret==1 (unittest success) if we also got stderr # logs, then we assume a QEMU failure. Otherwise we translate # status of 1 to 0 (SUCCESS) - if [ -z "$errors" ]; then + if [ -z "$(echo "$errors" | grep -vi warning)" ]; then ret=0 fi fi
Signature · 1 line
2.8.2
Re: [kvm-unit-tests PATCH v4 12/13] scripts/arch-run: change QEMU failure detection
Quoted 10 lines · Radim Krčmář
We FAIL the test whenever there is an output on stderr. QEMU or its libraries can warn and the test could still work, so ignore any line that has a warning keyword.
Signed-off-by Radim Krčmář <[email protected]>---
v4: newscripts/arch-run.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 21 lines
scripts/arch-run.bash +1
-1@@ -55,7 +55,7 @@ run_qemu () # Even when ret==1 (unittest success) if we also got stderr # logs, then we assume a QEMU failure. Otherwise we translate # status of 1 to 0 (SUCCESS) - if [ -z "$errors" ]; then + if [ -z "$(echo "$errors" | grep -vi warning)" ]; then ret=0 fi fiSignature · 6 lines
2.8.2 -- 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
PATCH v4 13/13 scripts/run: generalize check
In reply to Radim Krčmářconfig attribute "check" is currently unused and a simpler imlementation has better chances of being used.
---
v4: new
scripts/runtime.bash | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
scripts/runtime.bash +5 -11
@@ -57,17 +57,11 @@ function run() return 2 fi - # check a file for a particular value before running a test - # the check line can contain multiple files to check separated by a space - # but each check parameter needs to be of the form <path>=<value> - for check_param in ${check[@]}; do - path=${check_param%%=*} - value=${check_param#*=} - if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then - echo "`SKIP` $1 ($path not equal to $value)" - return 2 - fi - done + eval $check || { + echo "skipped $testname (\`$check\` returned $?)" | RUNTIME_log_stderr + echo "`SKIP` $testname (check failed)" + return 77 + } last_line=$(premature_failure) && { echo "`SKIP` $1 ($last_line)"
Signature · 1 line
2.8.2
Re: [kvm-unit-tests PATCH v4 13/13] scripts/run: generalize check
Quoted 28 lines · Radim Krčmář
config attribute "check" is currently unused and a simpler imlementation has better chances of being used.
Signed-off-by Radim Krčmář <[email protected]>---
v4: newscripts/runtime.bash | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)scripts/runtime.bash +0
-9@@ -57,17 +57,11 @@ function run() return 2 fi - # check a file for a particular value before running a test - # the check line can contain multiple files to check separated by a space - # but each check parameter needs to be of the form <path>=<value> - for check_param in ${check[@]}; do - path=${check_param%%=*} - value=${check_param#*=} - if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then - echo "`SKIP` $1 ($path not equal to $value)" - return 2
scripts/runtime.bash function run() · line 67
Quoted 10 lines
scripts/runtime.bash +5
-2- fi - done + eval $check || { + echo "skipped $testname (\`$check\` returned $?)" | RUNTIME_log_stderr + echo "`SKIP` $testname (check failed)" + return 77 + } last_line=$(premature_failure) && { echo "`SKIP` $1 ($last_line)"
Good, except you need to update all the unittests.cfg headers where check is documented. Maybe something like
check = <bash-expr> # check an expression is true before running the test
Thanks,
drew
Re: [kvm-unit-tests PATCH v4 10/13] run_tests: log stderr
In reply to Radim KrčmářQuoted 10 lines · Radim Krčmář
Summary should provide all important information.
Signed-off-by Radim Krčmář <[email protected]>---
v4: newrun_tests.sh | 1 + scripts/mkstandalone.sh | 1 + scripts/runtime.bash | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)
Quoted 46 lines
run_tests.sh +1
-0@@ -46,6 +46,7 @@ while getopts "g:hv" opt; do esac done +RUNTIME_log_stderr () { cat >> test.log; } RUNTIME_log_stdout () { if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then ./scripts/pretty_print_stacks.py $1 >> test.logscripts/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; }" cat scripts/runtime.bashscripts/runtime.bash +2
-1@@ -55,7 +55,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 > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary)) + summary=$(eval $cmdline 2> >(RUNTIME_log_stderr) \ + > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary)) ret=$? if [ $ret -eq 0 ]; thenSignature · 6 lines
2.8.2 -- 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
Paolo Bonzini
maintainerQuoted 6 lines · Radim Krčmář
Radim Krčmář (13):
lib/report: allow test skipping
x86/*: report skipped tests
x86/unittests: remove svm-disabled
lib/string: add strncmp
lib/util: addargs_parse_keyval
Quoted 8 lines
x86/pmu: expect failure with
nmi_watchdog
lib/report: don't print 0 failed tests
scripts/runtime: consolidate summary tags
run_tests: print SUMMARY line in summary
run_tests: log stderr
scripts/runtime: skip tests that cannot run
scripts/arch-run: change QEMU failure detection
scripts/run: generalize check
Applying everything except 5, 6, 13. It would be nice to get the fixup for patch 3 before I push...
Paolo
Quoted 24 lines
arm/run | 2 +- lib/libcflat.h | 1 + lib/report.c | 49 ++++++++++++++++++++++++----------- lib/string.c | 17 ++++++++----- lib/string.h | 1 + lib/util.c | 17 +++++++++++++ lib/util.h | 10 ++++++++ powerpc/run | 2 +- run_tests.sh | 15 ++++++----- scripts/arch-run.bash | 2 +- scripts/mkstandalone.sh | 4 +++ scripts/runtime.bash | 68 ++++++++++++++++++++++++++++++++++++------------- x86/Makefile.common | 1 + x86/apic.c | 7 +++-- x86/emulator.c | 2 +- x86/hyperv_synic.c | 2 +- x86/pku.c | 2 +- x86/pmu.c | 8 ++++-- x86/smap.c | 2 +- x86/svm.c | 2 +- x86/tsc.c | 2 +- x86/unittests.cfg | 9 +------ 22 files changed, 156 insertions(+), 69 deletions(-)
2016-05-17 14:29+0200, Paolo Bonzini:
Quoted 16 lines · Radim Krčmář
Quoted 6 lines
Radim Krčmář (13):
lib/report: allow test skipping
x86/*: report skipped tests
x86/unittests: remove svm-disabled
lib/string: add strncmp
lib/util: addargs_parse_keyvalQuoted 8 lines
x86/pmu: expect failure with
nmi_watchdog
lib/report: don't print 0 failed tests
scripts/runtime: consolidate summary tags
run_tests: print SUMMARY line in summary
run_tests: log stderr
scripts/runtime: skip tests that cannot run
scripts/arch-run: change QEMU failure detection
scripts/run: generalize check
Quoted 2 lines
Applying everything except 5, 6, 13. It would be nice to get the fixup for patch 3 before I push...
Sorry for the delay ... I am overloaded for the next month as well, so improved versions of 5 and 6 seem unlikely before July.
Paolo Bonzini
maintainerQuoted 17 lines · Radim Krčmář
2016-05-17 14:29+0200, Paolo Bonzini:
Quoted 16 lines · Radim Krčmář
Quoted 14 lines
Radim Krčmář (13):
lib/report: allow test skipping
x86/*: report skipped tests
x86/unittests: remove svm-disabled
lib/string: add strncmp
lib/util: addargs_parse_keyval
x86/pmu: expect failure withnmi_watchdog
lib/report: don't print 0 failed tests
scripts/runtime: consolidate summary tags
run_tests: print SUMMARY line in summary
run_tests: log stderr
scripts/runtime: skip tests that cannot run
scripts/arch-run: change QEMU failure detection
scripts/run: generalize check
Quoted 5 lines
Quoted 2 lines
Applying everything except 5, 6, 13. It would be nice to get the fixup for patch 3 before I push...
Sorry for the delay ... I am overloaded for the next month as well, so improved versions of 5 and 6 seem unlikely before July.
Applying the fixup to patch 2 and pushing to git.kernel.org, thanks.
Thanks,
Paolo