[LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR

Li Wang liwang@redhat.com
Thu Apr 13 09:57:53 CEST 2023


On Wed, Apr 12, 2023 at 3:40 PM Petr Vorel <pvorel@suse.cz> wrote:

> NFS tests have problem when TMPDIR path contains double slashes,
> because they grep exportfs output which is normalized.
>

I'm ok to remove redundant slashes, I just wondering where
is the second slash comes from?
Is that added by accident when env variable definition?

>
> Problem is either trailing slash:
>
> $ TMPDIR=/var/tmp/ nfs01.sh -t tcp
> ...
> nfs01 1 TINFO: Mounting NFS: mount -v -t nfs -o proto=tcp,vers=3 10.0.0.2:/var/tmp//LTP_nfs01.sIqm4LLS4u/3/tcp
> /var/tmp//LTP_nfs01.sIqm4LLS4u/3/0
> nfs01 1 TINFO: starting 'nfs01_open_files 1000'
> nfs01 1 TPASS: test finished successfully
> nfs01 2 TINFO: Cleaning up testcase
> nfs01 2 TINFO: remote_dir: '/var/tmp//LTP_nfs01.sIqm4LLS4u/3/tcp'
> exportfs: Could not find '*:/var/tmp//LTP_nfs01.sIqm4LLS4u/3/tcp' to
> unexport.
> rm: cannot remove '/var/tmp//LTP_nfs01.sIqm4LLS4u/3/0': Device or resource
> busy
> rm: cannot remove '/var/tmp//LTP_nfs01.sIqm4LLS4u/3/0': Is a directory
>
> or double (or more) slashes (anywhere in $TMPDIR):
>
> $ TMPDIR=/var//tmp nfs01.sh -t tcp
> nfs01 1 TINFO: Mounting NFS: mount -v -t nfs -o proto=tcp,vers=3 10.0.0.2:/var//tmp/LTP_nfs01.qNjSsopVbY/3/tcp
> /var//tmp/LTP_nfs01.qNjSsopVbY/3/0
> nfs01 1 TINFO: starting 'nfs01_open_files 1000'
> nfs01 1 TPASS: test finished successfully
> nfs01 2 TINFO: Cleaning up testcase
> nfs01 2 TINFO: remote_dir: '/var//tmp/LTP_nfs01.qNjSsopVbY/3/tcp'
> exportfs: Could not find '*:/var//tmp/LTP_nfs01.qNjSsopVbY/3/tcp' to
> unexport.
> rm: cannot remove '/var//tmp/LTP_nfs01.qNjSsopVbY/3/0': Device or resource
> busy
> rm: cannot remove '/var//tmp/LTP_nfs01.qNjSsopVbY/3/0': Is a directory
>
> While this could be handled in nfs_lib.sh, it's better to save it for
> all tests. It's easier to modify $TST_TMPDIR, because the problem
> narrows down to double slash.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/lib/tst_test.sh | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index c817eec77..42f60ab58 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -722,6 +722,8 @@ tst_run()
>                 fi
>
>                 TST_TMPDIR=$(mktemp -d "$TMPDIR/LTP_$TST_ID.XXXXXXXXXX")
> +               # remove possible trailing slash or double slashes from
> TMPDIR
> +               TST_TMPDIR=$(echo "$TST_TMPDIR" | sed 's~/\+~/~g')
>
>                 chmod 777 "$TST_TMPDIR"
>
> --
> 2.40.0
>
>

-- 
Regards,
Li Wang


More information about the ltp mailing list