Skip to contentSkip to conversation

few framework cleanups

PATCH In review Andrew Jones 2 participants 6 messages Dec 19, 2016 – Dec 22, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover few framework cleanups

clean build-head, remove extra empty lines, move summary's empty line

Andrew Jones (3):
Makefile: distclean should remove build-head report already adds a newline
report: move blank line to better side of SUMMARY

 scripts/runtime.bash | 1 +
 Makefile             | 3 ++-
 lib/report.c         | 2 +-
 arm/spinlock-test.c  | 2 +-
 x86/asyncpf.c        | 8 ++++----
 x86/svm.c            | 4 ++--
 x86/vmx_tests.c      | 2 +-
 7 files changed, 12 insertions(+), 10 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/3 Makefile: distclean should remove build-head

---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -1
index 5201472d146f..a32333b0928e 100644
@@ -94,7 +94,8 @@ libfdt_clean:
 	$(LIBFDT_objdir)/.*.d
 
 distclean: clean libfdt_clean
-	$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
+	$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.* \
+	      build-head
 	$(RM) -r tests
 
 cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/asm-generic
Signature · 1 line
2.9.3
#2 lore raw

PATCH 2/3 report already adds a newline

In reply to Andrew Jones
---
 arm/spinlock-test.c | 2 +-
 x86/asyncpf.c       | 8 ++++----
 x86/svm.c           | 4 ++--
 x86/vmx_tests.c     | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)
arm/spinlock-test.c +1 -1
index 6009ba087e4b..7676a1523db5 100644
@@ -58,7 +58,7 @@ static void test_spinlock(void)
 
 		lock_ops.unlock(&global_lock);
 	}
-	report("CPU%d: Done - Errors: %d\n", errors == 0, cpu, errors);
+	report("CPU%d: Done - Errors: %d", errors == 0, cpu, errors);
 
 	cpumask_set_cpu(cpu, &smp_test_complete);
 	if (cpu != 0)
x86/asyncpf.c +4 -4
index a6051ab03eed..e29e07c556f3 100644
@@ -52,13 +52,13 @@ static void pf_isr(struct ex_regs *r)
 
 	switch (reason) {
 		case 0:
-			report("unexpected #PF at %p\n", false, read_cr2());
+			report("unexpected #PF at %p", false, read_cr2());
 			break;
 		case KVM_PV_REASON_PAGE_NOT_PRESENT:
 			phys = virt_to_phys_cr3(virt);
 			install_pte(phys_to_virt(read_cr3()), 1, virt, phys, 0);
 			write_cr3(read_cr3());
-			report("Got not present #PF token %x virt addr %p phys addr %p\n",
+			report("Got not present #PF token %x virt addr %p phys addr %p",
 					true, read_cr2(), virt, phys);
 			while(phys) {
 				safe_halt(); /* enables irq */
@@ -66,7 +66,7 @@ static void pf_isr(struct ex_regs *r)
 			}
 			break;
 		case KVM_PV_REASON_PAGE_READY:
-			report("Got present #PF token %x\n", true, read_cr2());
+			report("Got present #PF token %x", true, read_cr2());
 			if ((uint32_t)read_cr2() == ~0)
 				break;
 			install_pte(phys_to_virt(read_cr3()), 1, virt, phys | PT_PRESENT_MASK | PT_WRITABLE_MASK, 0);
@@ -74,7 +74,7 @@ static void pf_isr(struct ex_regs *r)
 			phys = 0;
 			break;
 		default:
-			report("unexpected async pf reason %d\n", false, reason);
+			report("unexpected async pf reason %d", false, reason);
 			break;
 	}
 }
x86/svm.c +2 -2
index cef0f568d611..25ac0ce4a645 100644
@@ -603,7 +603,7 @@ static void test_ioio(struct test *test)
     return;
 
 fail:
-    report("stage %d\n", false, get_test_stage(test));
+    report("stage %d", false, get_test_stage(test));
     test->scratch = -1;
 }
 
@@ -678,7 +678,7 @@ static void sel_cr0_bug_test(struct test *test)
      * are not in guest-mode anymore so we can't trigger an intercept.
      * Trigger a tripple-fault for now.
      */
-    report("sel_cr0 test. Can not recover from this - exiting\n", false);
+    report("sel_cr0 test. Can not recover from this - exiting", false);
     exit(report_summary());
 }
 
x86/vmx_tests.c +1 -1
index 5fd95706c418..911bb618d55c 100644
@@ -1098,7 +1098,7 @@ static int ept_exit_handler()
 						(unsigned long)data_page2,
 						EPT_RA | EPT_WA | EPT_EA);
 			} else
