From b258d5f36137088e5cb5ae097db7964290da7d55 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 17 Sep 2022 10:53:56 +0200 Subject: scanner: add validators for enums 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 Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/104 --- tests/enum-validator-test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/enum-validator-test.c (limited to 'tests/enum-validator-test.c') diff --git a/tests/enum-validator-test.c b/tests/enum-validator-test.c new file mode 100644 index 0000000..92037cf --- /dev/null +++ b/tests/enum-validator-test.c @@ -0,0 +1,13 @@ +#include +#include "data/small-server-core.h" + +int +main(int argc, char *argv[]) { + assert(intf_A_foo_is_valid(INTF_A_FOO_FIRST, 1)); + assert(intf_A_foo_is_valid(INTF_A_FOO_FIRST, 2)); + + assert(!intf_A_foo_is_valid(INTF_A_FOO_THIRD, 1)); + assert(intf_A_foo_is_valid(INTF_A_FOO_THIRD, 2)); + + assert(intf_A_foo_is_valid(INTF_A_FOO_NEGATIVE, 2)); +} -- cgit v1.2.3-70-g09d2