thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
9ae3a8
From 6a72b8101fdaa33464d6f82e7a7963e4aa135f41 Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <6a72b8101fdaa33464d6f82e7a7963e4aa135f41.1387369730.git.minovotn@redhat.com>
9ae3a8
In-Reply-To: <091eecc4fa42754760dfff393dabcc2b444e9693.1387369730.git.minovotn@redhat.com>
9ae3a8
References: <091eecc4fa42754760dfff393dabcc2b444e9693.1387369730.git.minovotn@redhat.com>
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
Date: Tue, 10 Dec 2013 15:29:11 +0100
9ae3a8
Subject: [PATCH 11/21] tests: QAPI schema parser tests
9ae3a8
9ae3a8
RH-Author: Markus Armbruster <armbru@redhat.com>
9ae3a8
Message-id: <1386689361-30281-9-git-send-email-armbru@redhat.com>
9ae3a8
Patchwork-id: 56130
9ae3a8
O-Subject: [PATCH 7.0 qemu-kvm 08/18] tests: QAPI schema parser tests
9ae3a8
Bugzilla: 997915
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
9ae3a8
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
9ae3a8
The parser handles erroneous input badly.  To be improved shortly.
9ae3a8
9ae3a8
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
Message-id: 1374939721-7876-2-git-send-email-armbru@redhat.com
9ae3a8
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
9ae3a8
(cherry picked from commit 98626572f18ddc61c08588c32a1773bc91f8624e)
9ae3a8
---
9ae3a8
 configure                                      |  2 +-
9ae3a8
 tests/Makefile                                 | 24 ++++++++++++++++++++++--
9ae3a8
 tests/qapi-schema/comments.err                 |  0
9ae3a8
 tests/qapi-schema/comments.exit                |  1 +
9ae3a8
 tests/qapi-schema/comments.json                |  4 ++++
9ae3a8
 tests/qapi-schema/comments.out                 |  3 +++
9ae3a8
 tests/qapi-schema/empty.err                    |  0
9ae3a8
 tests/qapi-schema/empty.exit                   |  1 +
9ae3a8
 tests/qapi-schema/empty.json                   |  0
9ae3a8
 tests/qapi-schema/empty.out                    |  3 +++
9ae3a8
 tests/qapi-schema/funny-char.err               |  0
9ae3a8
 tests/qapi-schema/funny-char.exit              |  1 +
9ae3a8
 tests/qapi-schema/funny-char.json              |  2 ++
9ae3a8
 tests/qapi-schema/funny-char.out               |  3 +++
9ae3a8
 tests/qapi-schema/indented-expr.err            |  0
9ae3a8
 tests/qapi-schema/indented-expr.exit           |  1 +
9ae3a8
 tests/qapi-schema/indented-expr.json           |  2 ++
9ae3a8
 tests/qapi-schema/indented-expr.out            |  3 +++
9ae3a8
 tests/qapi-schema/missing-colon.err            |  0
9ae3a8
 tests/qapi-schema/missing-colon.exit           |  1 +
9ae3a8
 tests/qapi-schema/missing-colon.json           |  2 ++
9ae3a8
 tests/qapi-schema/missing-colon.out            |  3 +++
9ae3a8
 tests/qapi-schema/missing-comma-list.err       |  0
9ae3a8
 tests/qapi-schema/missing-comma-list.exit      |  1 +
9ae3a8
 tests/qapi-schema/missing-comma-list.json      |  2 ++
9ae3a8
 tests/qapi-schema/missing-comma-list.out       |  3 +++
9ae3a8
 tests/qapi-schema/missing-comma-object.err     |  0
9ae3a8
 tests/qapi-schema/missing-comma-object.exit    |  1 +
9ae3a8
 tests/qapi-schema/missing-comma-object.json    |  2 ++
9ae3a8
 tests/qapi-schema/missing-comma-object.out     |  3 +++
9ae3a8
 tests/qapi-schema/non-objects.err              |  1 +
9ae3a8
 tests/qapi-schema/non-objects.exit             |  1 +
9ae3a8
 tests/qapi-schema/non-objects.json             |  2 ++
9ae3a8
 tests/qapi-schema/non-objects.out              |  0
9ae3a8
 tests/qapi-schema/quoted-structural-chars.err  |  0
