mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
tests/int: fix teardown in mounts_sshfs.bats
Function teardown assumes that every test case will call setup_sshfs. Currently, this assumption is true, but once a test case that won't call setup_sshfs is added (say because it has some extra "requires" or "skip"), it will break bats, so any bats invocation involving such a test case will end up hanging after the last test case is run. The reason is, we have set -u in helpers.bash to help catching the use of undefined variables. In the above scenario, such a variable is DIR, which is referenced in teardown but is only defined after a call to setup_sshfs. As a result, bash that is running the teardown function will exit upon seeing the first $DIR, and thus teardown_bundle won't be run. This, in turn, results in a stale recvtty process, which inherits bats' fd 3. Until that fd is closed, bats waits for test logs. Long story short, the fix is to - check if DIR is set before referencing it; - unset it after unmount. PS it is still not clear why there is no diagnostics about the failed teardown. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
committed by
Aleksa Sarai
parent
3272edfe3b
commit
153865d0fe
@@ -8,9 +8,12 @@ function setup() {
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
# Some distros do not have fusermount installed
|
||||
# as a dependency of fuse-sshfs, and good ol' umount works.
|
||||
fusermount -u "$DIR" || umount "$DIR"
|
||||
if [ -v DIR ]; then
|
||||
# Some distros do not have fusermount installed
|
||||
# as a dependency of fuse-sshfs, and good ol' umount works.
|
||||
fusermount -u "$DIR" || umount "$DIR"
|
||||
unset DIR
|
||||
fi
|
||||
|
||||
teardown_bundle
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user