summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-04-05 15:23:19 +0900
committerLuca Boccassi <luca.boccassi@gmail.com>2023-04-05 19:38:08 +0100
commit70650ae345801f4e1fd94c2cacd1b95ff174a60d (patch)
treef1e693998dada35bfd545e25328d59700d4b4308 /src/test
parentcad0fc7a1363b3221566d37092b5cc7576e65d1f (diff)
downloadsystemd-70650ae345801f4e1fd94c2cacd1b95ff174a60d.tar.gz
test: add tests for dir_fd_is_root_or_cwd()
Follow-up for e212f422796da9e626030289faf083407c8955df.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-fd-util.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/test-fd-util.c b/src/test/test-fd-util.c
index adcd851d7f..c902f83784 100644
--- a/src/test/test-fd-util.c
+++ b/src/test/test-fd-util.c
@@ -597,13 +597,17 @@ TEST(dir_fd_is_root) {
_cleanup_close_ int fd = -EBADF;
int r;
+ assert_se(dir_fd_is_root_or_cwd(AT_FDCWD) > 0);
+
assert_se((fd = open("/", O_CLOEXEC|O_PATH|O_DIRECTORY|O_NOFOLLOW)) >= 0);
assert_se(dir_fd_is_root(fd) > 0);
+ assert_se(dir_fd_is_root_or_cwd(fd) > 0);
fd = safe_close(fd);
assert_se((fd = open("/usr", O_CLOEXEC|O_PATH|O_DIRECTORY|O_NOFOLLOW)) >= 0);
assert_se(dir_fd_is_root(fd) == 0);
+ assert_se(dir_fd_is_root_or_cwd(fd) == 0);
r = detach_mount_namespace();
if (r < 0)
@@ -622,16 +626,19 @@ TEST(dir_fd_is_root) {
assert_se((fd = open(tmp, O_CLOEXEC|O_PATH|O_DIRECTORY|O_NOFOLLOW)) >= 0);
assert_se(dir_fd_is_root(fd) == 0);
+ assert_se(dir_fd_is_root_or_cwd(fd) == 0);
fd = safe_close(fd);
assert_se((fd = open(x, O_CLOEXEC|O_PATH|O_DIRECTORY|O_NOFOLLOW)) >= 0);
assert_se(dir_fd_is_root(fd) == 0);
+ assert_se(dir_fd_is_root_or_cwd(fd) == 0);
fd = safe_close(fd);
assert_se((fd = open(y, O_CLOEXEC|O_PATH|O_DIRECTORY|O_NOFOLLOW)) >= 0);
assert_se(dir_fd_is_root(fd) == 0);
+ assert_se(dir_fd_is_root_or_cwd(fd) == 0);
}
TEST(fd_get_path) {