From ef91ab0d5fe1a263e9e3cc1d14ea702a0a9f2261 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 14 Sep 2019 17:34:52 +0200 Subject: tests/qapi-schema: Demonstrate insufficient 'if' checking Cover invalid 'if' in struct members, features, union and alternate branches. Four out of four are broken. Mark FIXME. Signed-off-by: Markus Armbruster Message-Id: <20190914153506.2151-6-armbru@redhat.com> Reviewed-by: Eric Blake [Comment typo fixed] --- tests/qapi-schema/alternate-branch-if-invalid.err | 0 tests/qapi-schema/alternate-branch-if-invalid.exit | 1 + tests/qapi-schema/alternate-branch-if-invalid.json | 4 ++++ tests/qapi-schema/alternate-branch-if-invalid.out | 16 +++++++++++++++ tests/qapi-schema/features-if-invalid.err | 0 tests/qapi-schema/features-if-invalid.exit | 1 + tests/qapi-schema/features-if-invalid.json | 5 +++++ tests/qapi-schema/features-if-invalid.out | 14 +++++++++++++ tests/qapi-schema/struct-member-if-invalid.err | 0 tests/qapi-schema/struct-member-if-invalid.exit | 1 + tests/qapi-schema/struct-member-if-invalid.json | 4 ++++ tests/qapi-schema/struct-member-if-invalid.out | 15 ++++++++++++++ tests/qapi-schema/union-branch-if-invalid.err | 0 tests/qapi-schema/union-branch-if-invalid.exit | 1 + tests/qapi-schema/union-branch-if-invalid.json | 7 +++++++ tests/qapi-schema/union-branch-if-invalid.out | 23 ++++++++++++++++++++++ 16 files changed, 92 insertions(+) create mode 100644 tests/qapi-schema/alternate-branch-if-invalid.err create mode 100644 tests/qapi-schema/alternate-branch-if-invalid.exit create mode 100644 tests/qapi-schema/alternate-branch-if-invalid.json create mode 100644 tests/qapi-schema/alternate-branch-if-invalid.out create mode 100644 tests/qapi-schema/features-if-invalid.err create mode 100644 tests/qapi-schema/features-if-invalid.exit create mode 100644 tests/qapi-schema/features-if-invalid.json create mode 100644 tests/qapi-schema/features-if-invalid.out create mode 100644 tests/qapi-schema/struct-member-if-invalid.err create mode 100644 tests/qapi-schema/struct-member-if-invalid.exit create mode 100644 tests/qapi-schema/struct-member-if-invalid.json create mode 100644 tests/qapi-schema/struct-member-if-invalid.out create mode 100644 tests/qapi-schema/union-branch-if-invalid.err create mode 100644 tests/qapi-schema/union-branch-if-invalid.exit create mode 100644 tests/qapi-schema/union-branch-if-invalid.json create mode 100644 tests/qapi-schema/union-branch-if-invalid.out (limited to 'tests/qapi-schema') diff --git a/tests/qapi-schema/alternate-branch-if-invalid.err b/tests/qapi-schema/alternate-branch-if-invalid.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/alternate-branch-if-invalid.exit b/tests/qapi-schema/alternate-branch-if-invalid.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/qapi-schema/alternate-branch-if-invalid.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/alternate-branch-if-invalid.json b/tests/qapi-schema/alternate-branch-if-invalid.json new file mode 100644 index 0000000..6497f53 --- /dev/null +++ b/tests/qapi-schema/alternate-branch-if-invalid.json @@ -0,0 +1,4 @@ +# Cover alternative with invalid 'if' +# FIXME not rejected, would generate '#if \n' +{ 'alternate': 'Alt', + 'data': { 'branch': { 'type': 'int', 'if': ' ' } } } diff --git a/tests/qapi-schema/alternate-branch-if-invalid.out b/tests/qapi-schema/alternate-branch-if-invalid.out new file mode 100644 index 0000000..89305d7 --- /dev/null +++ b/tests/qapi-schema/alternate-branch-if-invalid.out @@ -0,0 +1,16 @@ +module None +object q_empty +enum QType + prefix QTYPE + member none + member qnull + member qnum + member qstring + member qdict + member qlist + member qbool +module alternate-branch-if-invalid.json +alternate Alt + tag type + case branch: int + if [' '] diff --git a/tests/qapi-schema/features-if-invalid.err b/tests/qapi-schema/features-if-invalid.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/features-if-invalid.exit b/tests/qapi-schema/features-if-invalid.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/qapi-schema/features-if-invalid.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/features-if-invalid.json b/tests/qapi-schema/features-if-invalid.json new file mode 100644 index 0000000..7e4c1ad --- /dev/null +++ b/tests/qapi-schema/features-if-invalid.json @@ -0,0 +1,5 @@ +# Cover feature with invalid 'if' +# FIXME not rejected, misinterpreted as unconditional +{ 'struct': 'Stru', + 'data': {}, + 'features': [{'name': 'f', 'if': null }] } diff --git a/tests/qapi-schema/features-if-invalid.out b/tests/qapi-schema/features-if-invalid.out new file mode 100644 index 0000000..9c2637b --- /dev/null +++ b/tests/qapi-schema/features-if-invalid.out @@ -0,0 +1,14 @@ +module None +object q_empty +enum QType + prefix QTYPE + member none + member qnull + member qnum + member qstring + member qdict + member qlist + member qbool +module features-if-invalid.json +object Stru + feature f diff --git a/tests/qapi-schema/struct-member-if-invalid.err b/tests/qapi-schema/struct-member-if-invalid.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/struct-member-if-invalid.exit b/tests/qapi-schema/struct-member-if-invalid.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/qapi-schema/struct-member-if-invalid.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/struct-member-if-invalid.json b/tests/qapi-schema/struct-member-if-invalid.json new file mode 100644 index 0000000..73987e0 --- /dev/null +++ b/tests/qapi-schema/struct-member-if-invalid.json @@ -0,0 +1,4 @@ +# Cover member with invalid 'if' +# FIXME not rejected, would generate '#if True\n' +{ 'struct': 'Stru', + 'data': { 'member': { 'type': 'int', 'if': true } } } diff --git a/tests/qapi-schema/struct-member-if-invalid.out b/tests/qapi-schema/struct-member-if-invalid.out new file mode 100644 index 0000000..8fbb979 --- /dev/null +++ b/tests/qapi-schema/struct-member-if-invalid.out @@ -0,0 +1,15 @@ +module None +object q_empty +enum QType + prefix QTYPE + member none + member qnull + member qnum + member qstring + member qdict + member qlist + member qbool +module struct-member-if-invalid.json +object Stru + member member: int optional=False + if [True] diff --git a/tests/qapi-schema/union-branch-if-invalid.err b/tests/qapi-schema/union-branch-if-invalid.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/union-branch-if-invalid.exit b/tests/qapi-schema/union-branch-if-invalid.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/qapi-schema/union-branch-if-invalid.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/union-branch-if-invalid.json b/tests/qapi-schema/union-branch-if-invalid.json new file mode 100644 index 0000000..859b63b --- /dev/null +++ b/tests/qapi-schema/union-branch-if-invalid.json @@ -0,0 +1,7 @@ +# Cover branch with invalid 'if' +# FIXME not rejected, would generate '#if \n' +{ 'enum': 'Branches', 'data': ['branch1'] } +{ 'struct': 'Stru', 'data': { 'member': 'str' } } +{ 'union': 'Uni', + 'base': { 'tag': 'Branches' }, 'discriminator': 'tag', + 'data': { 'branch1': { 'type': 'Stru', 'if': [''] } } } diff --git a/tests/qapi-schema/union-branch-if-invalid.out b/tests/qapi-schema/union-branch-if-invalid.out new file mode 100644 index 0000000..2ed4321 --- /dev/null +++ b/tests/qapi-schema/union-branch-if-invalid.out @@ -0,0 +1,23 @@ +module None +object q_empty +enum QType + prefix QTYPE + member none + member qnull + member qnum + member qstring + member qdict + member qlist + member qbool +module union-branch-if-invalid.json +enum Branches + member branch1 +object Stru + member member: str optional=False +object q_obj_Uni-base + member tag: Branches optional=False +object Uni + base q_obj_Uni-base + tag tag + case branch1: Stru + if [''] -- cgit v1.1