diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-03-31 03:54:41 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-04-01 15:20:48 +0900 |
commit | 9534d6c9ea790da2e90819e78c739f2dd9895248 (patch) | |
tree | 04d847b66feaf7d5ca855a439eb4fc67b5c22caa /src/libsystemd | |
parent | f9a726abefe1c25d952b36cd554e026e4c782967 (diff) | |
download | systemd-9534d6c9ea790da2e90819e78c739f2dd9895248.tar.gz |
test: add test for sd_device_open()
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-device/test-sd-device.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libsystemd/sd-device/test-sd-device.c b/src/libsystemd/sd-device/test-sd-device.c index 7276305e4f..8d7cb792d6 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 <fcntl.h> + #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 |