diff mbox series

[v4,1/2] lib/tst_test.sh: Make tst_umount work with argument has trailing slash

Message ID 20210719092107.GA1406@atcfdc88
State Changes Requested
Headers show
Series cgroup/cgroup_regression_test: Fix umount failure | expand

Commit Message

Leo Yu-Chi Liang July 19, 2021, 9:21 a.m. UTC
/proc/mounts shows the mount point without trailing slashes, e.g.
~ $ cat /proc/mounts
xxx /root/cgroup cgroup rw,relatime,cpu 0 0

So current tst_umount would not work with argument that has trailing slash, e.g.
tst_umount cgroup/ would give "The device is not mounted".

Fix this by filtering out the trailing slash in the argument for grep.

Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
---
 testcases/lib/tst_test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Petr Vorel July 21, 2021, 2:21 p.m. UTC | #1
Hi Leo,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index c6aa2c487..cbdfb707a 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -282,7 +282,7 @@  tst_umount()
 
 	[ -z "$device" ] && return
 
-	if ! grep -q "$device" /proc/mounts; then
+	if ! grep -q "${device%/}" /proc/mounts; then
 		tst_res TINFO "The $device is not mounted, skipping umount"
 		return
 	fi