[LTP] [PATCH] unshare01.sh: Setup parent mount flag before unshare testing

Petr Vorel pvorel@suse.cz
Mon Jun 7 11:42:49 CEST 2021


Hi Yang, Zhongyi,

> Hi Zhongyi, Petr

> I don't like the approach which enforces mountpoint to be shared in parent
> mount namespace.
> I think we can tune expected value by checking propagation flag in parent
> mount namespace because of two reasons:
> 1) Make test cover more cases.
> 2) Don't depend on the fixed tmpfs.

> Zhongyi,  could you test the following patch on your enviorment?
> -------------------------------------------------------------------------------------------------
> diff --git a/testcases/commands/unshare/unshare01.sh
> b/testcases/commands/unshare/unshare01.sh
> index bf163a7f4..78ea83fc0 100755
> --- a/testcases/commands/unshare/unshare01.sh
> +++ b/testcases/commands/unshare/unshare01.sh
> @@ -40,6 +40,17 @@ max_mntns_path="/proc/sys/user/max_mnt_namespaces"
>  default_max_userns=-1
>  default_max_mntns=-1

> +parse_propagation_flag()
> +{
> +       mount --bind dir_A dir_B
> +       if grep -w 'dir_B' /proc/self/mountinfo | grep -qw 'shared'; then
> +               echo "mounted"
> +       else
> +               echo "unmounted"
> +       fi
> +       umount dir_B
> +}
> +
>  setup()
>  {
>         # On some distributions(e.g RHEL7.4), the default value of
> @@ -149,7 +160,8 @@ do_test()
>         4) unshare_test "--user --map-root-user" "id -g" "0";;
>         5) unshare_test "--mount" "mount --bind dir_A dir_B" "unmounted";;
>         6) unshare_test "--mount --propagation shared" \
> -                       "mount --bind dir_A dir_B" "mounted";;
> +                       "mount --bind dir_A dir_B" \
> +                       "$(parse_propagation_flag)";;
>         7) unshare_test "--user --map-root-user --mount" \
>                         "mount --bind dir_A dir_B" "unmounted";;
>         8) unshare_test "--user --map-root-user --mount --propagation
> shared" \

Sorry for a big delay in this.
Your changes makes sense to me, ack.

Kind regards,
Petr


More information about the ltp mailing list