aboutsummaryrefslogtreecommitdiff
path: root/tests/qapi-schema
AgeCommit message (Collapse)Author
2023-11-13tests/qapi-schema: Tidy up pylint warnings and adviceMarkus Armbruster
Pylint warns: tests/qapi-schema/test-qapi.py:139:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) tests/qapi-schema/test-qapi.py:143:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) Add encoding='utf-8'. Pylint advises: tests/qapi-schema/test-qapi.py:143:13: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) Silence this by returning the value directly. Pylint advises: tests/qapi-schema/test-qapi.py:221:4: R1722: Consider using sys.exit() (consider-using-sys-exit) tests/qapi-schema/test-qapi.py:226:4: R1722: Consider using sys.exit() (consider-using-sys-exit) Sure, why not. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20231025092925.1785934-1-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
2023-09-08tests/: spelling fixesMichael Tokarev
with some rewording in tests/qemu-iotests/298 tests/qtest/fuzz/generic_fuzz.c tests/unit/test-throttle.c as suggested by Eric. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Eric Blake <eblake@redhat.com>
2023-05-22qapi: Improve error message for description following sectionMarkus Armbruster
The error message is bad when the section is untagged. For instance, test case doc-interleaved-section produces "'@foobar:' can't follow 'Note' section", which is okay, but if we drop the "Note:" tag, we get "'@foobar:' can't follow 'None' section, which is bad. Change the error message to "description of '@foobar:' follows a section". Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230510141637.3685080-1-armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> [Conflict with commit 3e32dca3f0d resolved]
2023-05-10qapi: Relax doc string @name: description indentation rulesMarkus Armbruster
The QAPI schema doc comment language provides special syntax for command and event arguments, struct and union members, alternate branches, enumeration values, and features: descriptions starting with "@name:". By convention, we format them like this: # @name: Lorem ipsum dolor sit amet, consectetur adipiscing elit, # sed do eiusmod tempor incididunt ut labore et dolore # magna aliqua. Okay for names as short as "name", but we have much longer ones. Their description gets squeezed against the right margin, like this: # @dirty-sync-missed-zero-copy: Number of times dirty RAM synchronization could # not avoid copying dirty pages. This is between # 0 and @dirty-sync-count * @multifd-channels. # (since 7.1) The description text is effectively just 50 characters wide. Easy enough to read, but can be cumbersome to write. The awkward squeeze against the right margin makes people go beyond it, which produces two undesirables: arguments about style, and descriptions that are unnecessarily hard to read, like this one: # @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU. This is # only present when the postcopy-blocktime migration capability # is enabled. (Since 3.0) We could instead format it like # @postcopy-vcpu-blocktime: # list of the postcopy blocktime per vCPU. This is only present # when the postcopy-blocktime migration capability is # enabled. (Since 3.0) or, since the commit before previous, like # @postcopy-vcpu-blocktime: # list of the postcopy blocktime per vCPU. This is only present # when the postcopy-blocktime migration capability is # enabled. (Since 3.0) However, I'd rather have # @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU. # This is only present when the postcopy-blocktime migration # capability is enabled. (Since 3.0) because this is how rST field and option lists work. To get this, we need to let the first non-blank line after the "@name:" line determine expected indentation. This fills up the indentation pitfall mentioned in docs/devel/qapi-code-gen.rst. A related pitfall still exists. Update the text to show it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230428105429.1687850-14-armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> [Work around lack of walrus operator in Python 3.7 and older]
2023-05-09qapi: Fix argument description indentation strippingMarkus Armbruster
When an argument's description starts on the line after the "#arg: " line, indentation is stripped only from the description's first line, as demonstrated by the previous commit. Moreover, subsequent lines with less indentation are not rejected. Make the first line's indentation the expected indentation for the remainder of the description. This fixes indentation stripping, and also requires at least that much indentation. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230428105429.1687850-12-armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com>
2023-05-09tests/qapi-schema/doc-good: Improve argument description testsMarkus Armbruster
Improve the comments to better describe what they test. Cover argument description starting on a new line indented. This style isn't documented in docs/devel/qapi-code-gen.rst. qapi-gen.py accepts it, but messes up indentation: it's stripped from the first line, not subsequent ones. The next commit will fix this. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230428105429.1687850-11-armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com>
2023-05-09tests/qapi-schema/doc-good: Improve a commentMarkus Armbruster
The QAPI generator doesn't reject undocumented members and features (yet). doc-good.json covers this, with clear "is undocumented" notes to signal intent. Except for @Variant1 member @var1, where it's "(but no @var: line)". Less clear. Replace by "@var1 is undocumented". Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230428105429.1687850-10-armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com>
2023-04-26qapi: allow unions to contain further unionsDaniel P. Berrangé
This extends the QAPI schema validation to permit unions inside unions, provided the checks for clashing fields pass. Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20230420102619.348173-4-berrange@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2023-04-25qapi: support updating expected test output via makeDaniel P. Berrangé
It is possible to pass --update to tests/qapi-schema/test-qapi.py to make it update the output files on error. This is inconvenient to achieve though when test-qapi.py is run indirectly by make/meson. Instead simply allow for an env variable to be set: $ QAPI_TEST_UPDATE= make check-qapi-schema Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20230420102619.348173-2-berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2023-04-24qapi: Require boxed for conditional command and event argumentsMarkus Armbruster
The C code generator fails to honor 'if' conditions of command and event arguments. For instance, tests/qapi-schema/qapi-schema-test.json has { 'event': 'TEST_IF_EVENT', 'data': { 'foo': 'TestIfStruct', 'bar': { 'type': ['str'], 'if': 'TEST_IF_EVT_ARG' } }, 'if': { 'all': ['TEST_IF_EVT', 'TEST_IF_STRUCT'] } } Generated tests/test-qapi-events.h fails to honor the TEST_IF_EVT_ARG condition: #if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) void qapi_event_send_test_if_event(TestIfStruct *foo, strList *bar); #endif /* defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) */ Only uses so far are in tests/. We could fix the generator to emit something like #if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) void qapi_event_send_test_if_event(TestIfStruct *foo #if defined(TEST_IF_EVT_ARG) , strList *bar #endif ); #endif /* defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) */ Ugly. Calls become similarly ugly. Not worth fixing. Conditional arguments work fine with 'boxed': true, simply because complex types with conditional members work fine. Not worth breaking. Reject conditional arguments unless boxed. Move the tests cases covering unboxed conditional arguments out of tests/qapi-schema/qapi-schema-test.json. Cover boxed conditional arguments there instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-15-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2023-04-24tests/qapi-schema: Cover optional conditional struct memberMarkus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-13-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2023-04-24tests/qapi-schema: Clean up positive test for conditionalsMarkus Armbruster
Union TestIfUnion is conditional on macros TEST_IF_UNION and TEST_IF_STRUCT. It uses TestIfEnum, which is conditional on macro TEST_IF_ENUM. If TEST_IF_UNION and TEST_IF_STRUCT are defined, but TEST_IF_ENUM isn't, the generated code won't compile. Command test-if-cmd is conditional an macros TEST_IF_CMD and TEST_IF_STRUCT, and uses TestIfEnum. Similar issue. Event TEST_IF_EVENT is conditional an macros TEST_IF_EVT and TEST_IF_STRUCT, and uses TestIfEnum. Similar issue. Replace the uses of TestIfEnum in the latter two by str. TestIfUnion is now TestIfEnum's only user. Change TestIfEnum's condition to TEST_IF_UNION. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-12-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Commit message corrected]
2023-04-24tests/qapi-schema: Rename a few conditionalsMarkus Armbruster
Positive test case { 'enum': 'TestIfEnum', 'data': [ 'foo', { 'name' : 'bar', 'if': 'TEST_IF_ENUM_BAR' } ], 'if': 'TEST_IF_ENUM' } generates #if defined(TEST_IF_ENUM) typedef enum TestIfEnum { TEST_IF_ENUM_FOO, #if defined(TEST_IF_ENUM_BAR) TEST_IF_ENUM_BAR, #endif /* defined(TEST_IF_ENUM_BAR) */ TEST_IF_ENUM__MAX, } TestIfEnum; Macro TEST_IF_ENUM_BAR clashes with the enumeration constant. Wouldn't compile with -DTEST_IF_BAR. Rename the macro to TEST_IF_ENUM_MEMBER. For consistency, rename similar macros elsewhere as well. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-11-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2023-04-24tests/qapi-schema: Improve union discriminator coverageMarkus Armbruster
A union's 'discriminator' must name one of the common members. QAPISchemaVariants.check() looks it up by its c_name(), then checks the name matches exactly (because c_name() is not injective). Tests union-base-empty and union-invalid-discriminator both cover the case where lookup fails. Repurpose the latter to cover the case where it succeeds and the name check fails. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-10-armbru@redhat.com Reviewed-by: Eric Blake <eblake@redhat.com> [Commit message typo fixed]
2023-04-24qapi: Fix to reject 'data': 'mumble' in structMarkus Armbruster
A struct's 'data' must be a JSON object defining the struct's members. The QAPI code generator incorrectly accepts a JSON string instead, and then crashes in QAPISchema._make_members() called from ._def_struct_type(). Fix to reject it: factor check_type_implicit() out of check_type_name_or_implicit(), and switch check_struct() to use it instead. Also add a test case. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-9-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [More detailed commit message]
2023-04-24qapi: Fix error message when type name or array is expectedMarkus Armbruster
We incorrectly report "FOO should be a type name" when it could also be an array. Fix that. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-8-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2023-04-24qapi: Improve error message for unexpected array typesMarkus Armbruster
We reject array types in certain places with "cannot be an array". Deleting this check improves the error message to "should be a type name" or "should be an object or type name", depending on context, so do that. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-6-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2023-02-02meson: replace Perl usage with PythonMarc-André Lureau
Let's try to remove Perl usage during build time. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20230110132700.833690-5-marcandre.lureau@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230124180127.1881110-8-alex.bennee@linaro.org>
2023-01-06tests/qapi-schema: remove Meson workaroundPaolo Bonzini
The referenced issue has been fixed since version 0.61, so remove the workaround. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-09-01meson: remove dead assignmentsPaolo Bonzini
Found with "muon analyze". Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-04-21qapi-schema: test: add a unit test for parsing array alternatesPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20220321164243.200569-4-pbonzini@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Dead code dropped in test_visitor_in_alternate_list()] Signed-off-by: Markus Armbruster <armbru@redhat.com>
2022-04-21qapi-schema: test: add a qapi-schema-test for array alternatesPaolo Bonzini
Check that conflicts among array alternates are detected correctly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20220321164243.200569-3-pbonzini@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Expected test output alternate-conflict-lists.json corrected] Signed-off-by: Markus Armbruster <armbru@redhat.com>
2022-04-21qapi-schema: support alternates with array typePaolo Bonzini
Detect array types as alternate branches, and turn the JSON list into a QAPISchemaArrayType. Array types in an alternate are represented with QTYPE_QLIST in the type field. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20220321164243.200569-2-pbonzini@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2021-11-08meson: drop sphinx_extn_dependsMarc-André Lureau
Module dependencies is now handled by depfile.py. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-08tests/qapi-schema/meson: add depfile to sphinx docMarc-André Lureau
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2021-10-29qapi: New special feature flag "unstable"Markus Armbruster
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases. The naming convention makes unstable interfaces easy to recognize. Promoting something from experimental to stable involves a name change. Client code needs to be updated. Occasionally bothersome. Worse, the convention is not universally observed: * QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2. * QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name. We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated". So support recognizing it the same way: introduce new special feature flag "unstable". It will be treated specially by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags. This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking. Management applications can then use query-qmp-schema and -compat to manage or guard against use of unstable interfaces the same way as for deprecated interfaces. docs/devel/qapi-code-gen.txt no longer mandates the naming convention. Using it anyway might help writers of programs that aren't full-fledged management applications. Not using it can save us bothersome renames. We'll see how that shakes out. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-Id: <20211028102520.747396-2-armbru@redhat.com>
2021-10-27qapi: Add feature flags to enum membersMarkus Armbruster
This is quite similar to commit 84ab008687 "qapi: Add feature flags to struct members", only for enums instead of structs. Special feature flag 'deprecated' is silently ignored there. This is okay only because it will be implemented shortly. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20211025042405.3762351-3-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
2021-10-05meson: switch minimum meson version to 0.58.2, minimum recommended to 0.59.2Paolo Bonzini
Meson 0.58.2 does not need b_staticpic=$pie anymore, and has stabilized the keyval module. Remove the workaround and use a few replacements for features deprecated in the 0.57.0 release cycle. One feature that we would like to use is passing dependencies to summary. However, that was broken in 0.59.0 and 0.59.1. Therefore, use the embedded Meson if the host has anything older than 0.59.2, but allow --meson= to use 0.58.2. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-10-02qapi/parser: remove FIXME comment from _append_body_lineJohn Snow
True, we do not check the validity of this symbol -- but we don't check the validity of definition names during parse, either -- that happens later, during the expr check. I don't want to introduce a dependency on expr.py:check_name_str here and introduce a cycle. Instead, rest assured that a documentation block is required for each definition. This requirement uses the names of each section to ensure that we fulfilled this requirement. e.g., let's say that block-core.json has a comment block for "Snapshot!Info" by accident. We'll see this error message: In file included from ../../qapi/block.json:8: ../../qapi/block-core.json: In struct 'SnapshotInfo': ../../qapi/block-core.json:38: documentation comment is for 'Snapshot!Info' That's a pretty decent error message. Now, let's say that we actually mangle it twice, identically: ../../qapi/block-core.json: In struct 'Snapshot!Info': ../../qapi/block-core.json:38: struct has an invalid name That's also pretty decent. If we forget to fix it in both places, we'll just be back to the first error. Therefore, let's just drop this FIXME and adjust the error message to not imply a more thorough check than is actually performed. Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210930205716.1148693-6-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2021-10-02qapi: Add spaces after symbol declaration for consistencyJohn Snow
Several QGA definitions omit a blank line after the symbol declaration. This works OK currently, but it's the only place where we do this. Adjust it for consistency. Future commits may wind up enforcing this formatting. Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210930205716.1148693-5-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2021-10-02qapi/parser: fix unused check_args_section argumentsJohn Snow
Pylint informs us we're not using these arguments. Oops, it's right. Correct the error message and remove the remaining unused parameter. Fix test output now that the error message is improved. Fixes: e151941d1b Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210930205716.1148693-4-jsnow@redhat.com> [Commit message formatting tweaked] Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2021-09-27tests/qapi-schema: Make test-qapi.py -u work when files are absentMarkus Armbruster
test-qapi.py -u updates the expected files. Since it fails when they are absent, users have to create them manually before they can use test-qapi.py to fill in the contents, say for a new test. Silly. Improve -u to create them. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210922125619.670673-3-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
2021-09-27tests/qapi-schema: Use Python OSError instead of outmoded IOErrorMarkus Armbruster
https://docs.python.org/3.6/library/exceptions.html has Changed in version 3.3: EnvironmentError, IOError, WindowsError, socket.error, select.error and mmap.error have been merged into OSError, and the constructor may return a subclass. and The following exceptions are kept for compatibility with previous versions; starting from Python 3.3, they are aliases of OSError. exception EnvironmentError exception IOError exception WindowsError Only available on Windows. Switch to the preferred name. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210922125619.670673-2-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> [Details added to commit message]
2021-09-27tests/qapi-schema: Rename flat-union-* test cases to union-*Markus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210917143134.412106-23-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com
2021-09-27qapi: Drop simple unionsMarkus Armbruster
Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. The previous commits eliminated simple union from the tree. Now drop them from the QAPI schema language entirely, and update mentions of "flat union" to just "union". Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210917143134.412106-22-armbru@redhat.com>
2021-09-27tests/qapi-schema: Purge simple unions from testsMarkus Armbruster
Drop tests that are specifically about simple unions: * SugaredUnion in doc-good: flat unions are covered by @Object. * union-branch-case and union-clash-branches: branch naming for flat unions is enforced for the tag enum instead, which is covered by enum-member-case and enum-clash-member. * union-empty: empty flat unions are covered by flat-union-empty. Rewrite the remainder to use flat unions: args-union, bad-base, flat-union-base-union, union-branch-invalid-dict, union-unknown. Except drop union-optional-branch. because converting this one is not worth the trouble; we don't explicitly check names beginning with '*' in other places, either. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210917143134.412106-21-armbru@redhat.com>
2021-09-27tests/qapi-schema: Drop simple union __org.qemu_x-Union1Markus Armbruster
Replace simple union __org.qemu_x-Union1 with flat union __org.qemu_x-Union2, except drop it from __org.qemu_x-command, because there it's only used to pull it into QMP. Now drop the unused -Union1, and rename -Union2 to -Union. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210917143134.412106-20-armbru@redhat.com>
2021-09-27tests/qapi-schema: Rewrite simple union TestIfUnion to be flatMarkus Armbruster
Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, rewrite TestIfUnion to be flat. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210917143134.412106-18-armbru@redhat.com>
2021-09-27tests/qapi-schema: Simple union UserDefListUnion is now unused, dropMarkus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210917143134.412106-17-armbru@redhat.com>
2021-09-27tests/qapi-schema: Wean off UserDefListUnionMarkus Armbruster
Command boxed-union uses simple union UserDefListUnion to cover unions. Use UserDefFlatUnion instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210917143134.412106-16-armbru@redhat.com>
2021-09-27tests/qapi-schema: Prepare for simple union UserDefListUnion removalMarkus Armbruster
Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, simple union UserDefListUnion has to go. It is used to cover arrays. The next few commits will eliminate its uses, and then it gets deleted. As a first step, provide struct ArrayStruct for the tests to be rewritten. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210917143134.412106-12-armbru@redhat.com>
2021-09-25qapi: Stop enforcing "type name should not end in 'Kind'Markus Armbruster
I'm about to convert simple unions to flat unions, then drop simple union support. The conversion involves making the implict enum types explicit. To reduce churn, I'd like to name them exactly like the implicit types they replace. However, these names are reserved for the generator's use. They won't be once simple unions are gone. Stop enforcing this naming rule now rather than then. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210917143134.412106-3-armbru@redhat.com>
2021-09-25qapi: Tidy up unusual line breaksMarkus Armbruster
Break lines between members instead of within members. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20210917143134.412106-2-armbru@redhat.com>
2021-09-08qapi: Fix bogus error for 'if': { 'not': '' }Markus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210908045428.2689093-6-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> [check_infix()'s type hint fixed]
2021-09-08tests/qapi-schema: Cover 'not' condition with empty argumentMarkus Armbruster
We flag this, but the error message is bogus: bad-if-not.json:2: 'if' condition [] of struct is useless The next commit will fix it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210908045428.2689093-5-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-09-03qapi: Tweak error messages for unknown / conflicting 'if' keysMarkus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210831123809.1107782-13-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-09-03qapi: Tweak error messages for missing / conflicting meta-typeMarkus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210831123809.1107782-12-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-09-03tests/qapi-schema: Hide OrderedDict in test outputMarkus Armbruster
Since commit 5d83b9a130 "qapi: replace if condition list with dict {'all': [...]}", we represent if conditionals as trees consisting of OrderedDict, list and str. This results in less than legible test output. For instance: if OrderedDict([('not', OrderedDict([('any', [OrderedDict([('not', 'TEST_IF_EVT')]), OrderedDict([('not', 'TEST_IF_STRUCT')])])]))]) We intend to replace OrderedDict by dict when we get Python 3.7, which will result in more legible output: if {'not': {'any': [{'not': 'TEST_IF_EVT'}, {'not': 'TEST_IF_STRUCT'}]}} Can't wait: put in a hack to get that now, with a comment to revert it when we replace OrderedDict. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210831123809.1107782-11-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-09-03qapi: Use "not COND" instead of "!COND" for generated documentationMarkus Armbruster
Generated documentation uses operators "and", "or", and "!". Change the latter to "not". Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210831123809.1107782-9-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-09-03qapi: Avoid redundant parens in code generated for conditionalsMarkus Armbruster
Commit 6cc2e4817f "qapi: introduce QAPISchemaIfCond.cgen()" caused a minor regression: redundant parenthesis. Subsequent commits eliminated of many of them, but not all. Get rid of the rest now. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210831123809.1107782-8-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>