test: show is_initialized flag in log message of test-sd-device
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 31 Oct 2018 01:01:45 +0000 (10:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 6 Nov 2018 06:45:22 +0000 (15:45 +0900)
And drop devpath, as it is redundant for most cases.

src/libsystemd/sd-device/test-sd-device.c

index 2e933cf..e523206 100644 (file)
@@ -17,7 +17,7 @@ static void test_sd_device_basic(void) {
         assert_se(sd_device_enumerator_new(&e) >= 0);
         assert_se(sd_device_enumerator_allow_uninitialized(e) >= 0);
         FOREACH_DEVICE(e, d) {
-                const char *syspath, *devpath, *subsystem, *val;
+                const char *syspath, *subsystem, *val;
                 dev_t devnum;
                 usec_t usec;
                 int i, r;
@@ -39,7 +39,7 @@ static void test_sd_device_basic(void) {
                 r = sd_device_get_driver(d, &val);
                 assert_se(r >= 0 || r == -ENOENT);
 
-                assert_se(sd_device_get_devpath(d, &devpath) >= 0);
+                assert_se(sd_device_get_devpath(d, &val) >= 0);
 
                 r = sd_device_get_devname(d, &val);
                 assert_se(r >= 0 || r == -ENOENT);
@@ -49,9 +49,9 @@ static void test_sd_device_basic(void) {
                 r = sd_device_get_sysnum(d, &val);
                 assert_se(r >= 0 || r == -ENOENT);
 
-                r = sd_device_get_is_initialized(d);
-                assert_se(r >= 0);
-                if (r > 0) {
+                i = sd_device_get_is_initialized(d);
+                assert_se(i >= 0);
+                if (i > 0) {
                         r = sd_device_get_usec_since_initialized(d, &usec);
                         assert_se(r >= 0 || r == -ENODATA);
                 }
@@ -62,7 +62,7 @@ static void test_sd_device_basic(void) {
                 r = sd_device_get_property_value(d, "ID_NET_DRIVER", &val);
                 assert_se(r >= 0 || r == -ENOENT);
 
-                log_debug("syspath:%s devpath:%s subsystem:%s", syspath, devpath, strempty(subsystem));
+                log_debug("subsystem:%s syspath:%s initialized:%s", strna(subsystem), syspath, yes_no(i));
         }
 }