[libgudev/benzea/fix-newline-stripping] tests: Add test for g_udev_device_get_sysfs_attr_keys



commit 4257a640715eba9614b9ddd770a9f179caa5c7ed
Author: Benjamin Berg <bberg redhat com>
Date:   Tue May 31 18:43:58 2022 +0200

    tests: Add test for g_udev_device_get_sysfs_attr_keys

 tests/test-sysfsattr.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/tests/test-sysfsattr.c b/tests/test-sysfsattr.c
index de38760..7dcf0dd 100644
--- a/tests/test-sysfsattr.c
+++ b/tests/test-sysfsattr.c
@@ -94,8 +94,21 @@ test_uncached_sysfs_attr (Fixture *f, G_GNUC_UNUSED const void *data)
        fprintf (sysfsfp, "%s\n", "Y");
        fclose (sysfsfp);
        g_assert_true (g_udev_device_get_sysfs_attr_as_boolean_uncached (dev, "console"));
+}
+
+static void
+test_sysfs_attr_keys (Fixture *f, G_GNUC_UNUSED const void *data)
+{
+       const char *expected[] = { "console", "dytc_lapmode", "subsystem", "uevent", NULL };
+       g_autoptr(GUdevDevice) dev = NULL;
+
+       dev = create_single_dev (f, "P: /devices/dev1\n"
+                                   "E: SUBSYSTEM=platform\n"
+                                   "A: dytc_lapmode=1\n"
+                                   "A: console=Y\\n\n"
+                                   "E: ID_MODEL=KoolGadget");
 
-       g_list_free_full (devices, g_object_unref);
+       g_assert_cmpstrv (g_udev_device_get_sysfs_attr_keys (dev), expected);
 }
 
 int main(int argc, char **argv)
@@ -108,5 +121,10 @@ int main(int argc, char **argv)
                    test_uncached_sysfs_attr,
                    fixture_teardown);
 
+       g_test_add ("/gudev/sysfs_attr_keys", Fixture, NULL,
+                   fixture_setup,
+                   test_sysfs_attr_keys,
+                   fixture_teardown);
+
        return g_test_run ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]