[PATCH v4 5/6] tests: check decoding of GPIO v2 ioctls
Dmitry V. Levin
ldv at altlinux.org
Sun Jan 24 15:33:40 UTC 2021
On Sat, Jan 23, 2021 at 09:56:44AM +0800, Kent Gibson wrote:
> Add tests for decoding of GPIO v2 ioctls.
>
> Signed-off-by: Kent Gibson <warthog618 at gmail.com>
[...]
> +static void
> +print_gpio_v2_line_attr(struct_gpio_v2_line_attribute *attr)
> +{
> + printf("{");
> + switch (attr->id) {
> + case GPIO_V2_LINE_ATTR_ID_FLAGS:
> + printf("flags=%#" PRIx64 NRAW(" /* GPIO_V2_LINE_FLAG_??? */"),
> + attr->flags);
If the kernel headers are used, this wouldn't necessarily be PRIx64 any
longer, I suggest using %#jx instead.
> + break;
> + case GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES:
> + printf("values=%#" PRIx64, attr->values);
Likewise.
> + break;
> + case GPIO_V2_LINE_ATTR_ID_DEBOUNCE:
> + printf("debounce_period_us=%u", attr->debounce_period_us);
> + break;
> + default:
> + printf("id=%u, data=%#" PRIx64, attr->id, attr->values);
Likewise.
If the XLAT_MACROS_ONLY approach is used, then the following patch would
be needed on top of yours:
diff --git a/tests/ioctl_gpio.c b/tests/ioctl_gpio.c
index 0454bfe19..ef6fa97a6 100644
--- a/tests/ioctl_gpio.c
+++ b/tests/ioctl_gpio.c
@@ -20,4 +20,6 @@
# include "xlat/gpio_ioctl_cmds.h"
# include "xlat/gpio_line_flags.h"
+# include "xlat/gpio_v2_line_attr_ids.h"
+# include "xlat/gpio_v2_line_flags.h"
#undef XLAT_MACROS_ONLY
@@ -46,4 +48,28 @@
#endif
+#ifdef HAVE_STRUCT_GPIO_V2_LINE_VALUES
+# define struct_gpio_v2_line_values struct gpio_v2_line_values
+#endif
+
+#ifdef HAVE_STRUCT_GPIO_V2_LINE_ATTRIBUTE
+# define struct_gpio_v2_line_attribute struct gpio_v2_line_attribute
+#endif
+
+#ifdef HAVE_STRUCT_GPIO_V2_LINE_CONFIG_ATTRIBUTE
+# define struct_gpio_v2_line_config_attribute struct gpio_v2_line_config_attribute
+#endif
+
+#ifdef HAVE_STRUCT_GPIO_V2_LINE_CONFIG
+# define struct_gpio_v2_line_config struct gpio_v2_line_config
+#endif
+
+#ifdef HAVE_STRUCT_GPIO_V2_LINE_REQUEST
+# define struct_gpio_v2_line_request struct gpio_v2_line_request
+#endif
+
+#ifdef HAVE_STRUCT_GPIO_V2_LINE_INFO
+# define struct_gpio_v2_line_info struct gpio_v2_line_info
+#endif
+
# define str_event_flags XLAT_KNOWN(0x3, "GPIOEVENT_REQUEST_BOTH_EDGES")
# define str_handle_flags XLAT_KNOWN(0x14, \
--
ldv
More information about the Strace-devel
mailing list