All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Zorro Lang <zlang@redhat.com>
Cc: Theodore Ts'o <tytso@mit.edu>, fstests@vger.kernel.org
Subject: [PATCH] fstests: reduce runtime of check -n
Date: Mon, 19 Jun 2023 13:50:58 +0300	[thread overview]
Message-ID: <20230619105058.2711467-1-amir73il@gmail.com> (raw)

kvm-xfstests invokes check -n twice to pre-process and generate the
tests-to-run list, which is then being passed as a long list of tests
for invkoing check in the command line.

check invokes dirname, basename and sed several times per test just
for doing basic string prefix/suffix trimming.
Use bash string pattern matching instead which is much faster.

Note that the following pattern matching expression change:
< test_dir=${test_dir#$SRC_DIR/*}
> t=${t#$SRC_DIR/}
does not change the meaning of the expression, because the
shortest match of "$SRC_DIR/*" that is being trimmed is "$SRC_DIR/"
and removing the tests/ prefix is what this code intended to do.

With check -n, there is no need to cleanup the results dir,
but check -n is doing that for every single listed test.
Move the cleanup of results dir to before actually running the test.

These improvements to check pre-test code cut down several minutes
from the time until tests actually start to run with kvm-xfstests.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---

Zorro,

Just to clarify, this change is not expected to change behavior -
only to improve runtime of check -n and the things that happen
before the first test is invoked.

Thanks,
Amir.

 check | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/check b/check
index e36978c1..1a16eccb 100755
--- a/check
+++ b/check
@@ -399,9 +399,9 @@ if $have_test_arg; then
 		*)	# Expand test pattern (e.g. xfs/???, *fs/001)
 			list=$(cd $SRC_DIR; echo $1)
 			for t in $list; do
-				test_dir=`dirname $t`
-				test_dir=${test_dir#$SRC_DIR/*}
-				test_name=`basename $t`
+				t=${t#$SRC_DIR/}
+				test_dir=${t%/*}
+				test_name=${t#*/}
 				group_file=$SRC_DIR/$test_dir/group.list
 
 				if grep -Eq "^$test_name" $group_file; then
@@ -849,18 +849,14 @@ function run_section()
 
 		# the filename for the test and the name output are different.
 		# we don't include the tests/ directory in the name output.
-		export seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
-
-		# Similarly, the result directory needs to replace the tests/
-		# part of the test location.
-		group=`dirname $seq`
+		export seqnum=${seq#$SRC_DIR/}
+		group=${seqnum%/*}
 		if $OPTIONS_HAVE_SECTIONS; then
-			export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;${RESULT_BASE}/$section;"`
 			REPORT_DIR="$RESULT_BASE/$section"
 		else
-			export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;$RESULT_BASE;"`
 			REPORT_DIR="$RESULT_BASE"
 		fi
+		export RESULT_DIR="$REPORT_DIR/$group"
 		seqres="$REPORT_DIR/$seqnum"
 
 		# Generate the entire section report with whatever test results
@@ -872,9 +868,6 @@ function run_section()
 					     "" &> /dev/null
 		fi
 
-		mkdir -p $RESULT_DIR
-		rm -f ${RESULT_DIR}/require_scratch*
-		rm -f ${RESULT_DIR}/require_test*
 		echo -n "$seqnum"
 
 		if $showme; then
@@ -899,6 +892,9 @@ function run_section()
 		fi
 
 		# really going to try and run this one
+		mkdir -p $RESULT_DIR
+		rm -f ${RESULT_DIR}/require_scratch*
+		rm -f ${RESULT_DIR}/require_test*
 		rm -f $seqres.out.bad $seqres.hints
 
 		# check if we really should run it
-- 
2.34.1


             reply	other threads:[~2023-06-19 10:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 10:50 Amir Goldstein [this message]
2023-06-21  1:13 ` [PATCH] fstests: reduce runtime of check -n Zorro Lang
2023-06-21  2:23 ` Zorro Lang
2023-06-21  9:26   ` David Disseldorp
2023-06-21 12:09     ` Amir Goldstein
2023-06-21 12:42       ` David Disseldorp
2023-06-21 13:01         ` Amir Goldstein
2023-06-23 15:29       ` Zorro Lang
2023-06-24  5:32         ` Amir Goldstein

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=20230619105058.2711467-1-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=zlang@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.