Linux block layer
 help / color / mirror / Atom feed
* [PATCH blktests] check: avoid double calls of the cleanup function
@ 2026-11-23  7:42 Shin'ichiro Kawasaki
  2026-11-30 13:13 ` Shin'ichiro Kawasaki
  0 siblings, 1 reply; 2+ messages in thread
From: Shin'ichiro Kawasaki @ 2026-11-23  7:42 UTC (permalink / raw)
  To: linux-block; +Cc: Daan De Meyer, Shin'ichiro Kawasaki

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 <shinichiro.kawasaki@wdc.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-30 13:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23  7:42 [PATCH blktests] check: avoid double calls of the cleanup function Shin'ichiro Kawasaki
2026-11-30 13:13 ` Shin'ichiro Kawasaki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox