]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: use more suitable assertions
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 26 Aug 2024 21:22:19 +0000 (06:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 27 Aug 2024 20:35:07 +0000 (05:35 +0900)
src/libsystemd/sd-device/test-sd-device-monitor.c

index d6a6e5d364bb5417aa2cf36226857c69c853d926..e1d65b5bc9860f8889aaed34311d5bbd053d5658 100644 (file)
@@ -48,7 +48,7 @@ static int monitor_handler(sd_device_monitor *m, sd_device *d, void *userdata) {
         const char *s, *syspath = userdata;
 
         ASSERT_OK(sd_device_get_syspath(d, &s));
-        ASSERT_TRUE(streq(s, syspath));
+        ASSERT_STREQ(s, syspath);
 
         return sd_event_exit(sd_device_monitor_get_event(m), 100);
 }
@@ -104,14 +104,14 @@ static void send_by_enumerator(
 TEST(sd_device_monitor_is_running) {
         _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *m = NULL;
 
-        ASSERT_EQ(sd_device_monitor_is_running(NULL), 0);
+        ASSERT_OK_ZERO(sd_device_monitor_is_running(NULL));
 
         ASSERT_OK(device_monitor_new_full(&m, MONITOR_GROUP_NONE, -1));
-        ASSERT_EQ(sd_device_monitor_is_running(m), 0);
+        ASSERT_OK_ZERO(sd_device_monitor_is_running(m));
         ASSERT_OK(sd_device_monitor_start(m, NULL, NULL));
-        ASSERT_EQ(sd_device_monitor_is_running(m), 1);
+        ASSERT_OK_POSITIVE(sd_device_monitor_is_running(m));
         ASSERT_OK(sd_device_monitor_stop(m));
-        ASSERT_EQ(sd_device_monitor_is_running(m), 0);
+        ASSERT_OK_ZERO(sd_device_monitor_is_running(m));
 }
 
 TEST(sd_device_monitor_start_stop) {
@@ -381,16 +381,16 @@ TEST(sd_device_monitor_receive) {
                 r = fd_wait_for_event(fd, POLLIN, 10 * USEC_PER_SEC);
                 if (r == -EINTR)
                         continue;
-                ASSERT_GT(r, 0);
+                ASSERT_OK_POSITIVE(r);
                 break;
         }
 
         _cleanup_(sd_device_unrefp) sd_device *dev = NULL;
-        ASSERT_GT(sd_device_monitor_receive(monitor_client, &dev), 0);
+        ASSERT_OK_POSITIVE(sd_device_monitor_receive(monitor_client, &dev));
 
         const char *s;
         ASSERT_OK(sd_device_get_syspath(dev, &s));
-        ASSERT_TRUE(streq(s, syspath));
+        ASSERT_STREQ(s, syspath);
 }
 
 static int intro(void) {