-				report("EPT basic framework - write\n", 0);
+				report("EPT basic framework - write", 0);
 			break;
 		case 1:
 			install_ept(pml4, (unsigned long)data_page1,
Signature · 1 line
2.9.3
#3 lore raw

PATCH 3/3 report: move blank line to better side of SUMMARY

In reply to Andrew Jones

Currently test.log gets output of the form

test1-command-line
test1-output

SUMMARY:
test2-command-line
test2-output

SUMMARY:
test3-command-line
...

Having a blank line before SUMMARY, and not after, it makes it tough to group lines by eye. Change it to

test1-command-line
test1-output
SUMMARY:

test2-command-line
test2-output
SUMMARY:

test3-command-line
...

The empty line is moved from report_summary to runtime in order to remove it altogether when running tests individually or as a standalone.

---
 scripts/runtime.bash | 1 +
 lib/report.c         | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
scripts/runtime.bash +1 -0
index 11a40a92183a..9c1bc3b3b3fe 100644
@@ -108,6 +108,7 @@ function run()
     summary=$(eval $cmdline 2> >(RUNTIME_log_stderr) \
                              > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary))
     ret=$?
+    [ "$STANDALONE" != "yes" ] && echo > >(RUNTIME_log_stdout $kernel)
 
     if [ $ret -eq 0 ]; then
         echo "`PASS` $1 $summary"
lib/report.c +1 -1
index fc0ef494f412..e24e81382f9e 100644
@@ -109,7 +109,7 @@ int report_summary(void)
 {
 	spin_lock(&lock);
 
-	printf("\nSUMMARY: %d tests", tests);
+	printf("SUMMARY: %d tests", tests);
 	if (failures)
 		printf(", %d unexpected failures", failures);
 	if (xfailures)
Signature · 1 line
2.9.3
#4 lore raw

Re: [PATCH kvm-unit-tests 3/3] report: move blank line to better side of SUMMARY

Quoted 42 lines · Andrew Jones

Currently test.log gets output of the form

test1-command-line
test1-output

SUMMARY:
test2-command-line
test2-output

SUMMARY:
test3-command-line
...

Having a blank line before SUMMARY, and not after, it makes it tough to group lines by eye. Change it to

test1-command-line
test1-output
SUMMARY:

test2-command-line
test2-output
SUMMARY:

test3-command-line
...

The empty line is moved from report_summary to runtime in order to remove it altogether when running tests individually or as a standalone.

---
 scripts/runtime.bash | 1 +
 lib/report.c         | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
scripts/runtime.bash +0 -0
index 11a40a92183a..9c1bc3b3b3fe 100644

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

Quoted 4 lines
scripts/runtime.bash +1 -0
@@ -108,6 +108,7 @@ function run()
     summary=$(eval $cmdline 2> >(RUNTIME_log_stderr) \
                              > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary))
     ret=$?
+    [ "$STANDALONE" != "yes" ] && echo > >(RUNTIME_log_stdout $kernel)

Hmm, even though this works, because of how we define RUNTIME_log_stdout (eventually using '>> test.log'), I should have used '>>' here as well for correctness.

Paolo,

Assuming we want to merge this patch, will you fix it up on commit? Or should I send a v2?

Thanks,
drew

Quoted 19 lines
scripts/runtime.bash +0 -0
     if [ $ret -eq 0 ]; then
         echo "`PASS` $1 $summary"
lib/report.c +1 -1
index fc0ef494f412..e24e81382f9e 100644
@@ -109,7 +109,7 @@ int report_summary(void)
 {
 	spin_lock(&lock);
 
-	printf("\nSUMMARY: %d tests", tests);
+	printf("SUMMARY: %d tests", tests);
 	if (failures)
 		printf(", %d unexpected failures", failures);
 	if (xfailures)
Signature · 1 line
2.9.3
maintainer
#5 lore raw

Re: [PATCH kvm-unit-tests 3/3] report: move blank line to better side of SUMMARY

Quoted 7 lines · Andrew Jones
Quoted 4 lines
     summary=$(eval $cmdline 2> >(RUNTIME_log_stderr) \
                              > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary))
     ret=$?

+ [ "$STANDALONE" != "yes" ] && echo > >(RUNTIME_log_stdout $kernel)

Hmm, even though this works, because of how we define RUNTIME_log_stdout (eventually using '>> test.log'), I should have used '>>' here as well for correctness.

I think it's okay, you're effectively writing to a pipe and the pipe is opened by this echo invocation. If you do a strace you can see that it's basically

echo | RUNTIME_log_stdout

Here:

    pipe([3, 4])          = 0
    fcntl(63, F_GETFD)    = -1 EBADF (Bad file descriptor)
    dup2(4, 63)           = 63
    close(4)              = 0

Thanks,

Paolo

Quoted 4 lines

Paolo,

Assuming we want to merge this patch, will you fix it up on commit? Or should I send a v2?