diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2021-08-04 12:31:02 +0400 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-08-26 13:53:56 +0200 |
commit | 3ad64edfad2fa404e866c01f6d427ed4fe4f4f0f (patch) | |
tree | 0dfacc884ce4a8aeb40e5a0e9ed57586b0a982e8 /tests/qapi-schema | |
parent | 5d83b9a130690f879d5f33e991beabe69cb88bc8 (diff) |
qapi: add 'any' condition
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210804083105.97531-8-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests/qapi-schema')
-rw-r--r-- | tests/qapi-schema/bad-if-key.err | 2 | ||||
-rw-r--r-- | tests/qapi-schema/bad-if-keys.err | 2 | ||||
-rw-r--r-- | tests/qapi-schema/doc-good.json | 4 | ||||
-rw-r--r-- | tests/qapi-schema/doc-good.out | 2 | ||||
-rw-r--r-- | tests/qapi-schema/doc-good.txt | 3 | ||||
-rw-r--r-- | tests/qapi-schema/enum-if-invalid.err | 2 | ||||
-rw-r--r-- | tests/qapi-schema/qapi-schema-test.json | 8 | ||||
-rw-r--r-- | tests/qapi-schema/qapi-schema-test.out | 5 |
8 files changed, 21 insertions, 7 deletions
diff --git a/tests/qapi-schema/bad-if-key.err b/tests/qapi-schema/bad-if-key.err index 725d5abae5..7236f46e7a 100644 --- a/tests/qapi-schema/bad-if-key.err +++ b/tests/qapi-schema/bad-if-key.err @@ -1,3 +1,3 @@ bad-if-key.json: In struct 'TestIfStruct': bad-if-key.json:2: 'if' condition has unknown key 'value' -Valid keys are 'all'. +Valid keys are 'all', 'any'. diff --git a/tests/qapi-schema/bad-if-keys.err b/tests/qapi-schema/bad-if-keys.err index b072db9a6f..db6d019d77 100644 --- a/tests/qapi-schema/bad-if-keys.err +++ b/tests/qapi-schema/bad-if-keys.err @@ -1,2 +1,2 @@ bad-if-keys.json: In struct 'TestIfStruct': -bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all' +bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all' or 'any' diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json index 25b1053e8a..e253d89ee0 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -103,7 +103,9 @@ 'features': [ 'union-feat1' ], 'base': 'Base', 'discriminator': 'base1', - 'data': { 'one': 'Variant1', 'two': { 'type': 'Variant2', 'if': 'IFTWO' } } } + 'data': { 'one': 'Variant1', + 'two': { 'type': 'Variant2', + 'if': { 'any': ['IFONE', 'IFTWO'] } } } } ## # @SugaredUnion: diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 689d084f3a..c44c346ec8 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -30,7 +30,7 @@ object Object tag base1 case one: Variant1 case two: Variant2 - if IFTWO + if OrderedDict([('any', ['IFONE', 'IFTWO'])]) feature union-feat1 object q_obj_Variant1-wrapper member data: Variant1 optional=False diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt index 4490108cb7..251e9b746c 100644 --- a/tests/qapi-schema/doc-good.txt +++ b/tests/qapi-schema/doc-good.txt @@ -120,7 +120,8 @@ Members The members of "Base" The members of "Variant1" when "base1" is ""one"" -The members of "Variant2" when "base1" is ""two"" (**If: **"IFTWO") +The members of "Variant2" when "base1" is ""two"" (**If: **"(IFONE or +IFTWO)") Features ~~~~~~~~ diff --git a/tests/qapi-schema/enum-if-invalid.err b/tests/qapi-schema/enum-if-invalid.err index df305cd79f..b96d94c48a 100644 --- a/tests/qapi-schema/enum-if-invalid.err +++ b/tests/qapi-schema/enum-if-invalid.err @@ -1,3 +1,3 @@ enum-if-invalid.json: In enum 'TestIfEnum': enum-if-invalid.json:2: 'if' condition has unknown key 'val' -Valid keys are 'all'. +Valid keys are 'all', 'any'. diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index e85a71c0f7..7737b32de8 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -291,6 +291,11 @@ 'features': [ { 'name': 'feature1', 'if': { 'all': [ 'defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] } } ] } +{ 'struct': 'CondFeatureStruct4', + 'data': { 'foo': 'int' }, + 'features': [ { 'name': 'feature1', + 'if': {'any': ['defined(TEST_IF_COND_1)', + 'defined(TEST_IF_COND_2)'] } } ] } { 'enum': 'FeatureEnum1', 'data': [ 'eins', 'zwei', 'drei' ], @@ -314,7 +319,8 @@ '*fs4': 'FeatureStruct4', '*cfs1': 'CondFeatureStruct1', '*cfs2': 'CondFeatureStruct2', - '*cfs3': 'CondFeatureStruct3' }, + '*cfs3': 'CondFeatureStruct3', + '*cfs4': 'CondFeatureStruct4' }, 'returns': 'FeatureStruct1', 'features': [] } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index e74756cfd8..2f067d57af 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -390,6 +390,10 @@ object CondFeatureStruct3 member foo: int optional=False feature feature1 if OrderedDict([('all', ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'])]) +object CondFeatureStruct4 + member foo: int optional=False + feature feature1 + if OrderedDict([('any', ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'])]) enum FeatureEnum1 member eins member zwei @@ -417,6 +421,7 @@ object q_obj_test-features0-arg member cfs1: CondFeatureStruct1 optional=True member cfs2: CondFeatureStruct2 optional=True member cfs3: CondFeatureStruct3 optional=True + member cfs4: CondFeatureStruct4 optional=True command test-features0 q_obj_test-features0-arg -> FeatureStruct1 gen=True success_response=True boxed=False oob=False preconfig=False command test-command-features1 None -> None |