summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-device/test-device-util.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:35:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:35:18 +0000
commitb750101eb236130cf056c675997decbac904cc49 (patch)
treea5df1a06754bdd014cb975c051c83b01c9a97532 /src/libsystemd/sd-device/test-device-util.c
parentInitial commit. (diff)
downloadsystemd-b750101eb236130cf056c675997decbac904cc49.tar.xz
systemd-b750101eb236130cf056c675997decbac904cc49.zip
Adding upstream version 252.22.upstream/252.22
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libsystemd/sd-device/test-device-util.c')
-rw-r--r--src/libsystemd/sd-device/test-device-util.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libsystemd/sd-device/test-device-util.c b/src/libsystemd/sd-device/test-device-util.c
new file mode 100644
index 0000000..bc8ab66
--- /dev/null
+++ b/src/libsystemd/sd-device/test-device-util.c
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "device-util.h"
+#include "tests.h"
+
+TEST(log_device_full) {
+ int r;
+
+ for (int level = LOG_ERR; level <= LOG_DEBUG; level++) {
+ log_device_full(NULL, level, "test level=%d: %m", level);
+
+ r = log_device_full_errno(NULL, level, EUCLEAN, "test level=%d errno=EUCLEAN: %m", level);
+ assert_se(r == -EUCLEAN);
+
+ r = log_device_full_errno(NULL, level, 0, "test level=%d errno=0: %m", level);
+ assert_se(r == 0);
+
+ r = log_device_full_errno(NULL, level, SYNTHETIC_ERRNO(ENODATA), "test level=%d errno=S(ENODATA): %m", level);
+ assert_se(r == -ENODATA);
+ }
+}
+
+DEFINE_TEST_MAIN(LOG_INFO);