These test case specifications demonstrate what kind of tests can
be specified using validator.py.
Most of them can replace existing unit tests written in C, and
device-crash-test.yaml can replace most of the functionality of
scripts/device-crash-test.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
tests/validator/cpu.yaml | 5 +++++
tests/validator/device-add.yaml | 17 +++++++++++++++++
tests/validator/device-crash-test.yaml | 7 +++++++
tests/validator/device-help.yaml | 3 +++
tests/validator/device-introspect.yaml | 23 +++++++++++++++++++++++
tests/validator/device-list.yaml | 10 ++++++++++
tests/validator/just-help.yaml | 3 +++
7 files changed, 68 insertions(+)
create mode 100644 tests/validator/cpu.yaml
create mode 100644 tests/validator/device-add.yaml
create mode 100644 tests/validator/device-crash-test.yaml
create mode 100644 tests/validator/device-help.yaml
create mode 100644 tests/validator/device-introspect.yaml
create mode 100644 tests/validator/device-list.yaml
create mode 100644 tests/validator/just-help.yaml
diff --git a/tests/validator/cpu.yaml b/tests/validator/cpu.yaml
new file mode 100644
index 0000000000..48032995ff
--- /dev/null
+++ b/tests/validator/cpu.yaml
@@ -0,0 +1,5 @@
+# Simply check if QEMU will run without errors using a CPU model:
+command-line: '$QEMU -S -cpu $CPU'
+expected-failures:
+ # "host" doesn't always work
+ - CPU: 'host'
diff --git a/tests/validator/device-add.yaml b/tests/validator/device-add.yaml
new file mode 100644
index 0000000000..b4c0daf70c
--- /dev/null
+++ b/tests/validator/device-add.yaml
@@ -0,0 +1,17 @@
+# This test specification will try device_add with all device types
+command-line: '$QEMU -S -machine $MACHINE,accel=$ACCEL'
+monitor-commands:
+- qmp:
+ - execute: 'device_add'
+ arguments:
+ driver: '$DEVICE'
+ id: 'test-device-for-$DEVICE'
+ - execute: 'device_del'
+ arguments:
+ id: 'test-device-for-$DEVICE'
+defaults:
+ MACHINE: 'none'
+ ACCEL: 'kvm:tcg'
+expected-failures:
+ - MACHINE: 'xenpv'
+ - MACHINE: 'xenfv'
diff --git a/tests/validator/device-crash-test.yaml b/tests/validator/device-crash-test.yaml
new file mode 100644
index 0000000000..edaab0ee8f
--- /dev/null
+++ b/tests/validator/device-crash-test.yaml
@@ -0,0 +1,7 @@
+# this is a very simple test case generator that will run QEMU
+# using all combinations of -machine and -device.
+# This replaces scripts/device-crash-test.
+# TODO: use a $MACHINE_OPT variable to make -machine optional
+command-line: '$QEMU -S -machine $MACHINE,accel=$ACCEL -device $DEVICE'
+
+#TODO: represent the whitelist from device-crash-test script somehow
diff --git a/tests/validator/device-help.yaml b/tests/validator/device-help.yaml
new file mode 100644
index 0000000000..95aa5c9f5b
--- /dev/null
+++ b/tests/validator/device-help.yaml
@@ -0,0 +1,3 @@
+# Just check if -device ...,help works:
+command-line: '$QEMU -device $DEVICE,help'
+qmp: false
diff --git a/tests/validator/device-introspect.yaml b/tests/validator/device-introspect.yaml
new file mode 100644
index 0000000000..f5b10aff9a
--- /dev/null
+++ b/tests/validator/device-introspect.yaml
@@ -0,0 +1,23 @@
+# This test specification is equivalent to "device/introspect/concrete" in
+# tests/device-introspect-test.c
+command-line: '$QEMU -S -machine $MACHINE,accel=$ACCEL'
+monitor-commands:
+- qmp:
+ - execute: 'device-list-properties'
+ arguments:
+ typename: '$DEVICE'
+- hmp: 'device_add $DEVICE,help'
+- hmp: 'info qom-tree'
+defaults:
+ MACHINE: 'none'
+ ACCEL: 'kvm:tcg'
+expected-failures:
+ - MACHINE: 'xenpv'
+ - MACHINE: 'xenfv'
+
+#TODO: the test runner could support something like:
+# extra-cases:
+# # like "device/introspect/none":
+# - DEVICE: 'nonexistent'
+# # like "device/introspect/abstract":
+# - DEVICE: 'device'
diff --git a/tests/validator/device-list.yaml b/tests/validator/device-list.yaml
new file mode 100644
index 0000000000..ac0004c05d
--- /dev/null
+++ b/tests/validator/device-list.yaml
@@ -0,0 +1,10 @@
+# this test specification is equivalent to the
+# "device/introspect/list" test case in device-introspect-test.c
+command-line: '$QEMU -nodefaults -machine none'
+monitor-commands:
+- qmp:
+ - execute: qom-list-types
+ arguments:
+ implements: 'device'
+ abstract: true
+- hmp: 'device_add help'
diff --git a/tests/validator/just-help.yaml b/tests/validator/just-help.yaml
new file mode 100644
index 0000000000..84ec8d7090
--- /dev/null
+++ b/tests/validator/just-help.yaml
@@ -0,0 +1,3 @@
+# just run $QEMU -help and ensure it won't crash
+command-line: '$QEMU -help'
+qmp: false
--
2.14.3