mirror of
https://github.com/systemd/systemd.git
synced 2025-02-27 01:57:35 +03:00
test: avoid leaking open loop devices
When a subshell is used ('make' or 'make all') the LOOPDEV environment variable, which is used to store the opened loop device, is lost. So the cleanup on trap/exit doesn't do anything, and the loop device used to mount the test image is left around. Avoid using a subshell to fix the issue.
This commit is contained in:
parent
50fc7d7036
commit
0761da386a
@ -2320,11 +2320,15 @@ do_test() {
|
||||
--all)
|
||||
ret=0
|
||||
echo -n "${testname}: $TEST_DESCRIPTION "
|
||||
(
|
||||
test_setup
|
||||
test_setup_cleanup
|
||||
test_run "$2"
|
||||
) </dev/null >"$TESTLOG" 2>&1 || ret=$?
|
||||
# Do not use a subshell, otherwise cleanup variables (LOOPDEV) will be lost
|
||||
# and loop devices will leak
|
||||
test_setup </dev/null >"$TESTLOG" 2>&1 || ret=$?
|
||||
if [ $ret -eq 0 ]; then
|
||||
test_setup_cleanup </dev/null >>"$TESTLOG" 2>&1 || ret=$?
|
||||
fi
|
||||
if [ $ret -eq 0 ]; then
|
||||
test_run "$2" </dev/null >>"$TESTLOG" 2>&1 || ret=$?
|
||||
fi
|
||||
test_cleanup
|
||||
if [ $ret -eq 0 ]; then
|
||||
rm "$TESTLOG"
|
||||
|
Loading…
x
Reference in New Issue
Block a user