|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
From 2e9d763e7cbeb33954bbe3f96fd94de2cd62edf7 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
Date: Thu, 12 Nov 2020 14:28:24 +0100
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
Subject: [PATCH] test-path-util: do not fail if the fd_is_mount_point check
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
fails
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
This test fails on i686 and ppc64le in koji:
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
/* test_path */
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
Assertion 'fd_is_mount_point(fd, "/", 0) > 0' failed at src/test/test-path-util.c:85, function test_path(). Aborting.
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
I guess some permission error is the most likely.
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
src/test/test-path-util.c | 23 +++++++++++++++++------
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
1 file changed, 17 insertions(+), 6 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
index f4f8d0550b..be428334f3 100644
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
--- a/src/test/test-path-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+++ b/src/test/test-path-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
@@ -40,8 +40,6 @@ static void test_path_simplify(const char *in, const char *out, const char *out_
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
static void test_path(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
- _cleanup_close_ int fd = -1;
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
log_info("/* %s */", __func__);
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
test_path_compare("/goo", "/goo", 0);
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
@@ -80,10 +78,6 @@ static void test_path(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
assert_se(streq(basename("/aa///file..."), "file..."));
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
assert_se(streq(basename("file.../"), ""));
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
- fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
- assert_se(fd >= 0);
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
- assert_se(fd_is_mount_point(fd, "/", 0) > 0);
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
test_path_simplify("aaa/bbb////ccc", "aaa/bbb/ccc", "aaa/bbb/ccc");
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
test_path_simplify("//aaa/.////ccc", "/aaa/./ccc", "/aaa/ccc");
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
test_path_simplify("///", "/", "/");
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
@@ -120,6 +114,22 @@ static void test_path(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
assert_se(!path_equal_ptr(NULL, "/a"));
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+static void test_path_is_mountpoint(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+ _cleanup_close_ int fd = -1;
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+ int r;
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+ log_info("/* %s */", __func__);
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+ fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+ assert_se(fd >= 0);
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+ r = fd_is_mount_point(fd, "/", 0);
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+ if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+ log_warning_errno(r, "Failed to check if / is a mount point, ignoring: %m");
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+ else
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+ assert_se(r == 1);
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
static void test_path_equal_root(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
/* Nail down the details of how path_equal("/", ...) works. */
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
@@ -714,6 +724,7 @@ int main(int argc, char **argv) {
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
test_print_paths();
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
test_path();
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
+ test_path_is_mountpoint();
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
test_path_equal_root();
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
test_find_executable_full();
|
|
Zbigniew Jędrzejewski-Szmek |
d9fc59 |
test_find_executable(argv[0]);
|