9ae3a8
 tests/qapi-schema/quoted-structural-chars.exit |  1 +
9ae3a8
 tests/qapi-schema/quoted-structural-chars.json |  1 +
9ae3a8
 tests/qapi-schema/quoted-structural-chars.out  |  3 +++
9ae3a8
 tests/qapi-schema/test-qapi.py                 | 25 +++++++++++++++++++++++++
9ae3a8
 tests/qapi-schema/trailing-comma-list.err      |  0
9ae3a8
 tests/qapi-schema/trailing-comma-list.exit     |  1 +
9ae3a8
 tests/qapi-schema/trailing-comma-list.json     |  2 ++
9ae3a8
 tests/qapi-schema/trailing-comma-list.out      |  3 +++
9ae3a8
 tests/qapi-schema/trailing-comma-object.err    |  0
9ae3a8
 tests/qapi-schema/trailing-comma-object.exit   |  1 +
9ae3a8
 tests/qapi-schema/trailing-comma-object.json   |  2 ++
9ae3a8
 tests/qapi-schema/trailing-comma-object.out    |  3 +++
9ae3a8
 tests/qapi-schema/unclosed-list.err            |  1 +
9ae3a8
 tests/qapi-schema/unclosed-list.exit           |  1 +
9ae3a8
 tests/qapi-schema/unclosed-list.json           |  1 +
9ae3a8
 tests/qapi-schema/unclosed-list.out            |  0
9ae3a8
 tests/qapi-schema/unclosed-object.err          |  1 +
9ae3a8
 tests/qapi-schema/unclosed-object.exit         |  1 +
9ae3a8
 tests/qapi-schema/unclosed-object.json         |  1 +
9ae3a8
 tests/qapi-schema/unclosed-object.out          |  0
9ae3a8
 tests/qapi-schema/unclosed-string.err          |  1 +
9ae3a8
 tests/qapi-schema/unclosed-string.exit         |  1 +
9ae3a8
 tests/qapi-schema/unclosed-string.json         |  2 ++
9ae3a8
 tests/qapi-schema/unclosed-string.out          |  0
9ae3a8
 59 files changed, 121 insertions(+), 3 deletions(-)
9ae3a8
 create mode 100644 tests/qapi-schema/comments.err
9ae3a8
 create mode 100644 tests/qapi-schema/comments.exit
9ae3a8
 create mode 100644 tests/qapi-schema/comments.json
9ae3a8
 create mode 100644 tests/qapi-schema/comments.out
9ae3a8
 create mode 100644 tests/qapi-schema/empty.err
9ae3a8
 create mode 100644 tests/qapi-schema/empty.exit
9ae3a8
 create mode 100644 tests/qapi-schema/empty.json
9ae3a8
 create mode 100644 tests/qapi-schema/empty.out
9ae3a8
 create mode 100644 tests/qapi-schema/funny-char.err
9ae3a8
 create mode 100644 tests/qapi-schema/funny-char.exit
9ae3a8
 create mode 100644 tests/qapi-schema/funny-char.json
9ae3a8
 create mode 100644 tests/qapi-schema/funny-char.out
9ae3a8
 create mode 100644 tests/qapi-schema/indented-expr.err
9ae3a8
 create mode 100644 tests/qapi-schema/indented-expr.exit
9ae3a8
 create mode 100644 tests/qapi-schema/indented-expr.json
9ae3a8
 create mode 100644 tests/qapi-schema/indented-expr.out
9ae3a8
 create mode 100644 tests/qapi-schema/missing-colon.err
9ae3a8
 create mode 100644 tests/qapi-schema/missing-colon.exit
9ae3a8
 create mode 100644 tests/qapi-schema/missing-colon.json
9ae3a8
 create mode 100644 tests/qapi-schema/missing-colon.out
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-list.err
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-list.exit
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-list.json
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-list.out
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-object.err
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-object.exit
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-object.json
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-object.out
9ae3a8
 create mode 100644 tests/qapi-schema/non-objects.err
9ae3a8
 create mode 100644 tests/qapi-schema/non-objects.exit
9ae3a8
 create mode 100644 tests/qapi-schema/non-objects.json
9ae3a8
 create mode 100644 tests/qapi-schema/non-objects.out
