Followup of commit f190e08d85556dac293ef15bfeee38e54471570f.
---
v2v/Makefile.am | 2 ++
v2v/test-v2v-o-json.sh | 58 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+)
create mode 100755 v2v/test-v2v-o-json.sh
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 39511022e..1c37d20b4 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -468,6 +468,7 @@ TESTS += \
test-v2v-networks-and-bridges.sh \
test-v2v-no-copy.sh \
test-v2v-o-glance.sh \
+ test-v2v-o-json.sh \
test-v2v-o-libvirt.sh \
test-v2v-o-null.sh \
test-v2v-o-openstack.sh \
@@ -628,6 +629,7 @@ EXTRA_DIST += \
test-v2v-networks-and-bridges.xml \
test-v2v-no-copy.sh \
test-v2v-o-glance.sh \
+ test-v2v-o-json.sh \
test-v2v-o-libvirt.sh \
test-v2v-o-null.sh \
test-v2v-o-openstack.sh \
diff --git a/v2v/test-v2v-o-json.sh b/v2v/test-v2v-o-json.sh
new file mode 100755
index 000000000..71458a1bb
--- /dev/null
+++ b/v2v/test-v2v-o-json.sh
@@ -0,0 +1,58 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2019 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.
+
+# Test -o json.
+
+set -e
+
+$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
+skip_unless_phony_guest windows.img
+skip_unless jq --version
+
+libvirt_uri="test://$abs_top_builddir/test-data/phony-guests/guests.xml"
+
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+
+guestname=windows
+
+d=test-v2v-o-json.d
+rm -rf $d
+mkdir $d
+
+json=$d/$guestname.json
+
+$VG virt-v2v --debug-gc \
+ -i libvirt -ic "$libvirt_uri" windows \
+ -o json -os $d -on $guestname
+
+# Test the disk was created.
+test -f $d/$guestname-sda
+
+# Test the JSON.
+test x$(jq -r '.name' $json) = xwindows
+test x$(jq -r '.inspect.type' $json) = xwindows
+test x$(jq -r '.inspect.distro' $json) = xwindows
+test x$(jq -r '.inspect.osinfo' $json) = xwin7
+test $(jq -r '.disks | length' $json) -eq 1
+test $(jq -r '.nics | length' $json) -eq 1
+test $(jq -r '.removables | length' $json) -eq 0
+
+# Clean up.
+rm -r $d
--
2.21.0