From: Frantisek Sumsal Date: Sat, 1 Oct 2022 19:56:08 +0000 (+0200) Subject: test: expand the expression in `cleanup_initdir()` X-Git-Tag: v252-rc1~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9caab7b5591c3bc6575b8678d011529ae6e0fc0e;p=thirdparty%2Fsystemd.git test: expand the expression in `cleanup_initdir()` Otherwise we might unexpectedly return 1 if the `get_bool` call fails. If the `get_bool` part in `get_bool "$TEST_SETUP_CLEANUP_ROOTDIR" && _umount_dir "${initdir:?}"` fails, the whole expression will short-circuit evaluate to 1, and since it's the last expression in the function it's also it's return value, which doesn't reflect the original intent of the expression: ``` # BUILD_DIR=$PWD/build make -C test/TEST-64-UDEV-STORAGE/ setup run TESTCASES=testcase_always_skip make: Entering directory '/home/fsumsal/repos/@systemd/systemd/test/TEST-64-UDEV-STORAGE' TEST-64-UDEV-STORAGE SETUP: systemd-udev storage tests Reusing existing image /var/tmp/systemd-test.uPbJZ9/default.img → /var/tmp/systemd-test.uPbJZ9/default.img TEST-64-UDEV-STORAGE RUN: systemd-udev storage tests ------ testcase_always_skip: BEGIN ------ Skipping... ------ testcase_always_skip: END (SKIP) ------ Passed tests: 0 * Skipped tests: 1 * testcase_always_skip Failed tests: 0 * TEST-64-UDEV-STORAGE RUN: systemd-udev storage tests [OK] make: Leaving directory '/home/fsumsal/repos/@systemd/systemd/test/TEST-64-UDEV-STORAGE' # BUILD_DIR=$PWD/build make -C test/TEST-64-UDEV-STORAGE/ setup run TESTCASES=testcase_always_skip make: Entering directory '/home/fsumsal/repos/@systemd/systemd/test/TEST-64-UDEV-STORAGE' TEST-64-UDEV-STORAGE SETUP: systemd-udev storage tests Reusing existing image /var/tmp/systemd-test.uPbJZ9/default.img → /var/tmp/systemd-test.uPbJZ9/default.img make: *** [Makefile:4: setup] Error 1 make: Leaving directory '/home/fsumsal/repos/@systemd/systemd/test/TEST-64-UDEV-STORAGE' ``` --- diff --git a/test/test-functions b/test/test-functions index e9da6e3d113..58860dc9447 100644 --- a/test/test-functions +++ b/test/test-functions @@ -1372,7 +1372,9 @@ mount_initdir() { cleanup_initdir() { # only umount if create_empty_image_rootdir() was called to mount it - get_bool "$TEST_SETUP_CLEANUP_ROOTDIR" && _umount_dir "${initdir:?}" + if get_bool "$TEST_SETUP_CLEANUP_ROOTDIR"; then + _umount_dir "${initdir:?}" + fi } umount_loopback() {