9ae3a8
 create mode 100644 tests/qapi-schema/quoted-structural-chars.err
9ae3a8
 create mode 100644 tests/qapi-schema/quoted-structural-chars.exit
9ae3a8
 create mode 100644 tests/qapi-schema/quoted-structural-chars.json
9ae3a8
 create mode 100644 tests/qapi-schema/quoted-structural-chars.out
9ae3a8
 create mode 100644 tests/qapi-schema/test-qapi.py
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-list.err
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-list.exit
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-list.json
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-list.out
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-object.err
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-object.exit
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-object.json
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-object.out
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-list.err
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-list.exit
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-list.json
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-list.out
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-object.err
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-object.exit
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-object.json
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-object.out
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-string.err
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-string.exit
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-string.json
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-string.out
9ae3a8
9ae3a8
diff --git a/tests/qapi-schema/unclosed-string.out b/tests/qapi-schema/unclosed-string.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
9ae3a8
Signed-off-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
---
9ae3a8
 configure                                      |  2 +-
9ae3a8
 tests/Makefile                                 | 24 ++++++++++++++++++++++--
9ae3a8
 tests/qapi-schema/comments.exit                |  1 +
9ae3a8
 tests/qapi-schema/comments.json                |  4 ++++
9ae3a8
 tests/qapi-schema/comments.out                 |  3 +++
9ae3a8
 tests/qapi-schema/empty.exit                   |  1 +
9ae3a8
 tests/qapi-schema/empty.out                    |  3 +++
9ae3a8
 tests/qapi-schema/funny-char.exit              |  1 +
9ae3a8
 tests/qapi-schema/funny-char.json              |  2 ++
9ae3a8
 tests/qapi-schema/funny-char.out               |  3 +++
9ae3a8
 tests/qapi-schema/indented-expr.exit           |  1 +
9ae3a8
 tests/qapi-schema/indented-expr.json           |  2 ++
9ae3a8
 tests/qapi-schema/indented-expr.out            |  3 +++
9ae3a8
 tests/qapi-schema/missing-colon.exit           |  1 +
9ae3a8
 tests/qapi-schema/missing-colon.json           |  2 ++
9ae3a8
 tests/qapi-schema/missing-colon.out            |  3 +++
9ae3a8
 tests/qapi-schema/missing-comma-list.exit      |  1 +
9ae3a8
 tests/qapi-schema/missing-comma-list.json      |  2 ++
9ae3a8
 tests/qapi-schema/missing-comma-list.out       |  3 +++
9ae3a8
 tests/qapi-schema/missing-comma-object.exit    |  1 +
9ae3a8
 tests/qapi-schema/missing-comma-object.json    |  2 ++
9ae3a8
 tests/qapi-schema/missing-comma-object.out     |  3 +++
9ae3a8
 tests/qapi-schema/non-objects.err              |  1 +
9ae3a8
 tests/qapi-schema/non-objects.exit             |  1 +
9ae3a8
 tests/qapi-schema/non-objects.json             |  2 ++
9ae3a8
 tests/qapi-schema/quoted-structural-chars.exit |  1 +
9ae3a8
 tests/qapi-schema/quoted-structural-chars.json |  1 +
9ae3a8
 tests/qapi-schema/quoted-structural-chars.out  |  3 +++
9ae3a8
 tests/qapi-schema/test-qapi.py                 | 25 +++++++++++++++++++++++++
9ae3a8
 tests/qapi-schema/trailing-comma-list.exit     |  1 +
9ae3a8
 tests/qapi-schema/trailing-comma-list.json     |  2 ++
9ae3a8
 tests/qapi-schema/trailing-comma-list.out      |  3 +++
9ae3a8
 tests/qapi-schema/trailing-comma-object.exit   |  1 +
9ae3a8
 tests/qapi-schema/trailing-comma-object.json   |  2 ++
9ae3a8
 tests/qapi-schema/trailing-comma-object.out    |  3 +++
9ae3a8
 tests/qapi-schema/unclosed-list.err            |  1 +
9ae3a8
 tests/qapi-schema/unclosed-list.exit           |  1 +
9ae3a8
 tests/qapi-schema/unclosed-list.json           |  1 +
