From 4a0b14a4f2c0f7067e2f39c582f7289e57b9dab6 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 15 Feb 2022 09:21:18 -0800 Subject: [PATCH] Wait for stdin open in orphan-inodes test The orphan inode test often uses a trick where it runs sleep in the abckground with a file as stdin as a means of holding files open. This can very rarely fail if the background sleep happens to be first schedled after the unlink of the file it's reading as stdin. A small delay gives it a chance to run and open the file before its unlinked. It's still possible to lose the race, of course, but so far this has been good enough. Signed-off-by: Zach Brown --- tests/tests/orphan-inodes.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/tests/orphan-inodes.sh b/tests/tests/orphan-inodes.sh index ffd9f498..a0d7479b 100644 --- a/tests/tests/orphan-inodes.sh +++ b/tests/tests/orphan-inodes.sh @@ -38,6 +38,7 @@ inode_exists $ino || echo "$ino didn't exist" echo "== unlinked and opened inodes still exist" sleep 1000000 < "$path" & +sleep .1 # wait for background sleep to run and open stdin pid="$!" rm -f "$path" inode_exists $ino || echo "$ino didn't exist" @@ -56,6 +57,7 @@ for nr in $(t_fs_nrs); do touch "$path" inos="$inos $(stat -c %i $path)" sleep 1000000 < "$path" & + sleep .1 # wait for background sleep to run and open stdin pids="$pids $!" rm -f "$path" done