From 8c57ff0e9b940eb1e29a4aa3e8a9d04b03424989 Mon Sep 17 00:00:00 2001
From: Xu Yandong <xuyandong2@huawei.com>
Date: Mon, 16 Oct 2017 17:55:48 +0800
Subject: tests: add cpu compare test cases for arm CPU

add cpu compare test cases for arm CPU

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
---
 tests/cputest.c                                      | 10 ++++++++++
 .../aarch64-guest-compat-incompatible.xml            |  4 ++++
 tests/cputestdata/aarch64-guest-compat-none.xml      |  1 +
 tests/cputestdata/aarch64-guest-compat-valid.xml     |  3 +++
 tests/cputestdata/aarch64-guest-exact.xml            |  4 ++++
 tests/cputestdata/aarch64-guest-features-invalid.xml | 12 ++++++++++++
 tests/cputestdata/aarch64-guest-features-valid.xml   |  7 +++++++
 .../aarch64-guest-legacy-incompatible.xml            |  4 ++++
 tests/cputestdata/aarch64-guest-legacy.xml           |  4 ++++
 tests/cputestdata/aarch64-guest-strict.xml           |  4 ++++
 tests/cputestdata/aarch64-host.xml                   | 12 ++++++++++++
 11 files changed, 65 insertions(+)
 create mode 100644 tests/cputestdata/aarch64-guest-compat-incompatible.xml
 create mode 100644 tests/cputestdata/aarch64-guest-compat-none.xml
 create mode 100644 tests/cputestdata/aarch64-guest-compat-valid.xml
 create mode 100644 tests/cputestdata/aarch64-guest-exact.xml
 create mode 100644 tests/cputestdata/aarch64-guest-features-invalid.xml
 create mode 100644 tests/cputestdata/aarch64-guest-features-valid.xml
 create mode 100644 tests/cputestdata/aarch64-guest-legacy-incompatible.xml
 create mode 100644 tests/cputestdata/aarch64-guest-legacy.xml
 create mode 100644 tests/cputestdata/aarch64-guest-strict.xml
 create mode 100644 tests/cputestdata/aarch64-host.xml

diff --git a/tests/cputest.c b/tests/cputest.c
index 1f59f0d..e4b4531 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -1140,6 +1140,16 @@ mymain(void)
     DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-compat-invalid", VIR_CPU_COMPARE_ERROR);
     DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-compat-incompatible", VIR_CPU_COMPARE_INCOMPATIBLE);
 
+    DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-strict", VIR_CPU_COMPARE_IDENTICAL);
+    DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-exact", VIR_CPU_COMPARE_INCOMPATIBLE);
+    DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-legacy", VIR_CPU_COMPARE_IDENTICAL);
+    DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-legacy-incompatible", VIR_CPU_COMPARE_INCOMPATIBLE);
+    DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-compat-none", VIR_CPU_COMPARE_IDENTICAL);
+    DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-compat-valid", VIR_CPU_COMPARE_IDENTICAL);
+    DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-compat-incompatible", VIR_CPU_COMPARE_INCOMPATIBLE);
+    DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-features-valid", VIR_CPU_COMPARE_IDENTICAL);
+    DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-features-invalid", VIR_CPU_COMPARE_INCOMPATIBLE);
+
     /* guest updates for migration
      * automatically compares host CPU with the result */
     DO_TEST_UPDATE(VIR_ARCH_X86_64, "host", "min", VIR_CPU_COMPARE_IDENTICAL);