9ae3a8
 tests/qapi-schema/unclosed-object.err          |  1 +
9ae3a8
 tests/qapi-schema/unclosed-object.exit         |  1 +
9ae3a8
 tests/qapi-schema/unclosed-object.json         |  1 +
9ae3a8
 tests/qapi-schema/unclosed-string.err          |  1 +
9ae3a8
 tests/qapi-schema/unclosed-string.exit         |  1 +
9ae3a8
 tests/qapi-schema/unclosed-string.json         |  2 ++
9ae3a8
 44 files changed, 121 insertions(+), 3 deletions(-)
9ae3a8
 create mode 100644 tests/qapi-schema/comments.err
9ae3a8
 create mode 100644 tests/qapi-schema/comments.exit
9ae3a8
 create mode 100644 tests/qapi-schema/comments.json
9ae3a8
 create mode 100644 tests/qapi-schema/comments.out
9ae3a8
 create mode 100644 tests/qapi-schema/empty.err
9ae3a8
 create mode 100644 tests/qapi-schema/empty.exit
9ae3a8
 create mode 100644 tests/qapi-schema/empty.json
9ae3a8
 create mode 100644 tests/qapi-schema/empty.out
9ae3a8
 create mode 100644 tests/qapi-schema/funny-char.err
9ae3a8
 create mode 100644 tests/qapi-schema/funny-char.exit
9ae3a8
 create mode 100644 tests/qapi-schema/funny-char.json
9ae3a8
 create mode 100644 tests/qapi-schema/funny-char.out
9ae3a8
 create mode 100644 tests/qapi-schema/indented-expr.err
9ae3a8
 create mode 100644 tests/qapi-schema/indented-expr.exit
9ae3a8
 create mode 100644 tests/qapi-schema/indented-expr.json
9ae3a8
 create mode 100644 tests/qapi-schema/indented-expr.out
9ae3a8
 create mode 100644 tests/qapi-schema/missing-colon.err
9ae3a8
 create mode 100644 tests/qapi-schema/missing-colon.exit
9ae3a8
 create mode 100644 tests/qapi-schema/missing-colon.json
9ae3a8
 create mode 100644 tests/qapi-schema/missing-colon.out
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-list.err
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-list.exit
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-list.json
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-list.out
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-object.err
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-object.exit
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-object.json
9ae3a8
 create mode 100644 tests/qapi-schema/missing-comma-object.out
9ae3a8
 create mode 100644 tests/qapi-schema/non-objects.err
9ae3a8
 create mode 100644 tests/qapi-schema/non-objects.exit
9ae3a8
 create mode 100644 tests/qapi-schema/non-objects.json
9ae3a8
 create mode 100644 tests/qapi-schema/non-objects.out
9ae3a8
 create mode 100644 tests/qapi-schema/quoted-structural-chars.err
9ae3a8
 create mode 100644 tests/qapi-schema/quoted-structural-chars.exit
9ae3a8
 create mode 100644 tests/qapi-schema/quoted-structural-chars.json
9ae3a8
 create mode 100644 tests/qapi-schema/quoted-structural-chars.out
9ae3a8
 create mode 100644 tests/qapi-schema/test-qapi.py
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-list.err
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-list.exit
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-list.json
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-list.out
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-object.err
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-object.exit
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-object.json
9ae3a8
 create mode 100644 tests/qapi-schema/trailing-comma-object.out
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-list.err
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-list.exit
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-list.json
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-list.out
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-object.err
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-object.exit
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-object.json
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-object.out
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-string.err
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-string.exit
9ae3a8
 create mode 100644 tests/qapi-schema/unclosed-string.json
9ae3a8
9ae3a8
diff --git a/configure b/configure
9ae3a8
index f86793d..0a729ac 100755
9ae3a8
--- a/configure
9ae3a8
+++ b/configure
9ae3a8
@@ -4511,7 +4511,7 @@ if [ "$dtc_internal" = "yes" ]; then
9ae3a8
 fi
9ae3a8
 
9ae3a8
 # build tree in object directory in case the source is not in the current directory
9ae3a8
-DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos"
9ae3a8
+DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema"
9ae3a8
 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
9ae3a8
 DIRS="$DIRS roms/seabios roms/vgabios"
