From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] unshare01.sh: Setup parent mount flag before unshare testing
Date: Wed, 24 Feb 2021 02:40:17 +0100 [thread overview]
Message-ID: <YDWugcEDg/z4tRrX@pevik> (raw)
In-Reply-To: <20210223140323.126555-1-zhaogongyi@huawei.com>
Hi,
> We need setup parent mount flag to shared before unshare testing, or it will
> fail for system which has no systemd service since the propagation flag is
> changed by systemd. From man 7 mount_namespaces.
Do I understand correctly that all distros without systemd are affected,
because systemd "automatically remounts all mount points as MS_SHARED
on system startup" and test expect it?
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
> testcases/commands/unshare/unshare01.sh | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
> diff --git a/testcases/commands/unshare/unshare01.sh b/testcases/commands/unshare/unshare01.sh
> index bf163a7f4..e1fb15035 100755
> --- a/testcases/commands/unshare/unshare01.sh
> +++ b/testcases/commands/unshare/unshare01.sh
> @@ -31,7 +31,6 @@ TST_SETUP=setup
> TST_CLEANUP=cleanup
> TST_TESTFUNC=do_test
> TST_NEEDS_ROOT=1
> -TST_NEEDS_TMPDIR=1
You still need TST_NEEDS_TMPDIR=1, because you create files and directories.
Also your patch breaks bind test on very old systems (kernel 2.6, util-linux
2.17.2, glibc 2.12):
unshare01 5 TFAIL: unshare --mount mount --bind dir_A dir_B got bind info
Any idea why (how to avoid this regression)?
> TST_NEEDS_CMDS="unshare id mount umount"
> . tst_test.sh
> @@ -39,6 +38,7 @@ max_userns_path="/proc/sys/user/max_user_namespaces"
> max_mntns_path="/proc/sys/user/max_mnt_namespaces"
> default_max_userns=-1
> default_max_mntns=-1
> +CURR=$(pwd)
Instead of $CURR, cd - can be used.
> setup()
> {
> @@ -55,6 +55,10 @@ setup()
> echo 1024 > "${max_mntns_path}"
> fi
> + mkdir $CURR/dir_C
just mkdir dir_C
> + mount -t tmpfs none dir_C
> + mount --make-shared dir_C
FYI We have tst_mount, but it'd not help much here.
> + cd dir_C
> mkdir -p dir_A dir_B
> touch dir_A/A dir_B/B
> }
> @@ -66,6 +70,9 @@ cleanup()
> echo ${default_max_userns} > "${max_userns_path}"
> [ ${default_max_mntns} -ne -1 ] && \
> echo ${default_max_mntns} > "${max_mntns_path}"
> + cd $CURR
> + umount dir_C
tst_umount dir_C
> + rm -rf dir_C
rm is not needed (cleanup is done automatically).
> }
> check_id()
Full diff of changes I propose below.
Kind regards,
Petr
diff --git testcases/commands/unshare/unshare01.sh testcases/commands/unshare/unshare01.sh
index e1fb15035..0b5c56811 100755
--- testcases/commands/unshare/unshare01.sh
+++ testcases/commands/unshare/unshare01.sh
@@ -31,6 +31,7 @@ TST_SETUP=setup
TST_CLEANUP=cleanup
TST_TESTFUNC=do_test
TST_NEEDS_ROOT=1
+TST_NEEDS_TMPDIR=1
TST_NEEDS_CMDS="unshare id mount umount"
. tst_test.sh
@@ -38,7 +39,6 @@ max_userns_path="/proc/sys/user/max_user_namespaces"
max_mntns_path="/proc/sys/user/max_mnt_namespaces"
default_max_userns=-1
default_max_mntns=-1
-CURR=$(pwd)
setup()
{
@@ -55,7 +55,7 @@ setup()
echo 1024 > "${max_mntns_path}"
fi
- mkdir $CURR/dir_C
+ mkdir dir_C
mount -t tmpfs none dir_C
mount --make-shared dir_C
cd dir_C
@@ -70,9 +70,8 @@ cleanup()
echo ${default_max_userns} > "${max_userns_path}"
[ ${default_max_mntns} -ne -1 ] && \
echo ${default_max_mntns} > "${max_mntns_path}"
- cd $CURR
- umount dir_C
- rm -rf dir_C
+ cd - >/dev/null
+ tst_umount dir_C
}
check_id()
next prev parent reply other threads:[~2021-02-24 1:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-23 14:03 [LTP] [PATCH] unshare01.sh: Setup parent mount flag before unshare testing Zhao Gongyi
2021-02-24 1:40 ` Petr Vorel [this message]
2021-02-24 5:01 ` Xiao Yang
2021-06-07 9:42 ` Petr Vorel
-- strict thread matches above, loose matches on Subject: below --
2021-02-25 9:38 zhaogongyi
2021-02-25 10:02 zhaogongyi
2021-02-25 10:57 ` Xiao Yang
2021-02-27 9:46 zhaogongyi
2021-02-28 12:22 ` Xiao Yang
2021-03-01 1:13 zhaogongyi
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=YDWugcEDg/z4tRrX@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