Blob Blame History Raw
From c32b1c0b3fe1f2b2e365f6e336c2720f6b15ff81 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 27 Aug 2016 07:32:49 +0100
Subject: [PATCH] tests: Add a regression test for RHBZ#1370424.

Regression test for previous commit which just tests that
guestfs_add_domain doesn't assert-fail on guests with no port
attribute.

(cherry picked from commit 98aa78f288e44868bcccf56b777d57d9fd4ec6a6)
---
 tests/regressions/Makefile.am     |  2 ++
 tests/regressions/rhbz1370424.sh  | 42 +++++++++++++++++++++++++++++++++++++++
 tests/regressions/rhbz1370424.xml | 28 ++++++++++++++++++++++++++
 3 files changed, 72 insertions(+)
 create mode 100755 tests/regressions/rhbz1370424.sh
 create mode 100644 tests/regressions/rhbz1370424.xml

diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am
index 77a5ff5..407c5b0 100644
--- a/tests/regressions/Makefile.am
+++ b/tests/regressions/Makefile.am
@@ -48,6 +48,7 @@ EXTRA_DIST = \
 	rhbz1232192.sh \
 	rhbz1232192.xml \
 	rhbz1285847.sh \
+	rhbz1370424.sh \
 	test-noexec-stack.pl
 
 TESTS = \
@@ -77,6 +78,7 @@ TESTS = \
 	rhbz1175196.sh \
 	rhbz1232192.sh \
 	rhbz1285847.sh \
+	rhbz1370424.sh \
 	test-big-heap \
 	test-noexec-stack.pl \
 	$(SLOW_TESTS)
diff --git a/tests/regressions/rhbz1370424.sh b/tests/regressions/rhbz1370424.sh
new file mode 100755
index 0000000..5b21a32
--- /dev/null
+++ b/tests/regressions/rhbz1370424.sh
@@ -0,0 +1,42 @@
+#!/bin/bash -
+# libguestfs
+# Copyright (C) 2016 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Regression test for:
+# https://bugzilla.redhat.com/show_bug.cgi?id=1370424
+# Handle a network disk without a port attribute.
+
+set -e
+export LANG=C
+
+if [ -n "$SKIP_TEST_RHBZ1370424_SH" ]; then
+    echo "$0: test skipped because environment variable is set"
+    exit 77
+fi
+
+if [ "$(guestfish get-backend)" = "uml" ]; then
+    echo "$0: test skipped because UML backend does not support network"
+    exit 77
+fi
+
+guestfish <<EOF
+-add-domain rhbz1370424 \
+            libvirturi:test://$(pwd)/rhbz1370424.xml \
+            readonly:true
+# The test is just that the above command does not segfault.
+# We don't need to do anything else here.
+EOF
diff --git a/tests/regressions/rhbz1370424.xml b/tests/regressions/rhbz1370424.xml
new file mode 100644
index 0000000..059ea21
--- /dev/null
+++ b/tests/regressions/rhbz1370424.xml
@@ -0,0 +1,28 @@
+<node>
+  <domain type='test'>
+    <name>rhbz1370424</name>
+    <memory>1048576</memory>
+    <vcpu>2</vcpu>
+    <os>
+      <type>hvm</type>
+      <boot dev='hd'/>
+    </os>
+    <features>
+      <acpi/>
+      <apic/>
+      <pae/>
+    </features>
+    <devices>
+      <disk type='network' device='disk'>
+        <driver name='qemu' type='raw'/>
+        <source protocol='gluster' name='gluster-vol/test.qcow2'>
+          <host name='localhost'/>
+        </source>
+        <backingStore/>
+        <target dev='vda' bus='virtio'/>
+        <alias name='virtio-disk0'/>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+      </disk>
+    </devices>
+  </domain>
+</node>
-- 
1.8.3.1