From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v6, 1/4] lib: tst_umount: umount a mount point instead of a device
Date: Mon, 23 Aug 2021 15:48:12 +0200 [thread overview]
Message-ID: <YSOnHBMsOKPqyjLu@pevik> (raw)
In-Reply-To: <20210804015248.GA22328@andestech.com>
> 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 <ycliang@andestech.com>
> ---
> testcases/lib/tst_test.sh | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index c6aa2c487..1060bda2f 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -277,31 +277,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 [[ "$mntpoint" != /* ]]; then
[[ ]] is a bashism, it cannot be used. [1]
Instead grep must be used to compare regex:
if echo "$mntpoint" |grep -q ^/; then
This can be changed during merge.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
[1] https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#22-shell-coding-style
> + 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()
next prev parent reply other threads:[~2021-08-23 13:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-04 1:52 [LTP] [PATCH v6, 1/4] lib: tst_umount: umount a mount point instead of a device Leo Liang
2021-08-23 13:48 ` Petr Vorel [this message]
2021-08-23 14:19 ` Petr Vorel
2021-08-24 11:27 ` Leo Liang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YSOnHBMsOKPqyjLu@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox