From: Yu Watanabe Date: Wed, 30 Mar 2022 18:54:41 +0000 (+0900) Subject: test: add test for sd_device_open() X-Git-Tag: v251-rc2~231^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9534d6c9ea790da2e90819e78c739f2dd9895248;p=thirdparty%2Fsystemd.git test: add test for sd_device_open() --- diff --git a/src/libsystemd/sd-device/test-sd-device.c b/src/libsystemd/sd-device/test-sd-device.c index 7276305e4f2..8d7cb792d68 100644 --- a/src/libsystemd/sd-device/test-sd-device.c +++ b/src/libsystemd/sd-device/test-sd-device.c @@ -1,10 +1,13 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #include "device-enumerator-private.h" #include "device-internal.h" #include "device-private.h" #include "device-util.h" #include "errno-util.h" +#include "fd-util.h" #include "hashmap.h" #include "nulstr-util.h" #include "path-util.h" @@ -65,6 +68,10 @@ static void test_sd_device_one(sd_device *d) { assert_se(sd_device_get_syspath(dev, &val) >= 0); assert_se(streq(syspath, val)); dev = sd_device_unref(dev); + + _cleanup_close_ int fd = -1; + fd = sd_device_open(d, O_CLOEXEC| O_NONBLOCK | (is_block ? O_RDONLY : O_NOCTTY | O_PATH)); + assert_se(fd >= 0 || ERRNO_IS_PRIVILEGE(fd)); } else assert_se(r == -ENODEV || ERRNO_IS_PRIVILEGE(r)); } else