aboutsummaryrefslogtreecommitdiffstats
path: root/tests/data
Commit message (Collapse)AuthorAgeFilesLines
* scanner: use separate guards for validator functionsSimon Ser2025-02-233-28/+140
| | | | | | | | | | | | | | Generated XXX_is_valid() functions for enums are guarded behind the same #define as the enum itself. This worked fine until recently, but since fbd7460737c9 ("scanner: add new enum-header mode") we're also generating enum-only headers. When including the enum-only header first, and then the server header, the validator functions are missing. Define a separate guard to fix this. Signed-off-by: Simon Ser <contact@emersion.fr>
* tests: add enum bitfield testSimon Ser2024-07-095-0/+135
| | | | Signed-off-by: Simon Ser <contact@emersion.fr>
* scanner: fix validator for bitfieldsSimon Ser2024-07-091-58/+48
| | | | | | | Bitfields are valid if the value only contains bits inside of the supported entries for the given version. Signed-off-by: Simon Ser <contact@emersion.fr>
* tests: add deprecated-since attributesSimon Ser2024-04-248-3/+105
| | | | | | | Add a new event and enum entry to small.xml with a deprecated-since attribute to exercise the scanner code generation. Signed-off-by: Simon Ser <contact@emersion.fr>
* scanner: add validators for enumsSimon Ser2024-04-2311-0/+674
| | | | | | | | | | | | | | Right now compositors need to manually check that enum values sent by the client are valid. In particular: - Check that the value sent by the client is not outside of the enum. - Check that the version of the enum entry is consistent with the object version. Automatically generate validator functions to perform these tasks. Signed-off-by: Simon Ser <contact@emersion.fr> Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/104
* tests: add scanner test for enum-headerSimon Ser2024-03-281-0/+836
| | | | Signed-off-by: Simon Ser <contact@emersion.fr>
* util: fix undefined behavior in wl_array_for_eachDavid Benjamin2024-03-244-0/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | If a wl_array has size zero, wl_array_for_each computes NULL + 0 to get to the end pointer. This should be fine, and indeed it would be fine in C++. But the C specification has a mistake here and it is actually undefined behavior. See https://davidben.net/2024/01/15/empty-slices.html Clang's -fsanitize=undefined flags this. I ran into this in Chromium's build with wayland-scanner on one of our XML files. ../../third_party/wayland/src/src/scanner.c:1853:2: runtime error: applying zero offset to null pointer #0 0x55c979b8e02c in emit_code third_party/wayland/src/src/scanner.c:1853:2 #1 0x55c979b89323 in main third_party/wayland/src/src/scanner.c #2 0x7f8dfdb8c6c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #3 0x7f8dfdb8c784 in __libc_start_main csu/../csu/libc-start.c:360:3 #4 0x55c979b70f39 in _start (...) An empty XML file is sufficient to hit this case, so I've added it as a test. To reproduce, undo the fix and include only the test, then build with: CC=clang CFLAGS="-fno-sanitize-recover=undefined" meson build/ -Db_sanitize=undefined -Db_lundef=false ninja -C build test Signed-off-by: David Benjamin <davidben@google.com>
* build: add a gen-scanner-test targetSimon Ser2024-01-151-0/+3
| | | | | | | | This adds a command to re-generate the test data. This needs to be done when either an XML source file or the scanner's output is changed. Signed-off-by: Simon Ser <contact@emersion.fr>
* doc: fix typo in wl_data_device.data_offershierote2022-01-102-2/+2
| | | | Signed-off-by: Taishi Eguchi <taishi2060@gmail.com>
* scanner: Use the new atomic marshal/destroy functionDerek Foreman2021-08-073-172/+140
| | | | | | | | | | | | | | | | Use the new flagged marshal+destroy function in generated code. It's intended as a replacement for all existing wl_proxy_marshal_* functions, so I've used it to replace them all. This results in a large update to the scanner test files as well. We now pass the new WL_MARSHAL_FLAG_DESTROY flag when appropriate, so the race condition in #86 caused by releasing the display mutex between marshalling the proxy and destroying the proxy is now gone. Fixes #86 Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* tests: Test wayland-scanner with a description in an entryJames Legg2021-07-073-32/+34
| | | | | | | | | This previously would have caused a memory leak and incorrect comments. Signed-off-by: James Legg <lankyleggy@gmail.com> Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
* Replace initial 8 spaces with a tab for all xml filesPeter Hutterer2020-04-291-3/+3
| | | | | | | | | This is the style used in wayland.xml which is the only file we really care about for git blame information. So let's adjust all others to that style for consistency and fix editorconfig to avoid messing this up in the future. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* scanner: Guard interface declarationsGuido Günther2020-04-236-0/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows to include client and server headers in the same file fixing warnings like In file included from ../subprojects/wlroots/include/wlr/types/wlr_layer_shell_v1.h:16, from ../src/desktop.h:16, from ../src/server.h:13, from ../tests/testlib.c:8: tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-protocol.h:80:34: warning: redundant redeclaration of ‘zwlr_layer_shell_v1_interface’ [-Wredundant-decls] 80 | extern const struct wl_interface zwlr_layer_shell_v1_interface; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../tests/testlib.h:8, from ../tests/testlib.c:7: tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-client-protocol.h:77:34: note: previous declaration of ‘zwlr_layer_shell_v1_interface’ was here 77 | extern const struct wl_interface zwlr_layer_shell_v1_interface; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../subprojects/wlroots/include/wlr/types/wlr_layer_shell_v1.h:16, from ../src/desktop.h:16, from ../src/server.h:13, from ../tests/testlib.c:8: tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-protocol.h:106:34: warning: redundant redeclaration of ‘zwlr_layer_surface_v1_interface’ [-Wredundant-decls] 106 | extern const struct wl_interface zwlr_layer_surface_v1_interface; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../tests/testlib.h:8, from ../tests/testlib.c:7: tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-client-protocol.h:103:34: note: previous declaration of ‘zwlr_layer_surface_v1_interface’ was here 103 | extern const struct wl_interface zwlr_layer_surface_v1_interface; Signed-off-by: Guido Günther <agx@sigxcpu.org> Closes: #158
* scanner: prepend protocol name to types symbolMarty E. Plummer2019-09-114-135/+135
| | | | | | | | | | When doing unity builds via meson (example project: https://github.com/swaywm/sway) multiple source files are glued together via #include directives. Having every wayland-scanner generated source file have an identifier named '*types[]' will lead to errors in these unity builds if two or more of these are joined. Signed-off-by: Marty E. Plummer <hanetzer@startmail.com>
* tests: Verify that wayland_scanner can catch bad identifiersManuel Stoeckl2019-05-027-0/+65
| | | | | | | | | | | 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>
* tests: fix scanner private-code test reference dataPekka Paalanen2018-02-261-1/+1
| | | | | | | | | | | Commit e501230d1dc8a5015616e104ec0e08886a0b88df "scanner: Fix broken private-code generation" changed the scanner output without updating the reference output for scanner tests. Update the reference data. This fixes 'make check'. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
* tests: add code, public-code and private-code testsEmil Velikov2018-02-221-0/+71
| | | | | | | | | | | | | | First one is deprecated in favour of the second option. The latter is newly introduced and annotates the generated symbols accordingly. v2: Don't introduce small-public-code.c - reuse small-code.c (Pekka) Cc: Pekka Paalanen <ppaalanen@gmail.com> Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
* protocol: add axis_source.wheel_tiltPeter Hutterer2017-01-243-2/+35
| | | | | | | | | | | | Unlike a wheel rotation, a wheel tilt is a discrete-only axis. Wheel rotations are mapped to degrees in libinput but that that does not apply to wheel tilt axes where there is no physical equivalent. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com> Acked-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
* scanner: support "since" attribute for enum entriesPeter Hutterer2017-01-247-3/+101
| | | | | | | | | | | | | | | | | | | This was already in the DTD but not supported by the scanner. The check for ever-increasing "since" tags is not strictly required for enum entries as we control the binary value. But it keeps the xml file in good order, preventing things like: <entry name="first" value="…" /> <entry name="second" value="…" since="3"/> <entry name="third" value="…" since="2"/> <entry name="fourth" value="…" since="3"/> If this is undesirable in the future the check can be removed without side-effects. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* tests: sync example.xml with wayland.xmlPeter Hutterer2017-01-244-112/+294
| | | | | | | | | | | | | | | These are the protocol.xml changes from: 66a26aeb2a: protocol: Remove inconsistent line breaks a26ed0949e: protocol: indentation fixes 6a18a87727: protocol: Extend wl_touch with touchpoint shape and orientation and a few other, smaller ones. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Yong Bakos <ybakos@humanoriented.com> Tested-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* tests: add data files for future wayland-scanner testPekka Paalanen2016-11-2311-0/+13740
This patch adds the input and reference output data files for the wayland-scanner tests to be added by the following patch. The data files are split into their own patch because they are extremely uninteresting to review: - example.xml is just a copy wayland.xml from 1.12.0 - small.xml is a tiny dummy definition used for testing scanner variations without causing lots of big output files - the other files are wayland-scanner products from the xml files Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> v2: update output due to 2c6350beb92816eb9213c4944d197485e788ef6d Acked-by: Yong Bakos <ybakos@humanoriented.com>