diff --git a/tests/cputestdata/aarch64-guest-compat-incompatible.xml b/tests/cputestdata/aarch64-guest-compat-incompatible.xml
new file mode 100644
index 0000000..f68ead5
--- /dev/null
+++ b/tests/cputestdata/aarch64-guest-compat-incompatible.xml
@@ -0,0 +1,4 @@
+<cpu mode='custom'>
+  <model>cortex-a72</model>
+  <vendor>ARM</vendor>
+</cpu>
diff --git a/tests/cputestdata/aarch64-guest-compat-none.xml b/tests/cputestdata/aarch64-guest-compat-none.xml
new file mode 100644
index 0000000..fd50c03
--- /dev/null
+++ b/tests/cputestdata/aarch64-guest-compat-none.xml
@@ -0,0 +1 @@
+<cpu mode='host-model'/>
diff --git a/tests/cputestdata/aarch64-guest-compat-valid.xml b/tests/cputestdata/aarch64-guest-compat-valid.xml
new file mode 100644
index 0000000..0206d6e
--- /dev/null
+++ b/tests/cputestdata/aarch64-guest-compat-valid.xml
@@ -0,0 +1,3 @@
+<cpu mode='host-model'>
+  <model>cortex-a57</model>
+</cpu>
diff --git a/tests/cputestdata/aarch64-guest-exact.xml b/tests/cputestdata/aarch64-guest-exact.xml
new file mode 100644
index 0000000..bbbe65f
--- /dev/null
+++ b/tests/cputestdata/aarch64-guest-exact.xml
@@ -0,0 +1,4 @@
+<cpu match='exact'>
+  <model>cortex-a72</model>
+  <vendor>ARM</vendor>
+</cpu>
diff --git a/tests/cputestdata/aarch64-guest-features-invalid.xml b/tests/cputestdata/aarch64-guest-features-invalid.xml
new file mode 100644
index 0000000..afbb402
--- /dev/null
+++ b/tests/cputestdata/aarch64-guest-features-invalid.xml
@@ -0,0 +1,12 @@
+<cpu>
+  <model>cortex-a57</model>
+  <vendor>ARM</vendor>
+  <feature name='fp'/>
+  <feature name='asimd'/>
+  <feature name='aes'/>
+  <feature name='pmull'/>
+  <feature name='sha1'/>
+  <feature name='sha2'/>
+  <feature name='crc32'/>
+  <feature name='sha3'/>
+</cpu>
diff --git a/tests/cputestdata/aarch64-guest-features-valid.xml b/tests/cputestdata/aarch64-guest-features-valid.xml
new file mode 100644
index 0000000..0858f76
--- /dev/null
+++ b/tests/cputestdata/aarch64-guest-features-valid.xml
@@ -0,0 +1,7 @@
+<cpu>
+  <model>cortex-a57</model>
+  <vendor>ARM</vendor>
+  <feature name='asimd'/>
+  <feature name='aes'/>
+  <feature name='crc32'/>
+</cpu>
diff --git a/tests/cputestdata/aarch64-guest-legacy-incompatible.xml b/tests/cputestdata/aarch64-guest-legacy-incompatible.xml
new file mode 100644
index 0000000..2f1941d
--- /dev/null
+++ b/tests/cputestdata/aarch64-guest-legacy-incompatible.xml
@@ -0,0 +1,4 @@
+<cpu mode='custom' match='exact'>
+  <model fallback='allow'>cortex-a72</model>
+  <vendor>ARM</vendor>
+</cpu>
diff --git a/tests/cputestdata/aarch64-guest-legacy.xml b/tests/cputestdata/aarch64-guest-legacy.xml
new file mode 100644
index 0000000..64a05e4
--- /dev/null
+++ b/tests/cputestdata/aarch64-guest-legacy.xml
@@ -0,0 +1,4 @@
+<cpu mode='custom' match='exact'>
+  <model fallback='allow'>cortex-a57</model>
+  <vendor>ARM</vendor>
+</cpu>
diff --git a/tests/cputestdata/aarch64-guest-strict.xml b/tests/cputestdata/aarch64-guest-strict.xml
new file mode 100644
index 0000000..a057ebd
--- /dev/null
+++ b/tests/cputestdata/aarch64-guest-strict.xml
@@ -0,0 +1,4 @@
+<cpu match='strict'>
+  <model>cortex-a57</model>
+  <vendor>ARM</vendor>
+</cpu>
diff --git a/tests/cputestdata/aarch64-host.xml b/tests/cputestdata/aarch64-host.xml
new file mode 100644
index 0000000..60c20f2
--- /dev/null
+++ b/tests/cputestdata/aarch64-host.xml
@@ -0,0 +1,12 @@
+<cpu>
+  <arch>aarch64</arch>
+  <model>cortex-a57</model>
+  <vendor>ARM</vendor>
+  <feature name='fp'/>
+  <feature name='asimd'/>
+  <feature name='aes'/>
+  <feature name='pmull'/>
+  <feature name='sha1'/>
+  <feature name='sha2'/>
+  <feature name='crc32'/>
+</cpu>
-- 
2.23.0

