public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR
@ 2023-04-12  7:39 Petr Vorel
  2023-04-12  7:41 ` Petr Vorel
  2023-04-13  7:57 ` Li Wang
  0 siblings, 2 replies; 6+ messages in thread
From: Petr Vorel @ 2023-04-12  7:39 UTC (permalink / raw)
  To: ltp

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

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR
  2023-04-12  7:39 [LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR Petr Vorel
@ 2023-04-12  7:41 ` Petr Vorel
  2023-04-13  7:57 ` Li Wang
  1 sibling, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2023-04-12  7:41 UTC (permalink / raw)
  To: ltp

Hi,

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

If you agree with the fix in the library, I'll send a patch also for C API.

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR
  2023-04-12  7:39 [LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR Petr Vorel
  2023-04-12  7:41 ` Petr Vorel
@ 2023-04-13  7:57 ` Li Wang
  2023-04-13  8:02   ` Petr Vorel
  1 sibling, 1 reply; 6+ messages in thread
From: Li Wang @ 2023-04-13  7:57 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR
  2023-04-13  7:57 ` Li Wang
@ 2023-04-13  8:02   ` Petr Vorel
  2023-04-13  8:20     ` Li Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2023-04-13  8:02 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp

> 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?

Yes, that's the last slash in TMPDIR=/var/tmp/.
TMPDIR=/var/tmp would work.

Kind regards,
Petr

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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR
  2023-04-13  8:02   ` Petr Vorel
@ 2023-04-13  8:20     ` Li Wang
  2023-04-26 17:29       ` Petr Vorel
  0 siblings, 1 reply; 6+ messages in thread
From: Li Wang @ 2023-04-13  8:20 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

On Thu, Apr 13, 2023 at 4:02 PM Petr Vorel <pvorel@suse.cz> wrote:

> > 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?
>
> Yes, that's the last slash in TMPDIR=/var/tmp/.
> TMPDIR=/var/tmp would work.
>

Ok, I agree with the secondary treatment inside lib (includes C API),
as we can't grantee the all users to remember this trivial.

Reviewed-by: Li Wang <liwang@redhat.com>


-- 
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR
  2023-04-13  8:20     ` Li Wang
@ 2023-04-26 17:29       ` Petr Vorel
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2023-04-26 17:29 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp

Hi Li,

> > > > 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?

> > Yes, that's the last slash in TMPDIR=/var/tmp/.
> > TMPDIR=/var/tmp would work.


> Ok, I agree with the secondary treatment inside lib (includes C API),
> as we can't grantee the all users to remember this trivial.

> Reviewed-by: Li Wang <liwang@redhat.com>

thanks, merged!

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-04-26 17:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-12  7:39 [LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR Petr Vorel
2023-04-12  7:41 ` Petr Vorel
2023-04-13  7:57 ` Li Wang
2023-04-13  8:02   ` Petr Vorel
2023-04-13  8:20     ` Li Wang
2023-04-26 17:29       ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox