Skip to contentSkip to conversation

test: Add XSAVE unit test

PATCH Superseded Sheng Yang 3 participants 7 messages Jun 11, 2010 – Jun 14, 2010 KVM

lore
Share & tools
lore

Sheng Yang

author
#0 lore raw

PATCH v3 1/1 test: Add XSAVE unit test

Based on IDT test framework.

---
 kvm/test/config-x86-common.mak |    2 +
 kvm/test/config-x86_64.mak     |    3 +-
 kvm/test/x86/xsave.c           |  260 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 264 insertions(+), 1 deletions(-)
 create mode 100644 kvm/test/x86/xsave.c
kvm/test/config-x86-common.mak +2 -0
index 800b635..0e1ccce 100644
@@ -61,6 +61,8 @@ $(TEST_DIR)/msr.flat: $(cstart.o) $(TEST_DIR)/msr.o
 
 $(TEST_DIR)/idt_test.flat: $(cstart.o) $(TEST_DIR)/idt.o $(TEST_DIR)/idt_test.o
 
+$(TEST_DIR)/xsave.flat: $(cstart.o) $(TEST_DIR)/idt.o $(TEST_DIR)/xsave.o
+
 arch_clean:
 	$(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat \
 	$(TEST_DIR)/.*.d $(TEST_DIR)/lib/.*.d $(TEST_DIR)/lib/*.o
kvm/test/config-x86_64.mak +2 -1
index f9cd121..2da2906 100644
@@ -5,6 +5,7 @@ ldarch = elf64-x86-64
 CFLAGS += -D__x86_64__
 
 tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
-	  $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat
+	  $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat \
+	  $(TEST_DIR)/xsave.flat
 
 include config-x86-common.mak
kvm/test/x86/xsave.c new file +260 -0

260 lines not on this page · raw message

Signature · 1 line
1.7.0.1
#1 lore raw
Quoted 3 lines · Sheng Yang

Based on IDT test framework.

Nice and comprehensive.

Quoted 9 lines
kvm/test/x86/xsave.c new file +8 -0
+
+int main(void)
+{
+    setup_idt();
+    if (check_cpuid_1_ecx(CPUID_1_ECX_XSAVE)) {
+        printf("CPU has XSAVE feature\n");
+        test_xsave();
+    } else {

kvm/test/x86/xsave.c line 260

Quoted 10 lines
kvm/test/x86/xsave.c new file +10 -0
+        printf("CPU don't has XSAVE feature\n");
+        test_no_xsave();
+    }
+    printf("Total test: %d\n", total_tests);
+    if (fail_tests == 0)
+        printf("ALL PASS!\n");
+    else
+        printf("Fail %d tests.\n", fail_tests);
+    return 1;
+}

Need to return 0 if !fail_tests, so we can hook this up to autotest.

Signature · 1 line
error compiling committee.c: too many arguments to function
author
#2 lore raw

PATCH v4 1/1 test: Add XSAVE unit test

Based on IDT test framework.

---
 kvm/test/config-x86-common.mak |    2 +
 kvm/test/config-x86_64.mak     |    3 +-
 kvm/test/x86/xsave.c           |  262 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 266 insertions(+), 1 deletions(-)
 create mode 100644 kvm/test/x86/xsave.c
kvm/test/config-x86-common.mak +2 -0
index 800b635..0e1ccce 100644
@@ -61,6 +61,8 @@ $(TEST_DIR)/msr.flat: $(cstart.o) $(TEST_DIR)/msr.o
 
 $(TEST_DIR)/idt_test.flat: $(cstart.o) $(TEST_DIR)/idt.o $(TEST_DIR)/idt_test.o
 
+$(TEST_DIR)/xsave.flat: $(cstart.o) $(TEST_DIR)/idt.o $(TEST_DIR)/xsave.o
+
 arch_clean:
 	$(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat \
 	$(TEST_DIR)/.*.d $(TEST_DIR)/lib/.*.d $(TEST_DIR)/lib/*.o
kvm/test/config-x86_64.mak +2 -1
index f9cd121..2da2906 100644
@@ -5,6 +5,7 @@ ldarch = elf64-x86-64
 CFLAGS += -D__x86_64__
 
 tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
-	  $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat
+	  $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat \
+	  $(TEST_DIR)/xsave.flat
 
 include config-x86-common.mak
kvm/test/x86/xsave.c new file +262 -0

262 lines not on this page · raw message

Signature · 1 line
1.7.0.1
#3 lore raw
Quoted 12 lines · Sheng Yang

Based on IDT test framework.

kvm/test/x86/xsave.c new file +10 -0
+
+int main(void)
+{
+    setup_idt();
+    if (check_cpuid_1_ecx(CPUID_1_ECX_XSAVE)) {
+        printf("CPU has XSAVE feature\n");
+        test_xsave();
+    } else {
+        printf("CPU don't has XSAVE feature\n");
+        test_no_xsave();

kvm/test/x86/xsave.c line 262

Quoted 10 lines
kvm/test/x86/xsave.c new file +10 -0
+    }
+    printf("Total test: %d\n", total_tests);
+    if (fail_tests == 0)
+        printf("ALL PASS!\n");
+    else {
+        printf("Fail %d tests.\n", fail_tests);
+        return 0;
+    }
+    return 1;
+}

Wrong way, 0 = success, !0 = fail (just like shell exit codes).

Signature · 1 line
error compiling committee.c: too many arguments to function
author
#4 lore raw
Quoted 16 lines · On Sunday 13 June 2010 16:43:42 Avi Kivity wrote:
Quoted 15 lines · Sheng Yang

Based on IDT test framework.

kvm/test/x86/xsave.c new file +14 -0
+
+int main(void)
+{
+    setup_idt();
+    if (check_cpuid_1_ecx(CPUID_1_ECX_XSAVE)) {
+        printf("CPU has XSAVE feature\n");
+        test_xsave();
+    } else {
+        printf("CPU don't has XSAVE feature\n");
+        test_no_xsave();
+    }
+    printf("Total test: %d\n", total_tests);
+    if (fail_tests == 0)
+        printf("ALL PASS!\n");
Quoted 8 lines

kvm/test/x86/xsave.c line 262

Quoted 6 lines
kvm/test/x86/xsave.c new file +6 -0
+    else {
+        printf("Fail %d tests.\n", fail_tests);
+        return 0;
+    }
+    return 1;
+}

Wrong way, 0 = success, !0 = fail (just like shell exit codes).

Indeed oops. Finally checked your first comment to this test case patch, and found I completely misread it...

--
regards
Yang, Sheng

author
#5 lore raw

PATCH v4 1/1 test: Add XSAVE unit test

In reply to Avi Kivity

Based on IDT test framework.

---
 kvm/test/config-x86-common.mak |    2 +
 kvm/test/config-x86_64.mak     |    3 +-
 kvm/test/x86/xsave.c           |  262 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 266 insertions(+), 1 deletions(-)
 create mode 100644 kvm/test/x86/xsave.c
kvm/test/config-x86-common.mak +2 -0
index 800b635..0e1ccce 100644
@@ -61,6 +61,8 @@ $(TEST_DIR)/msr.flat: $(cstart.o) $(TEST_DIR)/msr.o
 
 $(TEST_DIR)/idt_test.flat: $(cstart.o) $(TEST_DIR)/idt.o $(TEST_DIR)/idt_test.o
 
+$(TEST_DIR)/xsave.flat: $(cstart.o) $(TEST_DIR)/idt.o $(TEST_DIR)/xsave.o
+
 arch_clean:
 	$(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat \
 	$(TEST_DIR)/.*.d $(TEST_DIR)/lib/.*.d $(TEST_DIR)/lib/*.o
kvm/test/config-x86_64.mak +2 -1
index f9cd121..2da2906 100644
@@ -5,6 +5,7 @@ ldarch = elf64-x86-64
 CFLAGS += -D__x86_64__
 
 tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
-	  $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat
+	  $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat \
+	  $(TEST_DIR)/xsave.flat
 
 include config-x86-common.mak
kvm/test/x86/xsave.c new file +262 -0

262 lines not on this page · raw message

Signature · 1 line
1.7.0.1