summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-06-02 02:17:40 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-06-02 02:19:47 +0200
commit94e8dd54d023f1d1a0b4be7b66f8ad7220ac0b54 (patch)
tree047a277dfff78dfa184ac2ba26e1cb16ee6d2bdf
parenttest-async: wait a while for fd to be closed (diff)
downloadsystemd-94e8dd54d023f1d1a0b4be7b66f8ad7220ac0b54.tar.xz
systemd-94e8dd54d023f1d1a0b4be7b66f8ad7220ac0b54.zip
test-async: also check if the directory is removed
-rw-r--r--src/test/test-async.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/test/test-async.c b/src/test/test-async.c
index 2771cbd5aa..ee6bae2698 100644
--- a/src/test/test-async.c
+++ b/src/test/test-async.c
@@ -56,6 +56,18 @@ TEST(asynchronous_close) {
}
}
+static void wait_rm_rf(const char *path) {
+ for (unsigned trial = 0; trial < 100; trial++) {
+ usleep_safe(100 * USEC_PER_MSEC);
+ if (access(path, F_OK) < 0) {
+ assert_se(errno == ENOENT);
+ return;
+ }
+ }
+
+ assert_not_reached();
+}
+
TEST(asynchronous_rm_rf) {
_cleanup_free_ char *t = NULL, *k = NULL;
int r;
@@ -64,8 +76,9 @@ TEST(asynchronous_rm_rf) {
assert_se(k = path_join(t, "somefile"));
ASSERT_OK(touch(k));
ASSERT_OK(asynchronous_rm_rf(t, REMOVE_ROOT|REMOVE_PHYSICAL));
+ wait_rm_rf(t);
- /* Do this once more, form a subreaper. Which is nice, because we can watch the async child even
+ /* Do this once more, from a subreaper. Which is nice, because we can watch the async child even
* though detached */
r = safe_fork("(subreaper)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG_SIGTERM|FORK_LOG|FORK_WAIT, NULL);