tests: use GLib typedef conventions for line names and hogs
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 13 Feb 2023 10:03:47 +0000 (11:03 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 15 Feb 2023 12:21:56 +0000 (13:21 +0100)
The GVariant packaging works in the context of GLib unit testing so use
GLib conventions for declaring data types.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
tests/gpiod-test-helpers.c
tests/gpiod-test-helpers.h
tests/tests-chip.c
tests/tests-line-info.c

index 1669ee3ec4cae93a03d36ebea49b6a8c5ea281ae..7e5b39610bbaee9a9ae7fa32f31cf750d2e8c6d8 100644 (file)
 #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)"));
 
index 760949e9de90e718534af4301945c4d77d49dcf2..49e782bb9cfdb9eb9dcbd693618133d6d0c6c2d6 100644 (file)
@@ -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__ */
index 09ea78ddd0ae95aa97621f24ecccfc4af51472dc..a25663fa4fe033ddb1ab169eb8ddc67093cb2664 100644 (file)
@@ -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", },
index 0d8173e5f4f6a662aa23736fa549427afc5081c6..137084ec7ad9b74701accdf099af8e92aeb27b08 100644 (file)
@@ -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",