Blob Blame History Raw
From 86cb7449d73d5613f770713ef6df6508d9765ba8 Mon Sep 17 00:00:00 2001
Message-Id: <86cb7449d73d5613f770713ef6df6508d9765ba8@dist-git>
From: Andrea Bolognani <abologna@redhat.com>
Date: Mon, 21 Aug 2017 14:46:37 +0200
Subject: [PATCH] tests: Improve target index validation coverage

Split one of the existing tests to ensure both configuration
errors it contained cause a failure, and introduce a new
test case.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 9e318ad7130a806b2e9b7cc1e2d23e1c150bd691)

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1479647

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 ...muxml2argv-pseries-phb-invalid-target-index-1.xml} |  4 ----
 ...emuxml2argv-pseries-phb-invalid-target-index-2.xml | 18 ++++++++++++++++++
 ...emuxml2argv-pseries-phb-invalid-target-index-3.xml | 19 +++++++++++++++++++
 tests/qemuxml2argvtest.c                              |  4 +++-
 4 files changed, 40 insertions(+), 5 deletions(-)
 rename tests/qemuxml2argvdata/{qemuxml2argv-pseries-phb-wrong-target-index.xml => qemuxml2argv-pseries-phb-invalid-target-index-1.xml} (79%)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-1.xml
similarity index 79%
rename from tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml
rename to tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-1.xml
index 48e3b1f80b..4de341978e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-1.xml
@@ -12,10 +12,6 @@
     <controller type='pci' index='0' model='pci-root'>
       <target index='1'/>
     </controller>
-    <!-- Other PHBs can't have target index 0 -->
-    <controller type='pci' index='1' model='pci-root'>
-      <target index='0'/>
-    </controller>
     <controller type='usb' model='none'/>
     <memballoon model='none'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-2.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-2.xml
new file mode 100644
index 0000000000..5e4aa26359
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-2.xml
@@ -0,0 +1,18 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+  <memory unit='KiB'>524288</memory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>hvm</type>
+  </os>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <!-- PHBs other than the default one can't have target index 0 -->
+    <controller type='pci' index='1' model='pci-root'>
+      <target index='0'/>
+    </controller>
+    <controller type='usb' model='none'/>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml
new file mode 100644
index 0000000000..864c5d8758
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml
@@ -0,0 +1,19 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+  <memory unit='KiB'>524288</memory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>hvm</type>
+  </os>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <!-- QEMU only supports 32 PHBs with target index in the range 0-31,
+         so attempting to use target index 32 should fail -->
+    <controller type='pci' model='pci-root'>
+      <target index='32'/>
+    </controller>
+    <controller type='usb' model='none'/>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ee62e26309..5057d3583e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1760,13 +1760,15 @@ mymain(void)
     DO_TEST("pseries-phb-default-missing",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
-    DO_TEST_PARSE_ERROR("pseries-phb-wrong-target-index", NONE);
     DO_TEST("pseries-phb-numa-node",
             QEMU_CAPS_NUMA,
             QEMU_CAPS_OBJECT_MEMORY_RAM,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
             QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE);
     DO_TEST_PARSE_ERROR("pseries-default-phb-numa-node", NONE);
+    DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-1", NONE);
+    DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-2", NONE);
+    DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-3", NONE);
 
     DO_TEST("pseries-many-devices",
             QEMU_CAPS_NODEFCONFIG,
-- 
2.14.1