diff options
| author | Manuel Stoeckl <code@mstoeckl.com> | 2019-04-13 18:33:06 -0400 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2019-05-02 17:42:59 +0000 |
| commit | 6db761d16229084e576848967402d30b656e2dbf (patch) | |
| tree | 50cc136688ac2fe8475171c307f0c522a7e3a847 /tests | |
| parent | scanner: error when element names will not compile (diff) | |
| download | wayland-6db761d16229084e576848967402d30b656e2dbf.tar wayland-6db761d16229084e576848967402d30b656e2dbf.tar.gz wayland-6db761d16229084e576848967402d30b656e2dbf.tar.bz2 wayland-6db761d16229084e576848967402d30b656e2dbf.tar.lz wayland-6db761d16229084e576848967402d30b656e2dbf.tar.xz wayland-6db761d16229084e576848967402d30b656e2dbf.tar.zst wayland-6db761d16229084e576848967402d30b656e2dbf.zip | |
tests: Verify that wayland_scanner can catch bad identifiers
The test runs wayland_scanner on a set of XML protocol files which
have malformed element names, and confirms that an error is produced
and indicates the correct line.
Copyright notifications are not included in the test files, as
they are not code; of course, the project license still applies.
Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/data/bad-identifier-arg.xml | 10 | ||||
| -rw-r--r-- | tests/data/bad-identifier-entry.xml | 11 | ||||
| -rw-r--r-- | tests/data/bad-identifier-enum.xml | 10 | ||||
| -rw-r--r-- | tests/data/bad-identifier-event.xml | 8 | ||||
| -rw-r--r-- | tests/data/bad-identifier-interface.xml | 8 | ||||
| -rw-r--r-- | tests/data/bad-identifier-protocol.xml | 8 | ||||
| -rw-r--r-- | tests/data/bad-identifier-request.xml | 10 | ||||
| -rwxr-xr-x | tests/scanner-test.sh | 23 |
8 files changed, 88 insertions, 0 deletions
diff --git a/tests/data/bad-identifier-arg.xml b/tests/data/bad-identifier-arg.xml new file mode 100644 index 0000000..ac2a6b7 --- /dev/null +++ b/tests/data/bad-identifier-arg.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="the_protocol"> + <interface name="the_interface" version="1"> + <description summary="the summary"> + </description> + <request name="the_request"> + <arg name="" type="uint"/> + </request> + </interface> +</protocol> diff --git a/tests/data/bad-identifier-entry.xml b/tests/data/bad-identifier-entry.xml new file mode 100644 index 0000000..6ea2fae --- /dev/null +++ b/tests/data/bad-identifier-entry.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="the_protocol"> + <interface name="the_interface" version="1"> + <description summary="the summary"> + </description> + <enum name="4the_enum"> + <entry name="60_seconds" value="1" summary="this is the first"/> + <entry name="invalid entry" value="2" summary="this is the first"/> + </enum> + </interface> +</protocol> diff --git a/tests/data/bad-identifier-enum.xml b/tests/data/bad-identifier-enum.xml new file mode 100644 index 0000000..3225384 --- /dev/null +++ b/tests/data/bad-identifier-enum.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="the_protocol"> + <interface name="the_interface" version="1"> + <description summary="the summary"> + </description> + <enum name="the-enum"> + <entry name="the_entry" value="0" summary="entry summary"/> + </enum> + </interface> +</protocol> diff --git a/tests/data/bad-identifier-event.xml b/tests/data/bad-identifier-event.xml new file mode 100644 index 0000000..9708e3b --- /dev/null +++ b/tests/data/bad-identifier-event.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="the_protocol"> + <interface name="the_interface" version="1"> + <description summary="the summary"> + </description> + <event name="theΔevent"/> + </interface> +</protocol> diff --git a/tests/data/bad-identifier-interface.xml b/tests/data/bad-identifier-interface.xml new file mode 100644 index 0000000..17404c5 --- /dev/null +++ b/tests/data/bad-identifier-interface.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="the_protocol"> + <interface name="inter face" version="1"> + <description summary="the summary"> + </description> + <event name="the_event"/> + </interface> +</protocol> diff --git a/tests/data/bad-identifier-protocol.xml b/tests/data/bad-identifier-protocol.xml new file mode 100644 index 0000000..7a17204 --- /dev/null +++ b/tests/data/bad-identifier-protocol.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="1badprotocol"> + <interface name="required_interface" version="13"> + <description summary="required summary"> + </description> + <event name="requied_event"/> + </interface> +</protocol> diff --git a/tests/data/bad-identifier-request.xml b/tests/data/bad-identifier-request.xml new file mode 100644 index 0000000..a68c8aa --- /dev/null +++ b/tests/data/bad-identifier-request.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="the_protocol"> + <interface name="the_interface" version="1"> + <description summary="the summary"> + </description> + <request name="req-west"> + <arg name="the_arg" type="uint"/> + </request> + </interface> +</protocol> diff --git a/tests/scanner-test.sh b/tests/scanner-test.sh index ff25089..35ba047 100755 --- a/tests/scanner-test.sh +++ b/tests/scanner-test.sh @@ -36,6 +36,20 @@ generate_and_compare() { fail "$2 -> $3" } +verify_error() { + echo + echo "Checking that reading $1 gives an error on line $3" + + [ -f "$TEST_DATA_DIR/$1" ] || hard_fail "$1 not present" + + # Confirm failure error code + "$WAYLAND_SCANNER" server-header < "$TEST_DATA_DIR/$1" >/dev/null 2>"$TEST_OUTPUT_DIR/$2" && \ + fail "$1 return code check" + + # Verify that an error is produced at the correct line + grep -q "<stdin>:$3: error:" "$TEST_OUTPUT_DIR/$2" && echo "$1 PASS" || fail "$1 line number check" +} + generate_and_compare "code" "example.xml" "example-code.c" generate_and_compare "client-header" "example.xml" "example-client.h" generate_and_compare "server-header" "example.xml" "example-server.h" @@ -52,4 +66,13 @@ generate_and_compare "-c server-header" "small.xml" "small-server-core.h" generate_and_compare "code" "small.xml" "small-code.c" generate_and_compare "public-code" "small.xml" "small-code.c" generate_and_compare "private-code" "small.xml" "small-private-code.c" + +verify_error "bad-identifier-arg.xml" "bad-identifier-arg.log" 7 +verify_error "bad-identifier-entry.xml" "bad-identifier-entry.log" 8 +verify_error "bad-identifier-enum.xml" "bad-identifier-enum.log" 6 +verify_error "bad-identifier-event.xml" "bad-identifier-event.log" 6 +verify_error "bad-identifier-interface.xml" "bad-identifier-interface.log" 3 +verify_error "bad-identifier-protocol.xml" "bad-identifier-protocol.log" 2 +verify_error "bad-identifier-request.xml" "bad-identifier-request.log" 6 + exit $RETCODE |
