mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
test-fd-util: compare FDs to /bin/sh instead of /dev/null
/dev/null is a character device, so same_fd() in the fallback path that compares fstat will fail, as that bails out if the fd refers to a char device. This happens on kernels without F_DUPFD_QUERY and without kcmp. /* test_same_fd */ Assertion 'same_fd(d, e) > 0' failed at src/test/test-fd-util.c:111, function test_same_fd(). Aborting. Fixes #35552
This commit is contained in:
parent
630a2e7ee1
commit
3b32d333e8
@ -76,9 +76,9 @@ TEST(same_fd) {
|
|||||||
|
|
||||||
assert_se(pipe2(p, O_CLOEXEC) >= 0);
|
assert_se(pipe2(p, O_CLOEXEC) >= 0);
|
||||||
assert_se((a = fcntl(p[0], F_DUPFD, 3)) >= 0);
|
assert_se((a = fcntl(p[0], F_DUPFD, 3)) >= 0);
|
||||||
assert_se((b = open("/dev/null", O_RDONLY|O_CLOEXEC)) >= 0);
|
assert_se((b = open("/bin/sh", O_RDONLY|O_CLOEXEC)) >= 0);
|
||||||
assert_se((c = fcntl(a, F_DUPFD, 3)) >= 0);
|
assert_se((c = fcntl(a, F_DUPFD, 3)) >= 0);
|
||||||
assert_se((d = open("/dev/null", O_RDONLY|O_CLOEXEC|O_PATH)) >= 0); /* O_PATH changes error returns in F_DUPFD_QUERY, let's test explicitly */
|
assert_se((d = open("/bin/sh", O_RDONLY|O_CLOEXEC|O_PATH)) >= 0); /* O_PATH changes error returns in F_DUPFD_QUERY, let's test explicitly */
|
||||||
assert_se((e = fcntl(d, F_DUPFD, 3)) >= 0);
|
assert_se((e = fcntl(d, F_DUPFD, 3)) >= 0);
|
||||||
|
|
||||||
assert_se(same_fd(p[0], p[0]) > 0);
|
assert_se(same_fd(p[0], p[0]) > 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user