9ae3a8
 DIRS="$DIRS qapi-generated"
9ae3a8
diff --git a/tests/Makefile b/tests/Makefile
9ae3a8
index 2e9093e..e96982b 100644
9ae3a8
--- a/tests/Makefile
9ae3a8
+++ b/tests/Makefile
9ae3a8
@@ -70,6 +70,14 @@ gcov-files-sparc64-y += hw/m48t59.c
9ae3a8
 check-qtest-arm-y = tests/tmp105-test$(EXESUF)
9ae3a8
 gcov-files-arm-y += hw/tmp105.c
9ae3a8
 
9ae3a8
+check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
9ae3a8
+        comments.json empty.json funny-char.json indented-expr.json \
9ae3a8
+        missing-colon.json missing-comma-list.json \
9ae3a8
+        missing-comma-object.json non-objects.json \
9ae3a8
+        quoted-structural-chars.json \
9ae3a8
+        trailing-comma-list.json trailing-comma-object.json \
9ae3a8
+        unclosed-list.json unclosed-object.json unclosed-string.json)
9ae3a8
+
9ae3a8
 GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h
9ae3a8
 
9ae3a8
 test-obj-y = tests/check-qint.o tests/check-qstring.o tests/check-qdict.o \
9ae3a8
@@ -157,6 +165,7 @@ check-help:
9ae3a8
 	@echo " make check-qtest-TARGET   Run qtest tests for given target"
9ae3a8
 	@echo " make check-qtest          Run qtest tests"
9ae3a8
 	@echo " make check-unit           Run qobject tests"
9ae3a8
+	@echo " make check-qapi-schema    Run QAPI schema tests"
9ae3a8
 	@echo " make check-block          Run block tests"
9ae3a8
 	@echo " make check-report.html    Generates an HTML test report"
9ae3a8
 	@echo
9ae3a8
@@ -219,12 +228,23 @@ check-report.html: check-report.xml
9ae3a8
 check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) qemu-io$(EXESUF)
9ae3a8
 	$<
9ae3a8
 
