* [PATCH 1/2] common/config: make set_prog_path() accept one argument only
@ 2017-05-06 0:19 Eric Biggers
2017-05-06 0:19 ` [PATCH 2/2] common/config: implement set_prog_path() using 'type -P' Eric Biggers
0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2017-05-06 0:19 UTC (permalink / raw)
To: fstests; +Cc: Eric Biggers
From: Eric Biggers <ebiggers@google.com>
All callers of set_prog_path() pass it only one argument, the program to
find on the $PATH. Therefore, to simplify things remove the unused code
which allowed fallback paths to be specified in the remaining arguments.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
common/config | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/common/config b/common/config
index 59041a39..b29c0eb0 100644
--- a/common/config
+++ b/common/config
@@ -93,7 +93,7 @@ export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
export RECREATE_TEST_DEV=false
-# $1 = prog to look for, $2* = default pathnames if not found in $PATH
+# $1 = prog to look for
set_prog_path()
{
p=`which $1 2> /dev/null`
@@ -101,17 +101,6 @@ set_prog_path()
echo $p
return 0
fi
- p=$1
-
- shift
- for f; do
- if [ -x $f ]; then
- echo $f
- return 0
- fi
- done
-
- echo ""
return 1
}
--
2.13.0.rc1.294.g07d810a77f-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH 2/2] common/config: implement set_prog_path() using 'type -P'
2017-05-06 0:19 [PATCH 1/2] common/config: make set_prog_path() accept one argument only Eric Biggers
@ 2017-05-06 0:19 ` Eric Biggers
0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2017-05-06 0:19 UTC (permalink / raw)
To: fstests; +Cc: Eric Biggers
From: Eric Biggers <ebiggers@google.com>
Bash's 'type -P' builtin is equivalent to 'which', but it's more
efficient because it doesn't involve executing an external binary.
Because set_prog_path() is executed 60+ times in common/config, which is
sourced by common/rc, which in turn is sourced by every test, switching
to 'type -P' actually can make a noticeable performance improvement for
short-running or skipped tests. For example:
Before:
# time ./check generic/002
...
Passed all 1 tests
real 0m1.365s
user 0m0.746s
sys 0m0.644s
After:
# time ./check generic/002
...
Passed all 1 tests
real 0m1.026s
user 0m0.511s
sys 0m0.470s
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
common/config | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/common/config b/common/config
index b29c0eb0..8211356c 100644
--- a/common/config
+++ b/common/config
@@ -96,12 +96,7 @@ export RECREATE_TEST_DEV=false
# $1 = prog to look for
set_prog_path()
{
- p=`which $1 2> /dev/null`
- if [ -n "$p" -a -x "$p" ]; then
- echo $p
- return 0
- fi
- return 1
+ type -P $1
}
# Handle mkfs.btrfs which does (or does not) require -f to overwrite
--
2.13.0.rc1.294.g07d810a77f-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-06 0:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-06 0:19 [PATCH 1/2] common/config: make set_prog_path() accept one argument only Eric Biggers
2017-05-06 0:19 ` [PATCH 2/2] common/config: implement set_prog_path() using 'type -P' Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox