Skip to contentSkip to conversation

Improvements for the x86 tests

PATCH Applied Thomas Huth 2 participants 6 messages Dec 11, 2019 – Jan 8, 2020 KVM

lore
Share & tools
lore
#0 lore raw

cover Improvements for the x86 tests

QEMU recently changed the error message that it prints out when a kernel could not be loaded, so we have to adjust our script in kvm-unit-tests accordingly.
Once this is fixed, add two missing tests (setjmp and cmpxchg8b) to the unittests.cfg and CI pipelines.

Thomas Huth (4):
scripts: Fix premature_failure() check with newer versions of QEMU
x86: Fix coding style in setjmp.c
x86: Add the setjmp test to the CI
x86: Add the cmpxchg8b test to the CI

 .gitlab-ci.yml       |  4 ++--
 .travis.yml          |  6 +++---
 scripts/runtime.bash |  2 +-
 x86/setjmp.c         | 22 ++++++++++------------
 x86/unittests.cfg    |  7 +++++++
 5 files changed, 23 insertions(+), 18 deletions(-)
Signature · 1 line
2.18.1
#1 lore raw

PATCH 1/4 scripts: Fix premature_failure() check with newer versions of QEMU

QEMU recently changed its output if it could not open a kernel file from "could not load kernel ..." to "could not open kernel ...", see QEMU commit 350f5233d755 ("hw/i386/pc: avoid an assignment in if condition in x86_load_linux()"). Thus we have to adapt our script that looks for this string accordingly.

---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runtime.bash +1 -1
index fbad0bd..eb60890 100644
@@ -18,7 +18,7 @@ premature_failure()
     local log="$(eval $(get_cmdline _NO_FILE_4Uhere_) 2>&1)"
 
     echo "$log" | grep "_NO_FILE_4Uhere_" |
-        grep -q -e "could not load kernel" -e "error loading" &&
+        grep -q -e "could not \(load\|open\) kernel" -e "error loading" &&
         return 1
 
     RUNTIME_log_stderr <<< "$log"
Signature · 1 line
2.18.1
#2 lore raw

PATCH 2/4 x86: Fix coding style in setjmp.c

In reply to Thomas Huth

No functional change, just use tabs for indentation.

---
 x86/setjmp.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
x86/setjmp.c +12 -12
index 1874944..1a848b4 100644
@@ -9,18 +9,18 @@ static const int expected[] = {
 
 int main(void)
 {
-    volatile int index = 0;
-    jmp_buf j;
-    int i;
+	volatile int index = 0;
+	jmp_buf j;
+	int i;
 
-    i = setjmp(j);
-    if (expected[index] != i) {
-	    printf("FAIL: actual %d / expected %d\n", i, expected[index]);
-	    return -1;
-    }
-    index++;
-    if (i + 1 < NUM_LONGJMPS)
-	    longjmp(j, i + 1);
+	i = setjmp(j);
+	if (expected[index] != i) {
+		printf("FAIL: actual %d / expected %d\n", i, expected[index]);
+		return -1;
+	}
+	index++;
+	if (i + 1 < NUM_LONGJMPS)
+		longjmp(j, i + 1);
 
-    return 0;
+	return 0;
 }
Signature · 1 line
2.18.1
#3 lore raw

PATCH 3/4 x86: Add the setjmp test to the CI

In reply to Thomas Huth

Use a proper report() in the test instead of printf(), and add it to the unittests.cfg and the CI yaml files.

---
 .gitlab-ci.yml    | 4 ++--
 .travis.yml       | 4 ++--
 x86/setjmp.c      | 8 +++-----
 x86/unittests.cfg | 3 +++
 4 files changed, 10 insertions(+), 9 deletions(-)
.gitlab-ci.yml +2 -2
index fbf3328..ea1aeaf 100644
@@ -67,7 +67,7 @@ build-x86_64:
      ioapic-split ioapic smptest smptest3 vmexit_cpuid vmexit_mov_from_cr8
      vmexit_mov_to_cr8 vmexit_inl_pmtimer  vmexit_ipi vmexit_ipi_halt
      vmexit_ple_round_robin vmexit_tscdeadline vmexit_tscdeadline_immed
-     eventinj msr port80 syscall tsc rmap_chain umip intel_iommu
+     eventinj msr port80 setjmp syscall tsc rmap_chain umip intel_iommu
      | tee results.txt
  - if grep -q FAIL results.txt ; then exit 1 ; fi
 
@@ -77,6 +77,6 @@ build-i386:
  - ./configure --arch=i386
  - make -j2
  - ACCEL=tcg ./run_tests.sh
-     eventinj port80 sieve tsc taskswitch taskswitch2 umip
+     eventinj port80 setjmp sieve tsc taskswitch taskswitch2 umip
      | tee results.txt
  - if grep -q FAIL results.txt ; then exit 1 ; fi
.travis.yml +2 -2
index 75bcf08..53f8d7d 100644
@@ -15,7 +15,7 @@ matrix:
       - BUILD_DIR="."
       - TESTS="access asyncpf debug emulator ept hypercall hyperv_stimer
                hyperv_synic idt_test intel_iommu ioapic ioapic-split
-               kvmclock_test msr pcid rdpru realmode rmap_chain s3 umip"
+               kvmclock_test msr pcid rdpru realmode rmap_chain s3 setjmp umip"
       - ACCEL="kvm"
 
     - addons:
@@ -45,7 +45,7 @@ matrix:
       - BUILD_DIR="i386-builddir"
       - TESTS="tsx-ctrl umip vmexit_cpuid vmexit_ipi vmexit_ipi_halt
                vmexit_mov_from_cr8 vmexit_mov_to_cr8 vmexit_ple_round_robin
-               vmexit_tscdeadline vmexit_tscdeadline_immed vmexit_vmcall"
+               vmexit_tscdeadline vmexit_tscdeadline_immed vmexit_vmcall setjmp"
       - ACCEL="kvm"
 
     - addons:
x86/setjmp.c +3 -5
index 1a848b4..cc411cd 100644
@@ -14,13 +14,11 @@ int main(void)
 	int i;
 
 	i = setjmp(j);
-	if (expected[index] != i) {
-		printf("FAIL: actual %d / expected %d\n", i, expected[index]);
-		return -1;
-	}
+	report(expected[index] == i, "actual %d == expected %d",
+	       i, expected[index]);
 	index++;
 	if (i + 1 < NUM_LONGJMPS)
 		longjmp(j, i + 1);
 
-	return 0;
+	return report_summary();
 }
