Skip to contentSkip to conversation

lib/tst_test.sh: Make tst_umount work with argument has trailing slash

PATCH Superseded Leo Liang 2 participants 2 messages Jul 19, 2021 – Jul 21, 2021

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Leo Liang

author
#0 lore raw

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

/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.

---
 testcases/lib/tst_test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/lib/tst_test.sh +1 -1
index c6aa2c487..cbdfb707a 100644
@@ -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
Signature · 1 line
2.17.0