From e7d36f0981e86a7b608e228a3f766e73f0b95e10 Mon Sep 17 00:00:00 2001
Message-Id: <e7d36f0981e86a7b608e228a3f766e73f0b95e10@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 26 Feb 2014 14:55:08 +0100
Subject: [PATCH] domainsnapshotxml2xmltest: Add test case for empty driver
element
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
Commit 5a66c667ff5cae61c2ad2e646c8eb3eedc67f925 fixed a NULL dereference
if the disk driver element was empty. Add a test for this case.
(cherry picked from commit 2cb2abc04d08c90e826b8341cca91e7c886f6188)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
tests/domainsnapshotxml2xmlin/disk_driver_name_null.xml | 10 ++++++++++
tests/domainsnapshotxml2xmlout/disk_driver_name_null.xml | 9 +++++++++
tests/domainsnapshotxml2xmltest.c | 1 +
3 files changed, 20 insertions(+)
create mode 100644 tests/domainsnapshotxml2xmlin/disk_driver_name_null.xml
create mode 100644 tests/domainsnapshotxml2xmlout/disk_driver_name_null.xml
diff --git a/tests/domainsnapshotxml2xmlin/disk_driver_name_null.xml b/tests/domainsnapshotxml2xmlin/disk_driver_name_null.xml
new file mode 100644
index 0000000..78eee9c
--- /dev/null
+++ b/tests/domainsnapshotxml2xmlin/disk_driver_name_null.xml
@@ -0,0 +1,10 @@
+<domainsnapshot>
+ <name>asdf</name>
+ <description>adsf</description>
+ <disks>
+ <disk name='vda' snapshot='external'>
+ <source file='/tmp/foo'/>
+ <driver/>
+ </disk>
+ </disks>
+</domainsnapshot>
diff --git a/tests/domainsnapshotxml2xmlout/disk_driver_name_null.xml b/tests/domainsnapshotxml2xmlout/disk_driver_name_null.xml
new file mode 100644
index 0000000..41961f1
--- /dev/null
+++ b/tests/domainsnapshotxml2xmlout/disk_driver_name_null.xml
@@ -0,0 +1,9 @@
+<domainsnapshot>
+ <name>asdf</name>
+ <description>adsf</description>
+ <disks>
+ <disk name='vda' snapshot='external'>
+ <source file='/tmp/foo'/>
+ </disk>
+ </disks>
+</domainsnapshot>
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index 7870601..4bf0c7c 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -220,6 +220,7 @@ mymain(void)
DO_TEST_INOUT("external_vm", NULL, false, false);
DO_TEST_INOUT("noparent", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8", false, false);
DO_TEST_INOUT("disk_snapshot", NULL, false, false);
+ DO_TEST_INOUT("disk_driver_name_null", NULL, false, false);
DO_TEST_IN("name_and_description", NULL);
DO_TEST_IN("description_only", NULL);
--
1.9.0