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




commit 0b89905b2b78ac896e7b20d7020437ba9288bca8
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, 20 insertions(+)
---
diff --git a/tests/test-sysfsattr.c b/tests/test-sysfsattr.c
index 88788ae..7dcf0dd 100644
--- a/tests/test-sysfsattr.c
+++ b/tests/test-sysfsattr.c
@@ -96,6 +96,21 @@ test_uncached_sysfs_attr (Fixture *f, G_GNUC_UNUSED const void *data)
        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_assert_cmpstrv (g_udev_device_get_sysfs_attr_keys (dev), expected);
+}
+
 int main(int argc, char **argv)
 {
        setlocale (LC_ALL, NULL);
@@ -106,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]