diff --git a/tests/meson.build b/tests/meson.build index f88410ff33..3ef4d06177 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -654,6 +654,7 @@ if conf.has('WITH_LIBVIRTD') 'virsh-define-dev-segfault', 'virsh-int-overflow', 'virsh-optparse', + 'virsh-output', 'virsh-read-bufsiz', 'virsh-read-non-seekable', 'virsh-schedinfo', diff --git a/tests/virsh-output b/tests/virsh-output new file mode 100755 index 0000000000..44833c7048 --- /dev/null +++ b/tests/virsh-output @@ -0,0 +1,27 @@ +#!/bin/sh + +. "$(dirname $0)/test-lib.sh" + +if [ ! -x /bin/bash ]; then + echo skipping test - no bash + exit 77 +fi + +mock_xdg_ || framework_failure + +export LIBVIRT_DEFAULT_URI='test:///default' +ln -s $abs_top_builddir/tools/virsh virsh + +$abs_top_srcdir/tests/virsh-output-commands > out 2>&1 + +echo end >> out + +if compare $abs_top_srcdir/tests/virsh-output.out out; then + exit 0 +else + if [ "x$VIR_TEST_REGENERATE_OUTPUT" = "x1" ]; then + cp out $abs_top_srcdir/tests/virsh-output.out + fi + + exit 1 +fi diff --git a/tests/virsh-output-commands b/tests/virsh-output-commands new file mode 100755 index 0000000000..43f87bee0f --- /dev/null +++ b/tests/virsh-output-commands @@ -0,0 +1,80 @@ +#!/bin/bash + +attach_disk() +{ + ./virsh attach-disk --print-xml --domain testdom $@ --source /nonexistent/file +} + +set -x + +./virsh attach-disk +./virsh attach-disk --print-xml --domain testdom $@ --source "" +./virsh attach-disk --print-xml --domain testdom $@ --source "" --sourcetype file +./virsh attach-disk --print-xml --domain testdom $@ --source "" --sourcetype blah +attach_disk --target hda +attach_disk --target hda --sourcetype file +attach_disk --target hda --sourcetype block +attach_disk --target hda --sourcetype nothing +attach_disk --target hda --sourcetype file --type disk +attach_disk --target hda --sourcetype block --type disk +attach_disk --target hda --sourcetype file --type cdrom +attach_disk --target hda --sourcetype block --type cdrom +attach_disk --target hda --sourcetype file --type blah +attach_disk --target hda --sourcetype block --type blah +attach_disk --target hda --sourcetype file --type disk --driver testdriver +attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 +attach_disk --target hda --sourcetype file --type disk --subdriver raw +attach_disk --target hda --sourcetype file --type disk --cache none +attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --cache none +attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --serial TEST_SERIAL +attach_disk --target hda --sourcetype file --type disk --mode readonly +attach_disk --target hda --sourcetype file --type disk --mode shareable +attach_disk --target hda --sourcetype file --type disk --mode whatever +attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias +attach_disk --target hda --sourcetype file --type disk --rawio +attach_disk --target hda --sourcetype file --type disk --multifunction +attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias --iothread 3 --mode readonly --cache none --driver qemu + +attach_disk --target hda --sourcetype file --type disk --address ide:1.2.3 +attach_disk --target hda --sourcetype file --type disk --address ide:1.2.4 +attach_disk --target hda --sourcetype file --type disk --address ide:1:2:5 +attach_disk --target sda --sourcetype file --type disk --address ide:1.2.3 +attach_disk --target vda --sourcetype file --type disk --address ide:1.2.3 + +attach_disk --target sda --sourcetype file --type disk --address usb:12.34 +attach_disk --target sda --sourcetype file --type disk --address usb:12.3 +attach_disk --target sda --sourcetype file --type disk --address usb:12:34 +attach_disk --target vda --sourcetype file --type disk --address usb:12.34 +attach_disk --target hda --sourcetype file --type disk --address usb:12.34 + +attach_disk --target sda --sourcetype file --type disk --address scsi:1.2.3 +attach_disk --target sda --sourcetype file --type disk --address scsi:1.2.4 +attach_disk --target sda --sourcetype file --type disk --address scsi:1:2:5 +attach_disk --target hda --sourcetype file --type disk --address scsi:1.2.3 +attach_disk --target vda --sourcetype file --type disk --address scsi:1.2.3 + +attach_disk --target sda --sourcetype file --type disk --address sata:1.2.3 +attach_disk --target sda --sourcetype file --type disk --address sata:1.2.4 +attach_disk --target sda --sourcetype file --type disk --address sata:1:2:5 +attach_disk --target hda --sourcetype file --type disk --address sata:1.2.3 +attach_disk --target vda --sourcetype file --type disk --address sata:1.2.3 + +attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.78 +attach_disk --target vda --sourcetype file --type disk --address pci:12:34:56:78 +attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.aa +attach_disk --target hda --sourcetype file --type disk --address pci:12.34.56.aa +attach_disk --target sda --sourcetype file --type disk --address pci:12.34.56.aa + +attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.78 --multifunction +attach_disk --target vda --sourcetype file --type disk --address pci:12:34:56:78 --multifunction +attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.aa --multifunction + +attach_disk --target vda --sourcetype file --type disk --address ccw:12.34.56 +attach_disk --target vda --sourcetype file --type disk --address ccw:12:34:56 +attach_disk --target vda --sourcetype file --type disk --address ccw:12.34.56 +attach_disk --target hda --sourcetype file --type disk --address ccw:12.34.56 +attach_disk --target sda --sourcetype file --type disk --address ccw:12.34.56 + +attach_disk --target vda --sourcetype file --type disk --address test:12.34.56 +attach_disk --target vda --sourcetype file --type disk --address test:12:34:56 +attach_disk --target vda --sourcetype file --type disk --address test:12.34.56 diff --git a/tests/virsh-output.out b/tests/virsh-output.out new file mode 100644 index 0000000000..8fbe02a232 --- /dev/null +++ b/tests/virsh-output.out @@ -0,0 +1,408 @@ ++ ./virsh attach-disk +error: command 'attach-disk' requires option +error: command 'attach-disk' requires option +error: command 'attach-disk' requires option ++ ./virsh attach-disk --print-xml --domain testdom --source '' +error: command 'attach-disk' requires option ++ ./virsh attach-disk --print-xml --domain testdom --source '' --sourcetype file +error: command 'attach-disk' requires option ++ ./virsh attach-disk --print-xml --domain testdom --source '' --sourcetype blah +error: command 'attach-disk' requires option ++ attach_disk --target hda ++ ./virsh attach-disk --print-xml --domain testdom --target hda --source /nonexistent/file + + + + + ++ attach_disk --target hda --sourcetype file ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --source /nonexistent/file + + + + + ++ attach_disk --target hda --sourcetype block ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype block --source /nonexistent/file + + + + + ++ attach_disk --target hda --sourcetype nothing ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype nothing --source /nonexistent/file +error: Unknown source type: 'nothing' + ++ attach_disk --target hda --sourcetype file --type disk ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --source /nonexistent/file + + + + + ++ attach_disk --target hda --sourcetype block --type disk ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype block --type disk --source /nonexistent/file + + + + + ++ attach_disk --target hda --sourcetype file --type cdrom ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type cdrom --source /nonexistent/file + + + + + ++ attach_disk --target hda --sourcetype block --type cdrom ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype block --type cdrom --source /nonexistent/file + + + + + ++ attach_disk --target hda --sourcetype file --type blah ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type blah --source /nonexistent/file + + + + + ++ attach_disk --target hda --sourcetype block --type blah ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype block --type blah --source /nonexistent/file + + + + + ++ attach_disk --target hda --sourcetype file --type disk --driver testdriver ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --driver testdriver --source /nonexistent/file + + + + + + ++ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver qcow2 --source /nonexistent/file + + + + + + ++ attach_disk --target hda --sourcetype file --type disk --subdriver raw ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver raw --source /nonexistent/file + + + + + + ++ attach_disk --target hda --sourcetype file --type disk --cache none ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --cache none --source /nonexistent/file + + + + + + ++ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --cache none ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver qcow2 --cache none --source /nonexistent/file + + + + + + ++ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --serial TEST_SERIAL ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver qcow2 --serial TEST_SERIAL --source /nonexistent/file + + + + + TEST_SERIAL + + ++ attach_disk --target hda --sourcetype file --type disk --mode readonly ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --mode readonly --source /nonexistent/file + + + + + + ++ attach_disk --target hda --sourcetype file --type disk --mode shareable ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --mode shareable --source /nonexistent/file + + + + + + ++ attach_disk --target hda --sourcetype file --type disk --mode whatever ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --mode whatever --source /nonexistent/file +error: No support for whatever in command 'attach-disk' + ++ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias --source /nonexistent/file + + + + + + + ++ attach_disk --target hda --sourcetype file --type disk --rawio ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --rawio --source /nonexistent/file + + + + + ++ attach_disk --target hda --sourcetype file --type disk --multifunction ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --multifunction --source /nonexistent/file + + + + + ++ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias --iothread 3 --mode readonly --cache none --driver qemu ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias --iothread 3 --mode readonly --cache none --driver qemu --source /nonexistent/file + + + + + + + + ++ attach_disk --target hda --sourcetype file --type disk --address ide:1.2.3 ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address ide:1.2.3 --source /nonexistent/file + + + +
+ + ++ attach_disk --target hda --sourcetype file --type disk --address ide:1.2.4 ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address ide:1.2.4 --source /nonexistent/file + + + +
+ + ++ attach_disk --target hda --sourcetype file --type disk --address ide:1:2:5 ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address ide:1:2:5 --source /nonexistent/file + + + +
+ + ++ attach_disk --target sda --sourcetype file --type disk --address ide:1.2.3 ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address ide:1.2.3 --source /nonexistent/file +error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address. + ++ attach_disk --target vda --sourcetype file --type disk --address ide:1.2.3 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address ide:1.2.3 --source /nonexistent/file +error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. + ++ attach_disk --target sda --sourcetype file --type disk --address usb:12.34 ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address usb:12.34 --source /nonexistent/file + + + +
+ + ++ attach_disk --target sda --sourcetype file --type disk --address usb:12.3 ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address usb:12.3 --source /nonexistent/file + + + +
+ + ++ attach_disk --target sda --sourcetype file --type disk --address usb:12:34 ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address usb:12:34 --source /nonexistent/file + + + +
+ + ++ attach_disk --target vda --sourcetype file --type disk --address usb:12.34 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address usb:12.34 --source /nonexistent/file +error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. + ++ attach_disk --target hda --sourcetype file --type disk --address usb:12.34 ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address usb:12.34 --source /nonexistent/file +error: expecting an ide:00.00.00 address. + ++ attach_disk --target sda --sourcetype file --type disk --address scsi:1.2.3 ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address scsi:1.2.3 --source /nonexistent/file + + + +
+ + ++ attach_disk --target sda --sourcetype file --type disk --address scsi:1.2.4 ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address scsi:1.2.4 --source /nonexistent/file + + + +
+ + ++ attach_disk --target sda --sourcetype file --type disk --address scsi:1:2:5 ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address scsi:1:2:5 --source /nonexistent/file + + + +
+ + ++ attach_disk --target hda --sourcetype file --type disk --address scsi:1.2.3 ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address scsi:1.2.3 --source /nonexistent/file +error: expecting an ide:00.00.00 address. + ++ attach_disk --target vda --sourcetype file --type disk --address scsi:1.2.3 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address scsi:1.2.3 --source /nonexistent/file +error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. + ++ attach_disk --target sda --sourcetype file --type disk --address sata:1.2.3 ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address sata:1.2.3 --source /nonexistent/file + + + +
+ + ++ attach_disk --target sda --sourcetype file --type disk --address sata:1.2.4 ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address sata:1.2.4 --source /nonexistent/file + + + +
+ + ++ attach_disk --target sda --sourcetype file --type disk --address sata:1:2:5 ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address sata:1:2:5 --source /nonexistent/file + + + +
+ + ++ attach_disk --target hda --sourcetype file --type disk --address sata:1.2.3 ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address sata:1.2.3 --source /nonexistent/file +error: expecting an ide:00.00.00 address. + ++ attach_disk --target vda --sourcetype file --type disk --address sata:1.2.3 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address sata:1.2.3 --source /nonexistent/file +error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. + ++ attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.78 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12.34.56.78 --source /nonexistent/file + + + +
+ + ++ attach_disk --target vda --sourcetype file --type disk --address pci:12:34:56:78 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12:34:56:78 --source /nonexistent/file + + + +
+ + ++ attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.aa ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12.34.56.aa --source /nonexistent/file + + + +
+ + ++ attach_disk --target hda --sourcetype file --type disk --address pci:12.34.56.aa ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address pci:12.34.56.aa --source /nonexistent/file +error: expecting an ide:00.00.00 address. + ++ attach_disk --target sda --sourcetype file --type disk --address pci:12.34.56.aa ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address pci:12.34.56.aa --source /nonexistent/file +error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address. + ++ attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.78 --multifunction ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12.34.56.78 --multifunction --source /nonexistent/file + + + +
+ + ++ attach_disk --target vda --sourcetype file --type disk --address pci:12:34:56:78 --multifunction ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12:34:56:78 --multifunction --source /nonexistent/file + + + +
+ + ++ attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.aa --multifunction ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12.34.56.aa --multifunction --source /nonexistent/file + + + +
+ + ++ attach_disk --target vda --sourcetype file --type disk --address ccw:12.34.56 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address ccw:12.34.56 --source /nonexistent/file + + + +
+ + ++ attach_disk --target vda --sourcetype file --type disk --address ccw:12:34:56 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address ccw:12:34:56 --source /nonexistent/file + + + +
+ + ++ attach_disk --target vda --sourcetype file --type disk --address ccw:12.34.56 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address ccw:12.34.56 --source /nonexistent/file + + + +
+ + ++ attach_disk --target hda --sourcetype file --type disk --address ccw:12.34.56 ++ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address ccw:12.34.56 --source /nonexistent/file +error: expecting an ide:00.00.00 address. + ++ attach_disk --target sda --sourcetype file --type disk --address ccw:12.34.56 ++ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address ccw:12.34.56 --source /nonexistent/file +error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address. + ++ attach_disk --target vda --sourcetype file --type disk --address test:12.34.56 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address test:12.34.56 --source /nonexistent/file +error: Invalid address. + ++ attach_disk --target vda --sourcetype file --type disk --address test:12:34:56 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address test:12:34:56 --source /nonexistent/file +error: Invalid address. + ++ attach_disk --target vda --sourcetype file --type disk --address test:12.34.56 ++ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address test:12.34.56 --source /nonexistent/file +error: Invalid address. + +end