9ae3a8
+.PHONY: check-tests/test-qapi.py
9ae3a8
+check-tests/test-qapi.py: tests/test-qapi.py
9ae3a8
+
9ae3a8
+.PHONY: $(patsubst %, check-%, $(check-qapi-schema-y))
9ae3a8
+$(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
9ae3a8
+	$(call quiet-command, PYTHONPATH=$(SRC_PATH)/scripts $(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py <$^ >$*.out 2>$*.err; echo $$? >$*.exit, "  TEST  $*.out")
9ae3a8
+	@diff -q $(SRC_PATH)/$*.out $*.out
9ae3a8
+	@diff -q $(SRC_PATH)/$*.err $*.err
9ae3a8
+	@diff -q $(SRC_PATH)/$*.exit $*.exit
9ae3a8
+
9ae3a8
 # Consolidated targets
9ae3a8
 
9ae3a8
-.PHONY: check-qtest check-unit check
9ae3a8
+.PHONY: check-qapi-schema check-qtest check-unit check
9ae3a8
+check-qapi-schema: $(patsubst %,check-%, $(check-qapi-schema-y))
9ae3a8
 check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
9ae3a8
 check-unit: $(patsubst %,check-%, $(check-unit-y))
9ae3a8
 check-block: $(patsubst %,check-%, $(check-block-y))
9ae3a8
-check: check-unit check-qtest
9ae3a8
+check: check-qapi-schema check-unit check-qtest
9ae3a8
 
9ae3a8
 -include $(wildcard tests/*.d)
9ae3a8
diff --git a/tests/qapi-schema/comments.err b/tests/qapi-schema/comments.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/comments.exit b/tests/qapi-schema/comments.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..573541a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/comments.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+0
9ae3a8
diff --git a/tests/qapi-schema/comments.json b/tests/qapi-schema/comments.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e643f3a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/comments.json
9ae3a8
@@ -0,0 +1,4 @@
9ae3a8
+# Unindented comment
9ae3a8
+{ 'enum': 'Status',             # Comment to the right of code
9ae3a8
+  # Indented comment
9ae3a8
+  'data': [ 'good', 'bad', 'ugly' ] }
9ae3a8
diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e3bd904
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/comments.out
9ae3a8
@@ -0,0 +1,3 @@
9ae3a8
+[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
9ae3a8
+['Status']
9ae3a8
+[]
9ae3a8
diff --git a/tests/qapi-schema/empty.err b/tests/qapi-schema/empty.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/empty.exit b/tests/qapi-schema/empty.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..573541a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/empty.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+0
9ae3a8
diff --git a/tests/qapi-schema/empty.json b/tests/qapi-schema/empty.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..b7f89a4
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/empty.out
9ae3a8
@@ -0,0 +1,3 @@
9ae3a8
+[]
9ae3a8
+[]
9ae3a8
+[]
9ae3a8
diff --git a/tests/qapi-schema/funny-char.err b/tests/qapi-schema/funny-char.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/funny-char.exit b/tests/qapi-schema/funny-char.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..573541a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/funny-char.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+0
9ae3a8
diff --git a/tests/qapi-schema/funny-char.json b/tests/qapi-schema/funny-char.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..d4973a2
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/funny-char.json
9ae3a8
@@ -0,0 +1,2 @@
9ae3a8
+{ 'enum': 'Status',
9ae3a8
+  'data': [ 'good', 'bad', 'ugly' ]; }
9ae3a8
diff --git a/tests/qapi-schema/funny-char.out b/tests/qapi-schema/funny-char.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e3bd904
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/funny-char.out
9ae3a8
@@ -0,0 +1,3 @@
9ae3a8
+[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
9ae3a8
+['Status']
9ae3a8
+[]
9ae3a8
diff --git a/tests/qapi-schema/indented-expr.err b/tests/qapi-schema/indented-expr.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/indented-expr.exit b/tests/qapi-schema/indented-expr.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..573541a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/indented-expr.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+0
9ae3a8
diff --git a/tests/qapi-schema/indented-expr.json b/tests/qapi-schema/indented-expr.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..d80af60
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/indented-expr.json
9ae3a8
@@ -0,0 +1,2 @@
9ae3a8
+{ 'id' : 'eins' }
9ae3a8
+ { 'id' : 'zwei' }
9ae3a8
diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indented-expr.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..98ae692
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/indented-expr.out
9ae3a8
@@ -0,0 +1,3 @@
9ae3a8
+[OrderedDict([('id', 'eins')])]
9ae3a8
+[]
9ae3a8
+[]
9ae3a8
diff --git a/tests/qapi-schema/missing-colon.err b/tests/qapi-schema/missing-colon.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/missing-colon.exit b/tests/qapi-schema/missing-colon.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..573541a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/missing-colon.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+0
9ae3a8
diff --git a/tests/qapi-schema/missing-colon.json b/tests/qapi-schema/missing-colon.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..6fc27ce
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/missing-colon.json
9ae3a8
@@ -0,0 +1,2 @@
9ae3a8
+{ 'enum' 'Status',
9ae3a8
+  'data': [ 'good', 'bad', 'ugly' ] }
9ae3a8
diff --git a/tests/qapi-schema/missing-colon.out b/tests/qapi-schema/missing-colon.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..50f827e
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/missing-colon.out
9ae3a8
@@ -0,0 +1,3 @@
9ae3a8
+[OrderedDict([('enum', ','), ('data', ['good', 'bad', 'ugly'])])]
9ae3a8
+[',']
9ae3a8
+[]
9ae3a8
diff --git a/tests/qapi-schema/missing-comma-list.err b/tests/qapi-schema/missing-comma-list.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/missing-comma-list.exit b/tests/qapi-schema/missing-comma-list.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..573541a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/missing-comma-list.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+0
9ae3a8
diff --git a/tests/qapi-schema/missing-comma-list.json b/tests/qapi-schema/missing-comma-list.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..1af39b2
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/missing-comma-list.json
9ae3a8
@@ -0,0 +1,2 @@
9ae3a8
+{ 'enum': 'Status',
9ae3a8
+  'data': [ 'good' 'bad', 'ugly' ] }
9ae3a8
diff --git a/tests/qapi-schema/missing-comma-list.out b/tests/qapi-schema/missing-comma-list.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e3bd904
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/missing-comma-list.out
9ae3a8
@@ -0,0 +1,3 @@
9ae3a8
+[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
9ae3a8
+['Status']
9ae3a8
+[]
9ae3a8
diff --git a/tests/qapi-schema/missing-comma-object.err b/tests/qapi-schema/missing-comma-object.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/missing-comma-object.exit b/tests/qapi-schema/missing-comma-object.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..573541a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/missing-comma-object.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+0
9ae3a8
diff --git a/tests/qapi-schema/missing-comma-object.json b/tests/qapi-schema/missing-comma-object.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..50f5178
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/missing-comma-object.json
9ae3a8
@@ -0,0 +1,2 @@
9ae3a8
+{ 'enum': 'Status'
9ae3a8
+  'data': [ 'good', 'bad', 'ugly' ] }
9ae3a8
diff --git a/tests/qapi-schema/missing-comma-object.out b/tests/qapi-schema/missing-comma-object.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e3bd904
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/missing-comma-object.out
9ae3a8
@@ -0,0 +1,3 @@
9ae3a8
+[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
9ae3a8
+['Status']
9ae3a8
+[]
9ae3a8
diff --git a/tests/qapi-schema/non-objects.err b/tests/qapi-schema/non-objects.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..48c849d
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/non-objects.err
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+Crashed: <type 'exceptions.AttributeError'>
9ae3a8
diff --git a/tests/qapi-schema/non-objects.exit b/tests/qapi-schema/non-objects.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..d00491f
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/non-objects.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+1
9ae3a8
diff --git a/tests/qapi-schema/non-objects.json b/tests/qapi-schema/non-objects.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..f3fa851
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/non-objects.json
9ae3a8
@@ -0,0 +1,2 @@
9ae3a8
+'string'
9ae3a8
+[ ]
9ae3a8
diff --git a/tests/qapi-schema/non-objects.out b/tests/qapi-schema/non-objects.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/quoted-structural-chars.err b/tests/qapi-schema/quoted-structural-chars.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/quoted-structural-chars.exit b/tests/qapi-schema/quoted-structural-chars.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..573541a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/quoted-structural-chars.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+0
9ae3a8
diff --git a/tests/qapi-schema/quoted-structural-chars.json b/tests/qapi-schema/quoted-structural-chars.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..9fe657a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/quoted-structural-chars.json
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+'{' 'key1' ':' 'value1' ',' 'key2' ':' '[' ']' '}'
9ae3a8
diff --git a/tests/qapi-schema/quoted-structural-chars.out b/tests/qapi-schema/quoted-structural-chars.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..85405be
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/quoted-structural-chars.out
9ae3a8
@@ -0,0 +1,3 @@
9ae3a8
+[OrderedDict([('key1', 'value1'), ('key2', [])])]
9ae3a8
+[]
9ae3a8
+[]
9ae3a8
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
9ae3a8
new file mode 100644
9ae3a8
index 0000000..3280eff
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/test-qapi.py
9ae3a8
@@ -0,0 +1,25 @@
9ae3a8
+#
9ae3a8
+# QAPI parser test harness
9ae3a8
+#
9ae3a8
+# Copyright (c) 2013 Red Hat Inc.
9ae3a8
+#
9ae3a8
+# Authors:
9ae3a8
+#  Markus Armbruster <armbru@redhat.com>
9ae3a8
+#
9ae3a8
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
9ae3a8
+# See the COPYING file in the top-level directory.
9ae3a8
+#
9ae3a8
+
9ae3a8
+from qapi import *
9ae3a8
+from pprint import pprint
9ae3a8
+import sys
9ae3a8
+
9ae3a8
+try:
9ae3a8
+    exprs = parse_schema(sys.stdin)
9ae3a8
+except:
9ae3a8
+    print >>sys.stderr, "Crashed:", sys.exc_info()[0]
9ae3a8
+    exit(1)
9ae3a8
+
9ae3a8
+pprint(exprs)
9ae3a8
+pprint(enum_types)
9ae3a8
+pprint(struct_types)
9ae3a8
diff --git a/tests/qapi-schema/trailing-comma-list.err b/tests/qapi-schema/trailing-comma-list.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/trailing-comma-list.exit b/tests/qapi-schema/trailing-comma-list.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..573541a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/trailing-comma-list.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+0
9ae3a8
diff --git a/tests/qapi-schema/trailing-comma-list.json b/tests/qapi-schema/trailing-comma-list.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..9b0c8bd
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/trailing-comma-list.json
9ae3a8
@@ -0,0 +1,2 @@
9ae3a8
+{ 'enum': 'Status',
9ae3a8
+  'data': [ 'good', 'bad', 'ugly', ] }
9ae3a8
diff --git a/tests/qapi-schema/trailing-comma-list.out b/tests/qapi-schema/trailing-comma-list.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e3bd904
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/trailing-comma-list.out
9ae3a8
@@ -0,0 +1,3 @@
9ae3a8
+[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
9ae3a8
+['Status']
9ae3a8
+[]
9ae3a8
diff --git a/tests/qapi-schema/trailing-comma-object.err b/tests/qapi-schema/trailing-comma-object.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/trailing-comma-object.exit b/tests/qapi-schema/trailing-comma-object.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..573541a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/trailing-comma-object.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+0
9ae3a8
diff --git a/tests/qapi-schema/trailing-comma-object.json b/tests/qapi-schema/trailing-comma-object.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..bbaea55
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/trailing-comma-object.json
9ae3a8
@@ -0,0 +1,2 @@
9ae3a8
+{ 'enum': 'Status',
9ae3a8
+  'data': [ 'good', 'bad', 'ugly' ], }
9ae3a8
diff --git a/tests/qapi-schema/trailing-comma-object.out b/tests/qapi-schema/trailing-comma-object.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e3bd904
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/trailing-comma-object.out
9ae3a8
@@ -0,0 +1,3 @@
9ae3a8
+[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
9ae3a8
+['Status']
9ae3a8
+[]
9ae3a8
diff --git a/tests/qapi-schema/unclosed-list.err b/tests/qapi-schema/unclosed-list.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..f9a9c2a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/unclosed-list.err
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+Crashed: <type 'exceptions.IndexError'>
9ae3a8
diff --git a/tests/qapi-schema/unclosed-list.exit b/tests/qapi-schema/unclosed-list.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..d00491f
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/unclosed-list.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+1
9ae3a8
diff --git a/tests/qapi-schema/unclosed-list.json b/tests/qapi-schema/unclosed-list.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e3e9566
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/unclosed-list.json
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+{ 'key': [ 'value' }
9ae3a8
diff --git a/tests/qapi-schema/unclosed-list.out b/tests/qapi-schema/unclosed-list.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/unclosed-object.err b/tests/qapi-schema/unclosed-object.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..f9a9c2a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/unclosed-object.err
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+Crashed: <type 'exceptions.IndexError'>
9ae3a8
diff --git a/tests/qapi-schema/unclosed-object.exit b/tests/qapi-schema/unclosed-object.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..d00491f
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/unclosed-object.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+1
9ae3a8
diff --git a/tests/qapi-schema/unclosed-object.json b/tests/qapi-schema/unclosed-object.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..8ac069d
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/unclosed-object.json
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+{ 'key': [ 'value' ]
9ae3a8
diff --git a/tests/qapi-schema/unclosed-object.out b/tests/qapi-schema/unclosed-object.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..e69de29
9ae3a8
diff --git a/tests/qapi-schema/unclosed-string.err b/tests/qapi-schema/unclosed-string.err
9ae3a8
new file mode 100644
9ae3a8
index 0000000..5af46c2
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/unclosed-string.err
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+Crashed: <type 'exceptions.Exception'>
9ae3a8
diff --git a/tests/qapi-schema/unclosed-string.exit b/tests/qapi-schema/unclosed-string.exit
9ae3a8
new file mode 100644
9ae3a8
index 0000000..d00491f
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/unclosed-string.exit
9ae3a8
@@ -0,0 +1 @@
9ae3a8
+1
9ae3a8
diff --git a/tests/qapi-schema/unclosed-string.json b/tests/qapi-schema/unclosed-string.json
9ae3a8
new file mode 100644
9ae3a8
index 0000000..8c16b6b
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qapi-schema/unclosed-string.json
9ae3a8
@@ -0,0 +1,2 @@
9ae3a8
+{ 'text': 'lorem ips
9ae3a8
+}
9ae3a8
-- 
9ae3a8
1.7.11.7
9ae3a8