lib: tst_umount: umount a mount point instead of a device
PATCH v7 1/4 lib: tst_umount: umount a mount point instead of a device
Current check inside tst_umount for whehter a device is mounted is ambiguous. Fix it by checking for the existance of the exact mount point the fs is mounted upon, and use the mount point instead of the device to do the umount process. This patch make tst_umount umount TST_MNTPOINT by default,
and reject any argument that does not start with '/'.
Signed-off-by Leo Yu-Chi Liang <[email protected]>
Reviewed-by Petr Vorel <[email protected]>
--- testcases/lib/tst_test.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
testcases/lib/tst_test.sh +11 -7
@@ -279,31 +279,35 @@ tst_mount() tst_umount() { - local device="${1:-$TST_DEVICE}" + local mntpoint="${1:-$TST_MNTPOINT}" local i=0 - [ -z "$device" ] && return + [ -z "$mntpoint" ] && return - if ! grep -q "$device" /proc/mounts; then - tst_res TINFO "The $device is not mounted, skipping umount" + if ! echo "$mntpoint" | grep -q ^/; then + tst_brk TCONF "The '$mntpoint' is not an absolute path" + fi + + if ! grep -q "${mntpoint%/}" /proc/mounts; then + tst_res TINFO "The '$mntpoint' is not mounted upon, skipping umount" return fi while [ "$i" -lt 50 ]; do - if umount "$device" > /dev/null; then + if umount "$mntpoint" > /dev/null; then return fi i=$((i+1)) - tst_res TINFO "umount($device) failed, try $i ..." + tst_res TINFO "umount($mntpoint) failed, try $i ..." tst_res TINFO "Likely gvfsd-trash is probing newly mounted "\ "fs, kill it to speed up tests." tst_sleep 100ms done - tst_res TWARN "Failed to umount($device) after 50 retries" + tst_res TWARN "Failed to umount($mntpoint) after 50 retries" } tst_mkfs()
Signature · 1 line
2.17.0
PATCH v7 1/4 lib: tst_umount: umount a mount point instead of a device
Hi!
testcases/lib/tst_test.sh tst_mount() · line 292
Quoted 1 line
testcases/lib/tst_test.sh +1
-0+ tst_res TINFO "The '$mntpoint' is not mounted upon, skipping umount"
^ I would remove this 'upon' here
Otherwise:
Reviewed-by Cyril Hrubis <[email protected]>
Signature · 2 lines
Cyril Hrubis [email protected]