x86/unittests.cfg +3 -0
index e99b086..acdde10 100644
@@ -171,6 +171,9 @@ file = realmode.flat
 [s3]
 file = s3.flat
 
+[setjmp]
+file = setjmp.flat
+
 [sieve]
 file = sieve.flat
 timeout = 180
Signature · 1 line
2.18.1
#4 lore raw

PATCH 4/4 x86: Add the cmpxchg8b test to the CI

In reply to Thomas Huth

Add an entry for this test to the unittests.cfg file and enable it in the CI pipelines.

---
 .gitlab-ci.yml    | 2 +-
 .travis.yml       | 2 +-
 x86/unittests.cfg | 4 ++++
 3 files changed, 6 insertions(+), 2 deletions(-)
.gitlab-ci.yml +1 -1
index ea1aeaf..67f7d80 100644
@@ -77,6 +77,6 @@ build-i386:
  - ./configure --arch=i386
  - make -j2
  - ACCEL=tcg ./run_tests.sh
-     eventinj port80 setjmp sieve tsc taskswitch taskswitch2 umip
+     cmpxchg8b eventinj port80 setjmp sieve tsc taskswitch taskswitch2 umip
      | tee results.txt
  - if grep -q FAIL results.txt ; then exit 1 ; fi
.travis.yml +1 -1
index 53f8d7d..091d071 100644
@@ -43,7 +43,7 @@ matrix:
       env:
       - CONFIG="--arch=i386"
       - BUILD_DIR="i386-builddir"
-      - TESTS="tsx-ctrl umip vmexit_cpuid vmexit_ipi vmexit_ipi_halt
+      - TESTS="cmpxchg8b tsx-ctrl umip vmexit_cpuid vmexit_ipi vmexit_ipi_halt
                vmexit_mov_from_cr8 vmexit_mov_to_cr8 vmexit_ple_round_robin
                vmexit_tscdeadline vmexit_tscdeadline_immed vmexit_vmcall setjmp"
       - ACCEL="kvm"
x86/unittests.cfg +4 -0
index acdde10..51e4ba5 100644
@@ -49,6 +49,10 @@ smp = 4
 extra_params = -cpu qemu64
 arch = x86_64
 
+[cmpxchg8b]
+file = cmpxchg8b.flat
+arch = i386
+
 [smptest]
 file = smptest.flat
 smp = 2
Signature · 1 line
2.18.1
maintainer Applied
#5 lore raw
In reply to Thomas Huth
Quoted 12 lines · Thomas Huth

QEMU recently changed the error message that it prints out when a kernel could not be loaded, so we have to adjust our script in kvm-unit-tests accordingly.
Once this is fixed, add two missing tests (setjmp and cmpxchg8b) to the unittests.cfg and CI pipelines.

Thomas Huth (4):
scripts: Fix premature_failure() check with newer versions of QEMU
x86: Fix coding style in setjmp.c
x86: Add the setjmp test to the CI
x86: Add the cmpxchg8b test to the CI

Quoted 7 lines
 .gitlab-ci.yml       |  4 ++--
 .travis.yml          |  6 +++---
 scripts/runtime.bash |  2 +-
 x86/setjmp.c         | 22 ++++++++++------------
 x86/unittests.cfg    |  7 +++++++
 5 files changed, 23 insertions(+), 18 deletions(-)

Applied, thanks.

Paolo