6d3351
From 86cb7449d73d5613f770713ef6df6508d9765ba8 Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <86cb7449d73d5613f770713ef6df6508d9765ba8@dist-git>
6d3351
From: Andrea Bolognani <abologna@redhat.com>
6d3351
Date: Mon, 21 Aug 2017 14:46:37 +0200
6d3351
Subject: [PATCH] tests: Improve target index validation coverage
6d3351
6d3351
Split one of the existing tests to ensure both configuration
6d3351
errors it contained cause a failure, and introduce a new
6d3351
test case.
6d3351
6d3351
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6d3351
(cherry picked from commit 9e318ad7130a806b2e9b7cc1e2d23e1c150bd691)
6d3351
6d3351
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1479647
6d3351
6d3351
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 ...muxml2argv-pseries-phb-invalid-target-index-1.xml} |  4 ----
6d3351
 ...emuxml2argv-pseries-phb-invalid-target-index-2.xml | 18 ++++++++++++++++++
6d3351
 ...emuxml2argv-pseries-phb-invalid-target-index-3.xml | 19 +++++++++++++++++++
6d3351
 tests/qemuxml2argvtest.c                              |  4 +++-
6d3351
 4 files changed, 40 insertions(+), 5 deletions(-)
6d3351
 rename tests/qemuxml2argvdata/{qemuxml2argv-pseries-phb-wrong-target-index.xml => qemuxml2argv-pseries-phb-invalid-target-index-1.xml} (79%)
6d3351
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-2.xml
6d3351
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml
6d3351
6d3351
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-1.xml
6d3351
similarity index 79%
6d3351
rename from tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml
6d3351
rename to tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-1.xml
6d3351
index 48e3b1f80b..4de341978e 100644
6d3351
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml
6d3351
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-1.xml
6d3351
@@ -12,10 +12,6 @@
6d3351
     <controller type='pci' index='0' model='pci-root'>
6d3351
       <target index='1'/>
6d3351
     </controller>
6d3351
-    
6d3351
-    <controller type='pci' index='1' model='pci-root'>
6d3351
-      <target index='0'/>
6d3351
-    </controller>
6d3351
     <controller type='usb' model='none'/>
6d3351
     <memballoon model='none'/>
6d3351
   </devices>
6d3351
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-2.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-2.xml
6d3351
new file mode 100644
6d3351
index 0000000000..5e4aa26359
6d3351
--- /dev/null
6d3351
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-2.xml
6d3351
@@ -0,0 +1,18 @@
6d3351
+<domain type='qemu'>
6d3351
+  <name>QEMUGuest1</name>
6d3351
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
6d3351
+  <memory unit='KiB'>524288</memory>
6d3351
+  <vcpu placement='static'>1</vcpu>
6d3351
+  <os>
6d3351
+    <type arch='ppc64' machine='pseries'>hvm</type>
6d3351
+  </os>
6d3351
+  <devices>
6d3351
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
6d3351
+    
6d3351
+    <controller type='pci' index='1' model='pci-root'>
6d3351
+      <target index='0'/>
6d3351
+    </controller>
6d3351
+    <controller type='usb' model='none'/>
6d3351
+    <memballoon model='none'/>
6d3351
+  </devices>
6d3351
+</domain>
6d3351
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml
6d3351
new file mode 100644
6d3351
index 0000000000..864c5d8758
6d3351
--- /dev/null
6d3351
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml
6d3351
@@ -0,0 +1,19 @@
6d3351
+<domain type='qemu'>
6d3351
+  <name>QEMUGuest1</name>
6d3351
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
6d3351
+  <memory unit='KiB'>524288</memory>
6d3351
+  <vcpu placement='static'>1</vcpu>
6d3351
+  <os>
6d3351
+    <type arch='ppc64' machine='pseries'>hvm</type>
6d3351
+  </os>
6d3351
+  <devices>
6d3351
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
6d3351
+    
6d3351
+         so attempting to use target index 32 should fail -->
6d3351
+    <controller type='pci' model='pci-root'>
6d3351
+      <target index='32'/>
6d3351
+    </controller>
6d3351
+    <controller type='usb' model='none'/>
6d3351
+    <memballoon model='none'/>
6d3351
+  </devices>
6d3351
+</domain>
6d3351
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
6d3351
index ee62e26309..5057d3583e 100644
6d3351
--- a/tests/qemuxml2argvtest.c
6d3351
+++ b/tests/qemuxml2argvtest.c
6d3351
@@ -1760,13 +1760,15 @@ mymain(void)
6d3351
     DO_TEST("pseries-phb-default-missing",
6d3351
             QEMU_CAPS_NODEFCONFIG,
6d3351
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
6d3351
-    DO_TEST_PARSE_ERROR("pseries-phb-wrong-target-index", NONE);
6d3351
     DO_TEST("pseries-phb-numa-node",
6d3351
             QEMU_CAPS_NUMA,
6d3351
             QEMU_CAPS_OBJECT_MEMORY_RAM,
6d3351
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
6d3351
             QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE);
6d3351
     DO_TEST_PARSE_ERROR("pseries-default-phb-numa-node", NONE);
6d3351
+    DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-1", NONE);
6d3351
+    DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-2", NONE);
6d3351
+    DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-3", NONE);
6d3351
 
6d3351
     DO_TEST("pseries-many-devices",
6d3351
             QEMU_CAPS_NODEFCONFIG,
6d3351
-- 
6d3351
2.14.1
6d3351