[LTP] [PATCH v2 1/2] tst_test.sh: Fix TBROK => TWARN evaluation in tst_brk()
Petr Vorel
pvorel@suse.cz
Tue Feb 11 21:57:33 CET 2025
From: Petr Vorel <petr.vorel@gmail.com>
This partly reverts commit 55bfa08e179de16773f19b703de70262896383ea
and setting TST_DO_EXIT=1 before _tst_do_cleanup() and unset it
afterwards inside of the _tst_run_iterations().
Also rename variable to be more descriptive: TST_DO_EXIT => TST_TBROK_TO_TWARN.
This fixes e.g. problem with not exiting test on too small $TMPDIR.
Before the fix:
# ./nfs10.sh -v 3 -t udp
nfs10 1 TINFO: Running: nfs10.sh -v 3 -t udp
...
nfs10 1 TINFO: Using /tmp/LTP_nfs10.LWDMqeJ74S as tmpdir (tmpfs filesystem)
tst_device.c:299: TWARN: Failed to create test_dev.img: ENOSPC (28)
Usage:
tst_device acquire [size [filename]]
tst_device release /path/to/device
tst_device clear /path/to/device
nfs10 1 TWARN: Failed to acquire device
tst_supported_fs_types.c:169: TINFO: Skipping ext2 as requested by the test
tst_supported_fs_types.c:169: TINFO: Skipping ext3 as requested by the test
tst_supported_fs_types.c:97: TINFO: Kernel supports ext4
...
nfs10 1 TINFO: === Testing on ext4 ===
tst_device.c:389: TWARN: Failed to clear 512k block on
Usage:
tst_device acquire [size [filename]]
tst_device release /path/to/device
tst_device clear /path/to/device
nfs10 1 TINFO: Formatting ext4 with opts=''
Usage: mkfs.ext4 [-c|-l filename] [-b block-size] [-C cluster-size]
[-i bytes-per-inode] [-I inode-size] [-J journal-options]
[-G flex-group-size] [-N number-of-inodes] [-d root-directory]
[-m reserved-blocks-percentage] [-o creator-os]
[-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]
[-O feature[,...]] [-r fs-revision] [-E extended-option[,...]]
[-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior][-z undo_file]
[-jnqvDFSV] device [blocks-count]
nfs10 1 TWARN: mkfs.ext4 failed
nfs10 1 TINFO: Mounting device: mount -t ext4 /tmp/LTP_nfs10.LWDMqeJ74S/mntpoint
mount: /tmp/LTP_nfs10.LWDMqeJ74S/mntpoint: can't find in /etc/fstab.
nfs10 1 TWARN: Failed to mount device ext4 type: mount exit = 1
nfs10 1 TINFO: timeout per run is 0h 11m 0s
nfs10 1 TCONF: rpc.mountd not running
nfs10 1 TINFO: Cleaning up testcase
nfs10 1 TINFO: The '/tmp/LTP_nfs10.LWDMqeJ74S/mntpoint' is not mounted, skipping umount
tst_device.c:281: TWARN: open() failed: ENOENT (2)
Usage:
tst_device acquire [size [filename]]
tst_device release /path/to/device
tst_device clear /path/to/device
nfs10 1 TWARN: Failed to release device ''
nfs10 1 TINFO: AppArmor enabled, this may affect test results
nfs10 1 TINFO: it can be disabled with TST_DISABLE_APPARMOR=1 (requires super/root)
nfs10 1 TINFO: loaded AppArmor profiles: none
After the fix:
# ./nfs10.sh -v 3 -t udp
nfs10 1 TINFO: Running: nfs10.sh -v 3 -t udp
...
nfs10 1 TINFO: Using /tmp/LTP_nfs10.34K5E5pjxY as tmpdir (tmpfs filesystem)
tst_device.c:299: TWARN: Failed to create test_dev.img: ENOSPC (28)
Usage:
tst_device acquire [size [filename]]
tst_device release /path/to/device
tst_device clear /path/to/device
nfs10 1 TBROK: Failed to acquire device
nfs10 1 TINFO: AppArmor enabled, this may affect test results
nfs10 1 TINFO: it can be disabled with TST_DISABLE_APPARMOR=1 (requires super/root)
nfs10 1 TINFO: loaded AppArmor profiles: none
Fixes: 55bfa08e17 ("tst_test.sh/tst_brk(): Convert only TBROK to TWARN in cleanup")
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
v1: https://patchwork.ozlabs.org/project/ltp/patch/20241211001418.392890-1-pvorel@suse.cz/
Changes v1-v2:
* set guarder in _tst_do_cleanup() (Cyril)
* rename variable (Cyril)
testcases/lib/tst_test.sh | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 2b797705e3..5a6e34473f 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -28,7 +28,6 @@ _tst_do_cleanup()
{
if [ -n "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" -a -z "$LTP_NO_CLEANUP" ]; then
if command -v $TST_CLEANUP >/dev/null 2>/dev/null; then
- TST_DO_CLEANUP=
$TST_CLEANUP
else
tst_res TWARN "TST_CLEANUP=$TST_CLEANUP declared, but function not defined (or cmd not found)"
@@ -40,7 +39,7 @@ _tst_do_cleanup()
_tst_do_exit()
{
local ret=0
- TST_DO_EXIT=1
+ TST_TBROK_TO_TWARN=1
_tst_do_cleanup
@@ -127,15 +126,11 @@ tst_brk()
local res=$1
shift
- # TBROK => TWARN on cleanup or exit
- if [ "$res" = TBROK ] && [ "$TST_DO_EXIT" = 1 -o -z "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" ]; then
- tst_res TWARN "$@"
- TST_DO_CLEANUP=
- return
- fi
-
if [ "$res" != TBROK -a "$res" != TCONF ]; then
tst_res TBROK "tst_brk can be called only with TBROK or TCONF ($res)"
+ elif [ "$TST_TBROK_TO_TWARN" = 1 ]; then
+ tst_res TWARN "$@"
+ return
else
tst_res "$res" "$@"
fi
@@ -820,7 +815,9 @@ _tst_run_iterations()
_tst_i=$((_tst_i-1))
done
+ TST_TBROK_TO_TWARN=1
_tst_do_cleanup
+ unset TST_TBROK_TO_TWARN
if [ "$TST_MOUNT_FLAG" = 1 ]; then
cd "$LTPROOT"
--
2.47.2
More information about the ltp
mailing list