Since the commit e25f27939668, the registered cleanup function is called twice: once from the explicit _cleanup() call in _call_test(), and once more from the EXIT trap when the test subshell exits. At the second call, TMPDIR has already been removed and unset, and the output is no longer redirected to the test output file. This was unnoticed because existing cleanup functions work fine at the second call. However, the cleanup function of the new test case added by GitHub PR 260 does not work well. It refers to TMPDIR to stop the nbd server, and the second call prints the error messages below: cat: /nbd.pid: No such file or directory tests/nbd/rc: line 87: kill: `': not a pid or valid job spec Avoid the second call by unsetting TEST_CLEANUP after calling it. Link: https://github.com/linux-blktests/blktests/pull/260 Fixes: e25f27939668 ("check: Add the ability to call a cleanup function after a test ends") Signed-off-by: Shin'ichiro Kawasaki --- check | 1 + 1 file changed, 1 insertion(+) diff --git a/check b/check index 3ef36b4..58eae3c 100755 --- a/check +++ b/check @@ -417,6 +417,7 @@ _register_test_cleanup() { _cleanup() { if [[ -v TEST_CLEANUP ]]; then ${TEST_CLEANUP} + unset TEST_CLEANUP fi if [[ "${TMPDIR:-}" ]]; then -- 2.56.0