qemu/tests/qapi-schema
Markus Armbruster c615550df3 qapi: Improve source file read error handling
qapi-gen.py crashes when it can't open the main schema file, and when
it can't read from any schema file.  Lazy.

Change QAPISchema.__init__() to take a file name instead of a file
object.  Move the open code from _include() to __init__(), so it's
used for the main schema file, too.

Move the read into the try for good measure, and rephrase the error
message.

Reporting open or read failure for the main schema file needs a
QAPISourceInfo representing "no source".  Make QAPISourceInfo cope
with fname=None.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190927134639.4284-27-armbru@redhat.com>
2019-09-28 17:17:48 +02:00
..
include
allow-preconfig-test.err
allow-preconfig-test.exit
allow-preconfig-test.json
allow-preconfig-test.out
alternate-any.err
alternate-any.exit
alternate-any.json
alternate-any.out
alternate-array.err
alternate-array.exit
alternate-array.json
alternate-array.out
alternate-base.err
alternate-base.exit
alternate-base.json
alternate-base.out
alternate-branch-if-invalid.err
alternate-branch-if-invalid.exit
alternate-branch-if-invalid.json
alternate-branch-if-invalid.out
alternate-clash.err
alternate-clash.exit
alternate-clash.json
alternate-clash.out
alternate-conflict-bool-string.err
alternate-conflict-bool-string.exit
alternate-conflict-bool-string.json
alternate-conflict-bool-string.out
alternate-conflict-dict.err
alternate-conflict-dict.exit
alternate-conflict-dict.json
alternate-conflict-dict.out
alternate-conflict-enum-bool.err
alternate-conflict-enum-bool.exit
alternate-conflict-enum-bool.json
alternate-conflict-enum-bool.out
alternate-conflict-enum-int.err
alternate-conflict-enum-int.exit
alternate-conflict-enum-int.json
alternate-conflict-enum-int.out
alternate-conflict-num-string.err
alternate-conflict-num-string.exit
alternate-conflict-num-string.json
alternate-conflict-num-string.out
alternate-conflict-string.err
alternate-conflict-string.exit
alternate-conflict-string.json
alternate-conflict-string.out
alternate-empty.err
alternate-empty.exit
alternate-empty.json
alternate-empty.out
alternate-invalid-dict.err
alternate-invalid-dict.exit
alternate-invalid-dict.json
alternate-invalid-dict.out
alternate-nested.err
alternate-nested.exit
alternate-nested.json
alternate-nested.out
alternate-unknown.err
alternate-unknown.exit
alternate-unknown.json
alternate-unknown.out
args-alternate.err
args-alternate.exit
args-alternate.json
args-alternate.out
args-any.err
args-any.exit
args-any.json
args-any.out
args-array-empty.err
args-array-empty.exit
args-array-empty.json
args-array-empty.out
args-array-unknown.err
args-array-unknown.exit
args-array-unknown.json
args-array-unknown.out
args-bad-boxed.err
args-bad-boxed.exit
args-bad-boxed.json
args-bad-boxed.out
args-boxed-anon.err
args-boxed-anon.exit
args-boxed-anon.json
args-boxed-anon.out
args-boxed-string.err
args-boxed-string.exit
args-boxed-string.json
args-boxed-string.out
args-int.err
args-int.exit
args-int.json
args-int.out
args-invalid.err
args-invalid.exit
args-invalid.json
args-invalid.out
args-member-array-bad.err
args-member-array-bad.exit
args-member-array-bad.json
args-member-array-bad.out
args-member-case.err
args-member-case.exit
args-member-case.json
args-member-case.out
args-member-unknown.err
args-member-unknown.exit
args-member-unknown.json
args-member-unknown.out
args-name-clash.err
args-name-clash.exit
args-name-clash.json
args-name-clash.out
args-union.err
args-union.exit
args-union.json
args-union.out
args-unknown.err
args-unknown.exit
args-unknown.json
args-unknown.out
bad-base.err
bad-base.exit
bad-base.json
bad-base.out
bad-data.err
bad-data.exit
bad-data.json
bad-data.out
bad-ident.err
bad-ident.exit
bad-ident.json
bad-ident.out
bad-if-empty-list.err
bad-if-empty-list.exit
bad-if-empty-list.json
bad-if-empty-list.out
bad-if-empty.err
bad-if-empty.exit
bad-if-empty.json
bad-if-empty.out
bad-if-list.err
bad-if-list.exit
bad-if-list.json
bad-if-list.out
bad-if.err
bad-if.exit
bad-if.json
bad-if.out
bad-type-bool.err
bad-type-bool.exit
bad-type-bool.json
bad-type-bool.out
bad-type-dict.err
bad-type-dict.exit
bad-type-dict.json
bad-type-dict.out
bad-type-int.err
bad-type-int.exit
bad-type-int.json
bad-type-int.out
base-cycle-direct.err
base-cycle-direct.exit
base-cycle-direct.json
base-cycle-direct.out
base-cycle-indirect.err
base-cycle-indirect.exit
base-cycle-indirect.json
base-cycle-indirect.out
command-int.err
command-int.exit
command-int.json
command-int.out
comments.err
comments.exit
comments.json
comments.out
doc-bad-alternate-member.err
doc-bad-alternate-member.exit
doc-bad-alternate-member.json
doc-bad-alternate-member.out
doc-bad-command-arg.err
doc-bad-command-arg.exit
doc-bad-command-arg.json
doc-bad-command-arg.out
doc-bad-section.err
doc-bad-section.exit
doc-bad-section.json
doc-bad-section.out
doc-bad-symbol.err
doc-bad-symbol.exit
doc-bad-symbol.json
doc-bad-symbol.out
doc-bad-union-member.err
doc-bad-union-member.exit
doc-bad-union-member.json
doc-bad-union-member.out
doc-before-include.err
doc-before-include.exit
doc-before-include.json
doc-before-include.out
doc-before-pragma.err
doc-before-pragma.exit
doc-before-pragma.json
doc-before-pragma.out
doc-duplicated-arg.err
doc-duplicated-arg.exit
doc-duplicated-arg.json
doc-duplicated-arg.out
doc-duplicated-return.err
doc-duplicated-return.exit
doc-duplicated-return.json
doc-duplicated-return.out
doc-duplicated-since.err
doc-duplicated-since.exit
doc-duplicated-since.json
doc-duplicated-since.out
doc-empty-arg.err
doc-empty-arg.exit
doc-empty-arg.json
doc-empty-arg.out
doc-empty-section.err
doc-empty-section.exit
doc-empty-section.json
doc-empty-section.out
doc-empty-symbol.err
doc-empty-symbol.exit
doc-empty-symbol.json
doc-empty-symbol.out
doc-good.err
doc-good.exit
doc-good.json
doc-good.out
doc-good.texi
doc-interleaved-section.err
doc-interleaved-section.exit
doc-interleaved-section.json
doc-interleaved-section.out
doc-invalid-end2.err
doc-invalid-end2.exit
doc-invalid-end2.json
doc-invalid-end2.out
doc-invalid-end.err
doc-invalid-end.exit
doc-invalid-end.json
doc-invalid-end.out
doc-invalid-return.err
doc-invalid-return.exit
doc-invalid-return.json
doc-invalid-return.out
doc-invalid-section.err
doc-invalid-section.exit
doc-invalid-section.json
doc-invalid-section.out
doc-invalid-start.err
doc-invalid-start.exit
doc-invalid-start.json
doc-invalid-start.out
doc-missing-colon.err
doc-missing-colon.exit
doc-missing-colon.json
doc-missing-colon.out
doc-missing-expr.err
doc-missing-expr.exit
doc-missing-expr.json
doc-missing-expr.out
doc-missing-space.err
doc-missing-space.exit
doc-missing-space.json
doc-missing-space.out
doc-missing.err
doc-missing.exit
doc-missing.json
doc-missing.out
doc-no-symbol.err
doc-no-symbol.exit
doc-no-symbol.json
doc-no-symbol.out
double-type.err
double-type.exit
double-type.json
double-type.out
duplicate-key.err
duplicate-key.exit
duplicate-key.json
duplicate-key.out
empty.err
empty.exit
empty.json
empty.out
enum-bad-member.err
enum-bad-member.exit
enum-bad-member.json
enum-bad-member.out
enum-bad-name.err
enum-bad-name.exit
enum-bad-name.json
enum-bad-name.out
enum-bad-prefix.err
enum-bad-prefix.exit
enum-bad-prefix.json
enum-bad-prefix.out
enum-clash-member.err
enum-clash-member.exit
enum-clash-member.json
enum-clash-member.out
enum-dict-member-unknown.err
enum-dict-member-unknown.exit
enum-dict-member-unknown.json
enum-dict-member-unknown.out
enum-if-invalid.err
enum-if-invalid.exit
enum-if-invalid.json
enum-if-invalid.out
enum-int-member.err
enum-int-member.exit
enum-int-member.json
enum-int-member.out
enum-member-case.err
enum-member-case.exit
enum-member-case.json
enum-member-case.out
enum-missing-data.err
enum-missing-data.exit
enum-missing-data.json
enum-missing-data.out
enum-wrong-data.err
enum-wrong-data.exit
enum-wrong-data.json
enum-wrong-data.out
escape-outside-string.err
event-boxed-empty.err
event-boxed-empty.exit
event-boxed-empty.json
event-boxed-empty.out
event-case.err
event-case.exit
event-case.json
event-case.out
event-member-invalid-dict.err
event-member-invalid-dict.exit
event-member-invalid-dict.json
event-member-invalid-dict.out
event-nest-struct.err
event-nest-struct.exit
event-nest-struct.json
event-nest-struct.out
features-bad-type.err
features-bad-type.exit
features-bad-type.json
features-bad-type.out
features-duplicate-name.err
features-duplicate-name.exit
features-duplicate-name.json
features-duplicate-name.out
features-if-invalid.err
features-if-invalid.exit
features-if-invalid.json
features-if-invalid.out
features-missing-name.err
features-missing-name.exit
features-missing-name.json
features-missing-name.out
features-name-bad-type.err
features-name-bad-type.exit
features-name-bad-type.json
features-name-bad-type.out
features-no-list.err
features-no-list.exit
features-no-list.json
features-no-list.out
features-unknown-key.err
features-unknown-key.exit
features-unknown-key.json
features-unknown-key.out
flat-union-array-branch.err
flat-union-array-branch.exit
flat-union-array-branch.json
flat-union-array-branch.out
flat-union-bad-base.err
flat-union-bad-base.exit
flat-union-bad-base.json
flat-union-bad-base.out
flat-union-bad-discriminator.err
flat-union-bad-discriminator.exit
flat-union-bad-discriminator.json
flat-union-bad-discriminator.out
flat-union-base-any.err
flat-union-base-any.exit
flat-union-base-any.json
flat-union-base-any.out
flat-union-base-union.err
flat-union-base-union.exit
flat-union-base-union.json
flat-union-base-union.out
flat-union-clash-member.err
flat-union-clash-member.exit
flat-union-clash-member.json
flat-union-clash-member.out
flat-union-discriminator-bad-name.err
flat-union-discriminator-bad-name.exit
flat-union-discriminator-bad-name.json
flat-union-discriminator-bad-name.out
flat-union-empty.err
flat-union-empty.exit
flat-union-empty.json
flat-union-empty.out
flat-union-inline-invalid-dict.err
flat-union-inline-invalid-dict.exit
flat-union-inline-invalid-dict.json
flat-union-inline-invalid-dict.out
flat-union-inline.err
flat-union-inline.exit
flat-union-inline.json
flat-union-inline.out
flat-union-int-branch.err
flat-union-int-branch.exit
flat-union-int-branch.json
flat-union-int-branch.out
flat-union-invalid-branch-key.err
flat-union-invalid-branch-key.exit
flat-union-invalid-branch-key.json
flat-union-invalid-branch-key.out
flat-union-invalid-discriminator.err
flat-union-invalid-discriminator.exit
flat-union-invalid-discriminator.json
flat-union-invalid-discriminator.out
flat-union-invalid-if-discriminator.err
flat-union-invalid-if-discriminator.exit
flat-union-invalid-if-discriminator.json
flat-union-invalid-if-discriminator.out
flat-union-no-base.err
flat-union-no-base.exit
flat-union-no-base.json
flat-union-no-base.out
flat-union-optional-discriminator.err
flat-union-optional-discriminator.exit
flat-union-optional-discriminator.json
flat-union-optional-discriminator.out
flat-union-string-discriminator.err
flat-union-string-discriminator.exit
flat-union-string-discriminator.json
flat-union-string-discriminator.out
funny-char.err
funny-char.exit
funny-char.json
funny-char.out
funny-word.err
funny-word.exit
funny-word.json
funny-word.out
ident-with-escape.err
ident-with-escape.exit
ident-with-escape.json
ident-with-escape.out
include-before-err.err
include-before-err.exit
include-before-err.json
include-before-err.out
include-cycle-b.json
include-cycle-c.json
include-cycle.err
include-cycle.exit
include-cycle.json
include-cycle.out
include-extra-junk.err
include-extra-junk.exit
include-extra-junk.json
include-extra-junk.out
include-nested-err.err
include-nested-err.exit
include-nested-err.json
include-nested-err.out
include-no-file.err
include-no-file.exit
include-no-file.json
include-no-file.out
include-non-file.err
include-non-file.exit
include-non-file.json
include-non-file.out
include-repetition-sub.json
include-repetition.err
include-repetition.exit
include-repetition.json
include-repetition.out
include-self-cycle.err
include-self-cycle.exit
include-self-cycle.json
include-self-cycle.out
include-simple-sub.json
include-simple.err
include-simple.exit
include-simple.json
include-simple.out
indented-expr.err
indented-expr.exit
indented-expr.json
indented-expr.out
leading-comma-list.err
leading-comma-list.exit
leading-comma-list.json
leading-comma-list.out
leading-comma-object.err
leading-comma-object.exit
leading-comma-object.json
leading-comma-object.out
missing-colon.err
missing-colon.exit
missing-colon.json
missing-colon.out
missing-comma-list.err
missing-comma-list.exit
missing-comma-list.json
missing-comma-list.out
missing-comma-object.err
missing-comma-object.exit
missing-comma-object.json
missing-comma-object.out
missing-type.err
missing-type.exit
missing-type.json
missing-type.out
nested-struct-data-invalid-dict.err
nested-struct-data-invalid-dict.exit
nested-struct-data-invalid-dict.json
nested-struct-data-invalid-dict.out
nested-struct-data.err
nested-struct-data.exit
nested-struct-data.json
nested-struct-data.out
non-objects.err
non-objects.exit
non-objects.json
non-objects.out
oob-test.err
oob-test.exit
oob-test.json
oob-test.out
pragma-doc-required-crap.err
pragma-doc-required-crap.exit
pragma-doc-required-crap.json
pragma-doc-required-crap.out
pragma-extra-junk.err
pragma-extra-junk.exit
pragma-extra-junk.json
pragma-extra-junk.out
pragma-name-case-whitelist-crap.err
pragma-name-case-whitelist-crap.exit
pragma-name-case-whitelist-crap.json
pragma-name-case-whitelist-crap.out
pragma-non-dict.err
pragma-non-dict.exit
pragma-non-dict.json
pragma-non-dict.out
pragma-returns-whitelist-crap.err
pragma-returns-whitelist-crap.exit
pragma-returns-whitelist-crap.json
pragma-returns-whitelist-crap.out
pragma-unknown.err
pragma-unknown.exit
pragma-unknown.json
pragma-unknown.out
qapi-schema-test.err
qapi-schema-test.exit
qapi-schema-test.json
qapi-schema-test.out
quoted-structural-chars.err
quoted-structural-chars.exit
quoted-structural-chars.json
quoted-structural-chars.out
redefined-builtin.err
redefined-builtin.exit
redefined-builtin.json
redefined-builtin.out
redefined-command.err
redefined-command.exit
redefined-command.json
redefined-command.out
redefined-event.err
redefined-event.exit
redefined-event.json
redefined-event.out
redefined-type.err
redefined-type.exit
redefined-type.json
redefined-type.out
reserved-command-q.err
reserved-command-q.exit
reserved-command-q.json
reserved-command-q.out
reserved-enum-q.err
reserved-enum-q.exit
reserved-enum-q.json
reserved-enum-q.out
reserved-member-has.err
reserved-member-has.exit
reserved-member-has.json
reserved-member-has.out
reserved-member-q.err
reserved-member-q.exit
reserved-member-q.json
reserved-member-q.out
reserved-member-u.err
reserved-member-u.exit
reserved-member-u.json
reserved-member-u.out
reserved-member-underscore.err
reserved-member-underscore.exit
reserved-member-underscore.json
reserved-member-underscore.out
reserved-type-kind.err
reserved-type-kind.exit
reserved-type-kind.json
reserved-type-kind.out
reserved-type-list.err
reserved-type-list.exit
reserved-type-list.json
reserved-type-list.out
returns-alternate.err
returns-alternate.exit
returns-alternate.json
returns-alternate.out
returns-array-bad.err
returns-array-bad.exit
returns-array-bad.json
returns-array-bad.out
returns-dict.err
returns-dict.exit
returns-dict.json
returns-dict.out
returns-unknown.err
returns-unknown.exit
returns-unknown.json
returns-unknown.out
returns-whitelist.err
returns-whitelist.exit
returns-whitelist.json
returns-whitelist.out
string-code-point-31.err
string-code-point-31.exit
string-code-point-31.json
string-code-point-31.out
string-code-point-127.err
string-code-point-127.exit
string-code-point-127.json
string-code-point-127.out
struct-base-clash-deep.err
struct-base-clash-deep.exit
struct-base-clash-deep.json
struct-base-clash-deep.out
struct-base-clash.err
struct-base-clash.exit
struct-base-clash.json
struct-base-clash.out
struct-data-invalid.err
struct-data-invalid.exit
struct-data-invalid.json
struct-data-invalid.out
struct-member-if-invalid.err
struct-member-if-invalid.exit
struct-member-if-invalid.json
struct-member-if-invalid.out
struct-member-invalid-dict.err
struct-member-invalid-dict.exit
struct-member-invalid-dict.json
struct-member-invalid-dict.out
struct-member-invalid.err
struct-member-invalid.exit
struct-member-invalid.json
struct-member-invalid.out
sub-sub-module.json
test-qapi.py
trailing-comma-list.err
trailing-comma-list.exit
trailing-comma-list.json
trailing-comma-list.out
trailing-comma-object.err
trailing-comma-object.exit
trailing-comma-object.json
trailing-comma-object.out
type-bypass-bad-gen.err
type-bypass-bad-gen.exit
type-bypass-bad-gen.json
type-bypass-bad-gen.out
unclosed-list.err
unclosed-list.exit
unclosed-list.json
unclosed-list.out
unclosed-object.err
unclosed-object.exit
unclosed-object.json
unclosed-object.out
unclosed-string.err
unclosed-string.exit
unclosed-string.json
unclosed-string.out
union-base-empty.err
union-base-empty.exit
union-base-empty.json
union-base-empty.out
union-base-no-discriminator.err
union-base-no-discriminator.exit
union-base-no-discriminator.json
union-base-no-discriminator.out
union-branch-case.err
union-branch-case.exit
union-branch-case.json
union-branch-case.out
union-branch-if-invalid.err
union-branch-if-invalid.exit
union-branch-if-invalid.json
union-branch-if-invalid.out
union-branch-invalid-dict.err
union-branch-invalid-dict.exit
union-branch-invalid-dict.json
union-branch-invalid-dict.out
union-clash-branches.err
union-clash-branches.exit
union-clash-branches.json
union-clash-branches.out
union-empty.err
union-empty.exit
union-empty.json
union-empty.out
union-invalid-base.err
union-invalid-base.exit
union-invalid-base.json
union-invalid-base.out
union-optional-branch.err
union-optional-branch.exit
union-optional-branch.json
union-optional-branch.out
union-unknown.err
union-unknown.exit
union-unknown.json
union-unknown.out
unknown-escape.err
unknown-escape.exit
unknown-escape.json
unknown-escape.out
unknown-expr-key.err
unknown-expr-key.exit
unknown-expr-key.json
unknown-expr-key.out