[Qemu-devel] [PATCH v6 07/11] tests: add allowed-in-preconfig-test for qapi-schema

Igor Mammedov posted 11 patches 7 years, 6 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v6 07/11] tests: add allowed-in-preconfig-test for qapi-schema
Posted by Igor Mammedov 7 years, 6 months ago
make sure the QAPISchema can parse allowed-in-preconfig correctly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 tests/Makefile.include                           | 1 +
 tests/qapi-schema/allowed-in-preconfig-test.err  | 1 +
 tests/qapi-schema/allowed-in-preconfig-test.exit | 1 +
 tests/qapi-schema/allowed-in-preconfig-test.json | 2 ++
 tests/qapi-schema/allowed-in-preconfig-test.out  | 0
 tests/qapi-schema/qapi-schema-test.json          | 3 +++
 tests/qapi-schema/qapi-schema-test.out           | 2 ++
 tests/test-qmp-cmds.c                            | 4 ++++
 8 files changed, 14 insertions(+)
 create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.err
 create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.exit
 create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.json
 create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.out

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 3b9a5e3..4d2460d 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -524,6 +524,7 @@ qapi-schema += missing-type.json
 qapi-schema += nested-struct-data.json
 qapi-schema += non-objects.json
 qapi-schema += oob-test.json
+qapi-schema += allowed-in-preconfig-test.json
 qapi-schema += pragma-doc-required-crap.json
 qapi-schema += pragma-extra-junk.json
 qapi-schema += pragma-name-case-whitelist-crap.json
diff --git a/tests/qapi-schema/allowed-in-preconfig-test.err b/tests/qapi-schema/allowed-in-preconfig-test.err
new file mode 100644
index 0000000..2b0511b
--- /dev/null
+++ b/tests/qapi-schema/allowed-in-preconfig-test.err
@@ -0,0 +1 @@
+tests/qapi-schema/allowed-in-preconfig-test.json:2: 'allowed-in-preconfig' of command 'allowed-in-preconfig-test' should only use true value
diff --git a/tests/qapi-schema/allowed-in-preconfig-test.exit b/tests/qapi-schema/allowed-in-preconfig-test.exit
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/qapi-schema/allowed-in-preconfig-test.exit
@@ -0,0 +1 @@
+1
diff --git a/tests/qapi-schema/allowed-in-preconfig-test.json b/tests/qapi-schema/allowed-in-preconfig-test.json
new file mode 100644
index 0000000..7e0e6cb
--- /dev/null
+++ b/tests/qapi-schema/allowed-in-preconfig-test.json
@@ -0,0 +1,2 @@
+# Check against allowed-in-preconfig illegal value
+{ 'command': 'allowed-in-preconfig-test', 'allowed-in-preconfig': 'some-string' }
diff --git a/tests/qapi-schema/allowed-in-preconfig-test.out b/tests/qapi-schema/allowed-in-preconfig-test.out
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index 06e30f4..608ca35 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -142,6 +142,9 @@
 # Smoke test on Out-Of-Band
 { 'command': 'an-oob-command', 'allow-oob': true }
 
+# test allowed-in-preconfig flag
+{ 'command': 'allowed-in-preconfig-test', 'allowed-in-preconfig': true }
+
 # For testing integer range flattening in opts-visitor. The following schema
 # corresponds to the option format:
 #
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 1f5038f..c955e2d 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -168,6 +168,8 @@ command boxed-union UserDefNativeListUnion -> None
    gen=True success_response=True boxed=True oob=False preconfig=False
 command an-oob-command None -> None
    gen=True success_response=True boxed=False oob=True preconfig=False
+command allowed-in-preconfig-test None -> None
+   gen=True success_response=True boxed=False oob=False preconfig=True
 object UserDefOptions
     member i64: intList optional=True
     member u64: uint64List optional=True
diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c
index db690cc..730476a 100644
--- a/tests/test-qmp-cmds.c
+++ b/tests/test-qmp-cmds.c
@@ -20,6 +20,10 @@ void qmp_an_oob_command(Error **errp)
 {
 }
 
+void qmp_allowed_in_preconfig_test(Error **errp)
+{
+}
+
 Empty2 *qmp_user_def_cmd0(Error **errp)
 {
     return g_new0(Empty2, 1);
-- 
2.7.4


Re: [Qemu-devel] [PATCH v6 07/11] tests: add allowed-in-preconfig-test for qapi-schema
Posted by Eric Blake 7 years, 6 months ago
On 04/27/2018 10:05 AM, Igor Mammedov wrote:
> make sure the QAPISchema can parse allowed-in-preconfig correctly
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  tests/Makefile.include                           | 1 +
>  tests/qapi-schema/allowed-in-preconfig-test.err  | 1 +
>  tests/qapi-schema/allowed-in-preconfig-test.exit | 1 +
>  tests/qapi-schema/allowed-in-preconfig-test.json | 2 ++
>  tests/qapi-schema/allowed-in-preconfig-test.out  | 0
>  tests/qapi-schema/qapi-schema-test.json          | 3 +++
>  tests/qapi-schema/qapi-schema-test.out           | 2 ++
>  tests/test-qmp-cmds.c                            | 4 ++++

Aha. I'd squash this with patch 6, since it supplies the additional
tests I was asking about there.  (They were separate on the OOB series
more because of the time crunch of getting it in before rc0; but now
that we aren't under a crunch, I'd rather just have one patch for all
new tests).

>  8 files changed, 14 insertions(+)
>  create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.err
>  create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.exit
>  create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.json
>  create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.out
> 

If you like my bikeshedding for a shorter 'allow-preconfig' name, don't
forget to rename the files as well as their contents.

> +++ b/tests/qapi-schema/qapi-schema-test.json
> @@ -142,6 +142,9 @@
>  # Smoke test on Out-Of-Band
>  { 'command': 'an-oob-command', 'allow-oob': true }
>  
> +# test allowed-in-preconfig flag
> +{ 'command': 'allowed-in-preconfig-test', 'allowed-in-preconfig': true }

Why not just have a single command that sets both allow-oob and
allowed-in-preconfig on the same command?  Of course, rename it to
something other than 'an-oob-command', if you merge things into one command.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org