ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR
Date: Wed, 12 Apr 2023 09:39:53 +0200	[thread overview]
Message-ID: <20230412073953.1983857-1-pvorel@suse.cz> (raw)

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

             reply	other threads:[~2023-04-12  7:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12  7:39 Petr Vorel [this message]
2023-04-12  7:41 ` [LTP] [PATCH 1/1] tst_test.sh: Remove possible double/trailing slashes from TMPDIR 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

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=20230412073953.1983857-1-pvorel@suse.cz \
    --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;
as well as URLs for NNTP newsgroup(s).