From 96b686aacbab90b379478d89bba0092cd04c3e2c Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 13 Feb 2023 11:03:47 +0100 Subject: [PATCH] tests: use GLib typedef conventions for line names and hogs The GVariant packaging works in the context of GLib unit testing so use GLib conventions for declaring data types. Signed-off-by: Bartosz Golaszewski --- tests/gpiod-test-helpers.c | 8 ++++---- tests/gpiod-test-helpers.h | 13 ++++++------- tests/tests-chip.c | 6 +++--- tests/tests-line-info.c | 4 ++-- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/tests/gpiod-test-helpers.c b/tests/gpiod-test-helpers.c index 1669ee3..7e5b396 100644 --- a/tests/gpiod-test-helpers.c +++ b/tests/gpiod-test-helpers.c @@ -12,10 +12,10 @@ #include "gpiod-test-helpers.h" GVariant * -gpiod_test_package_line_names(const struct gpiod_test_line_name *names) +gpiod_test_package_line_names(const GPIOSimLineName *names) { g_autoptr(GVariantBuilder) builder = NULL; - const struct gpiod_test_line_name *name; + const GPIOSimLineName *name; builder = g_variant_builder_new(G_VARIANT_TYPE("a(us)")); @@ -26,10 +26,10 @@ gpiod_test_package_line_names(const struct gpiod_test_line_name *names) return g_variant_ref_sink(g_variant_new("a(us)", builder)); } -GVariant *gpiod_test_package_hogs(const struct gpiod_test_hog *hogs) +GVariant *gpiod_test_package_hogs(const GPIOSimHog *hogs) { g_autoptr(GVariantBuilder) builder = NULL; - const struct gpiod_test_hog *hog; + const GPIOSimHog *hog; builder = g_variant_builder_new(G_VARIANT_TYPE("a(usi)")); diff --git a/tests/gpiod-test-helpers.h b/tests/gpiod-test-helpers.h index 760949e..49e782b 100644 --- a/tests/gpiod-test-helpers.h +++ b/tests/gpiod-test-helpers.h @@ -176,19 +176,18 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(struct_gpiod_edge_event_buffer, #define gpiod_test_expect_errno(_expected) \ g_assert_cmpint(_expected, ==, errno) -struct gpiod_test_line_name { +typedef struct { guint offset; const gchar *name; -}; +} GPIOSimLineName; -struct gpiod_test_hog { +typedef struct { guint offset; const gchar *name; GPIOSimDirection direction; -}; +} GPIOSimHog; -GVariant * -gpiod_test_package_line_names(const struct gpiod_test_line_name *names); -GVariant *gpiod_test_package_hogs(const struct gpiod_test_hog *hogs); +GVariant *gpiod_test_package_line_names(const GPIOSimLineName *names); +GVariant *gpiod_test_package_hogs(const GPIOSimHog *hogs); #endif /* __GPIOD_TEST_HELPERS_H__ */ diff --git a/tests/tests-chip.c b/tests/tests-chip.c index 09ea78d..a25663f 100644 --- a/tests/tests-chip.c +++ b/tests/tests-chip.c @@ -79,7 +79,7 @@ GPIOD_TEST_CASE(get_fd) GPIOD_TEST_CASE(find_line_bad) { - static const struct gpiod_test_line_name names[] = { + static const GPIOSimLineName names[] = { { .offset = 1, .name = "foo", }, { .offset = 2, .name = "bar", }, { .offset = 4, .name = "baz", }, @@ -106,7 +106,7 @@ GPIOD_TEST_CASE(find_line_bad) GPIOD_TEST_CASE(find_line_good) { - static const struct gpiod_test_line_name names[] = { + static const GPIOSimLineName names[] = { { .offset = 1, .name = "foo", }, { .offset = 2, .name = "bar", }, { .offset = 4, .name = "baz", }, @@ -132,7 +132,7 @@ GPIOD_TEST_CASE(find_line_good) /* Verify that for duplicated line names, the first one is returned. */ GPIOD_TEST_CASE(find_line_duplicate) { - static const struct gpiod_test_line_name names[] = { + static const GPIOSimLineName names[] = { { .offset = 1, .name = "foo", }, { .offset = 2, .name = "baz", }, { .offset = 4, .name = "baz", }, diff --git a/tests/tests-line-info.c b/tests/tests-line-info.c index 0d8173e..137084e 100644 --- a/tests/tests-line-info.c +++ b/tests/tests-line-info.c @@ -39,7 +39,7 @@ GPIOD_TEST_CASE(get_line_info_offset_out_of_range) GPIOD_TEST_CASE(line_info_basic_properties) { - static const struct gpiod_test_line_name names[] = { + static const GPIOSimLineName names[] = { { .offset = 1, .name = "foo", }, { .offset = 2, .name = "bar", }, { .offset = 4, .name = "baz", }, @@ -47,7 +47,7 @@ GPIOD_TEST_CASE(line_info_basic_properties) { } }; - static const struct gpiod_test_hog hogs[] = { + static const GPIOSimHog hogs[] = { { .offset = 3, .name = "hog3", -- 2.30.2