[PATCH v2 lkp-tests] tests/*: fix double mount problem

check mountpoint before mount destination dir to prevent mount twice problem Signed-off-by: Wang Yong <wangyong0117@qq.com> --- tests/cci-depends | 2 ++ tests/cci-makepkg | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/cci-depends b/tests/cci-depends index efa9a025b..4b885dc0c 100755 --- a/tests/cci-depends +++ b/tests/cci-depends @@ -7,6 +7,7 @@ . $LKP_SRC/lib/debug.sh . $LKP_SRC/lib/misc-base.sh +. $LKP_SRC/lib/mount.sh [ -n "$benchmark" ] || die "benchmark is empty" [ -n "$os_mount" ] || die "os_mount is empty" @@ -28,6 +29,7 @@ pack_arch=$os_arch . $LKP_SRC/distro/$DISTRO +is_mount_point ${DEPS_MNT} && umount ${DEPS_MNT} mount -t cifs -o guest,vers=1.0,noacl,nouser_xattr //$LKP_SERVER$DEPS_MNT $DEPS_MNT || die "Failed to run mount" umask 002 diff --git a/tests/cci-makepkg b/tests/cci-makepkg index 9551ebfe2..a105f1895 100755 --- a/tests/cci-makepkg +++ b/tests/cci-makepkg @@ -13,6 +13,7 @@ . $LKP_SRC/lib/debug.sh . $LKP_SRC/lib/misc-base.sh . $LKP_SRC/lib/env.sh +. $LKP_SRC/lib/mount.sh [ -n "$benchmark" ] || die "benchmark is empty" [ -n "$os_mount" ] || die "os_mount is empty" @@ -34,6 +35,7 @@ pack_to=${os_mount}/${os}/${os_arch}/${os_version}/${benchmark} cd $LKP_SRC/pkg/$benchmark || die "pkg is empty" [ -n "$LKP_SERVER" ] && { + is_mount_point ${PKG_MNT} && umount ${PKG_MNT} mount -t cifs -o guest,vers=1.0,noacl,nouser_xattr //$LKP_SERVER$PKG_MNT $PKG_MNT || die "Failed to run mount" } -- 2.23.0

On Tue, Nov 10, 2020 at 10:01:13AM +0800, Wang Yong wrote:
check mountpoint before mount destination dir to prevent mount twice problem
It looks good to me. I think you can modify all the other scripts that may cause mount error. Thanks, Ping
Signed-off-by: Wang Yong <wangyong0117@qq.com> --- tests/cci-depends | 2 ++ tests/cci-makepkg | 2 ++ 2 files changed, 4 insertions(+)
diff --git a/tests/cci-depends b/tests/cci-depends index efa9a025b..4b885dc0c 100755 --- a/tests/cci-depends +++ b/tests/cci-depends @@ -7,6 +7,7 @@
. $LKP_SRC/lib/debug.sh . $LKP_SRC/lib/misc-base.sh +. $LKP_SRC/lib/mount.sh
[ -n "$benchmark" ] || die "benchmark is empty" [ -n "$os_mount" ] || die "os_mount is empty" @@ -28,6 +29,7 @@ pack_arch=$os_arch
. $LKP_SRC/distro/$DISTRO
+is_mount_point ${DEPS_MNT} && umount ${DEPS_MNT} mount -t cifs -o guest,vers=1.0,noacl,nouser_xattr //$LKP_SERVER$DEPS_MNT $DEPS_MNT || die "Failed to run mount"
umask 002 diff --git a/tests/cci-makepkg b/tests/cci-makepkg index 9551ebfe2..a105f1895 100755 --- a/tests/cci-makepkg +++ b/tests/cci-makepkg @@ -13,6 +13,7 @@ . $LKP_SRC/lib/debug.sh . $LKP_SRC/lib/misc-base.sh . $LKP_SRC/lib/env.sh +. $LKP_SRC/lib/mount.sh
[ -n "$benchmark" ] || die "benchmark is empty" [ -n "$os_mount" ] || die "os_mount is empty" @@ -34,6 +35,7 @@ pack_to=${os_mount}/${os}/${os_arch}/${os_version}/${benchmark} cd $LKP_SRC/pkg/$benchmark || die "pkg is empty"
[ -n "$LKP_SERVER" ] && { + is_mount_point ${PKG_MNT} && umount ${PKG_MNT} mount -t cifs -o guest,vers=1.0,noacl,nouser_xattr //$LKP_SERVER$PKG_MNT $PKG_MNT || die "Failed to run mount" }
-- 2.23.0

On Tue, Nov 10, 2020 at 11:28:29AM +0800, Li Ping wrote:
On Tue, Nov 10, 2020 at 10:01:13AM +0800, Wang Yong wrote:
check mountpoint before mount destination dir to prevent mount twice problem
It looks good to me. I think you can modify all the other scripts that may cause mount error.
I check all the script under LKP_SRC/tests/, thre are umount operation if mount many times. Thanks, Wang Yong

On Tue, Nov 10, 2020 at 11:28:29AM +0800, Li Ping wrote:
On Tue, Nov 10, 2020 at 10:01:13AM +0800, Wang Yong wrote:
check mountpoint before mount destination dir to prevent mount twice problem
It looks good to me. I think you can modify all the other scripts that may cause mount error.
Thanks, Ping
如果使用mount的地方较多,可以封装一个safe_mount的lib库 Thanks sunyukui
Signed-off-by: Wang Yong <wangyong0117@qq.com> --- tests/cci-depends | 2 ++ tests/cci-makepkg | 2 ++ 2 files changed, 4 insertions(+)
diff --git a/tests/cci-depends b/tests/cci-depends index efa9a025b..4b885dc0c 100755 --- a/tests/cci-depends +++ b/tests/cci-depends @@ -7,6 +7,7 @@
. $LKP_SRC/lib/debug.sh . $LKP_SRC/lib/misc-base.sh +. $LKP_SRC/lib/mount.sh
[ -n "$benchmark" ] || die "benchmark is empty" [ -n "$os_mount" ] || die "os_mount is empty" @@ -28,6 +29,7 @@ pack_arch=$os_arch
. $LKP_SRC/distro/$DISTRO
+is_mount_point ${DEPS_MNT} && umount ${DEPS_MNT} mount -t cifs -o guest,vers=1.0,noacl,nouser_xattr //$LKP_SERVER$DEPS_MNT $DEPS_MNT || die "Failed to run mount"
umask 002 diff --git a/tests/cci-makepkg b/tests/cci-makepkg index 9551ebfe2..a105f1895 100755 --- a/tests/cci-makepkg +++ b/tests/cci-makepkg @@ -13,6 +13,7 @@ . $LKP_SRC/lib/debug.sh . $LKP_SRC/lib/misc-base.sh . $LKP_SRC/lib/env.sh +. $LKP_SRC/lib/mount.sh
[ -n "$benchmark" ] || die "benchmark is empty" [ -n "$os_mount" ] || die "os_mount is empty" @@ -34,6 +35,7 @@ pack_to=${os_mount}/${os}/${os_arch}/${os_version}/${benchmark} cd $LKP_SRC/pkg/$benchmark || die "pkg is empty"
[ -n "$LKP_SERVER" ] && { + is_mount_point ${PKG_MNT} && umount ${PKG_MNT} mount -t cifs -o guest,vers=1.0,noacl,nouser_xattr //$LKP_SERVER$PKG_MNT $PKG_MNT || die "Failed to run mount" }
-- 2.23.0
participants (3)
-
Li Ping
-
Sun Yukui
-
Wang Yong