mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-13 09:11:06 +00:00
SCRIPTS: run-regtests: reduce the number of processes needed to check options
run-tegtests is starting to take a lot of time to spot which tests are eligible, because for each test file a lot of "sed" sub-processes are launched. This commit eliminates calls to sed by using the shell's internal processing and parsing the VTC file only once. Instead of extracting each option one by one from the file, all entries that look like a valid option are passed to a single case/esac statement and their value is extracted. Splitting into lists is simply done by adjusting the IFS depending on the list's delimiter, which, contrary to the // pattern modifier, is supported on every shell. This was tested on both bash and dash, and the tests' execution time dropped by 31% from 8.7 seconds to 6.0 seconds.
This commit is contained in:
parent
ec347b1239
commit
969e7afa0d
@ -120,13 +120,32 @@ _findtests() {
|
||||
any_test=$(echo $REGTESTS_TYPES | grep -cw "any")
|
||||
for i in $( find "$1" -name *.vtc ); do
|
||||
skiptest=
|
||||
require_version="$(sed -ne 's/^#REQUIRE_VERSION=//p' "$i")"
|
||||
require_version_below="$(sed -ne 's/^#REQUIRE_VERSION_BELOW=//p' "$i")"
|
||||
require_options="$(sed -ne 's/^#REQUIRE_OPTIONS=//p' "$i" | sed -e 's/,/ /g')"
|
||||
require_services="$(sed -ne 's/^#REQUIRE_SERVICES=//p' "$i" | sed -e 's/,/ /g')"
|
||||
exclude_targets="$(sed -ne 's/^#EXCLUDE_TARGETS=//p' "$i" | sed -e 's/,/ /g')"
|
||||
OLDIFS="$IFS"; IFS="$LINEFEED"
|
||||
set -- $(grep '^#[0-9A-Z_]*=' "$i")
|
||||
IFS="$OLDIFS"
|
||||
|
||||
require_version=""; require_version_below=""; require_options="";
|
||||
require_services=""; exclude_targets=""; regtest_type=""
|
||||
requiredoption=""; requiredservice=""; excludedtarget="";
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
v="$1"; v="${v#*=}"
|
||||
case "$1" in
|
||||
"#REQUIRE_VERSION="*) require_version="$v" ;;
|
||||
"#REQUIRE_VERSION_BELOW="*) require_version_below="$v" ;;
|
||||
"#REQUIRE_OPTIONS="*) require_options="$v" ;;
|
||||
"#REQUIRE_SERVICES="*) require_services="$v" ;;
|
||||
"#EXCLUDE_TARGETS="*) exclude_targets="$v" ;;
|
||||
"#REGTEST_TYPE="*) regtest_type="$v" ;;
|
||||
"#REQUIRE_OPTION="*) requiredoption="${v%,*}" ;;
|
||||
"#REQUIRE_SERVICE="*) required_service="${v%,*}" ;;
|
||||
"#EXCLUDE_TARGET="*) excludedtarget="${v%,*}" ;;
|
||||
# Note: any new variable declared here must be initialized above.
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ $any_test -ne 1 ] ; then
|
||||
regtest_type="$(sed -ne 's/^#REGTEST_TYPE=//p' "$i")"
|
||||
if [ -z $regtest_type ] ; then
|
||||
regtest_type=default
|
||||
fi
|
||||
@ -136,21 +155,22 @@ _findtests() {
|
||||
fi
|
||||
fi
|
||||
|
||||
requiredoption="$(sed -ne 's/^#REQUIRE_OPTION=//p' "$i" | sed -e 's/,.*//')"
|
||||
if [ -n "$requiredoption" ]; then
|
||||
require_options="$require_options $requiredoption"
|
||||
require_options="$require_options,$requiredoption"
|
||||
fi
|
||||
|
||||
requiredservice="$(sed -ne 's/^#REQUIRE_SERVICE=//p' "$i" | sed -e 's/,.*//')"
|
||||
if [ -n "$requiredservice" ]; then
|
||||
require_services="$require_services $requiredservice"
|
||||
require_services="$require_services,$requiredservice"
|
||||
fi
|
||||
|
||||
excludedtarget="$(sed -ne 's/^#EXCLUDE_TARGET=//p' "$i" | sed -e 's/,.*//')"
|
||||
if [ -n "$excludedtarget" ]; then
|
||||
exclude_targets="$exclude_targets $excludedtarget"
|
||||
exclude_targets="$exclude_targets,$excludedtarget"
|
||||
fi
|
||||
|
||||
IFS=","; set -- $require_options; IFS=$OLDIFS; require_options="$*"
|
||||
IFS=","; set -- $require_services; IFS=$OLDIFS; require_services="$*"
|
||||
IFS=","; set -- $exclude_targets; IFS=$OLDIFS; exclude_targets="$*"
|
||||
|
||||
if [ -n "$require_version" ]; then
|
||||
if [ $(_version "$HAPROXY_VERSION") -lt $(_version "$require_version") ]; then
|
||||
echo " Skip $i because option haproxy is version: $HAPROXY_VERSION"
|
||||
@ -174,7 +194,7 @@ _findtests() {
|
||||
done
|
||||
|
||||
for requiredoption in $require_options; do
|
||||
alternatives=$(echo "$requiredoption" | sed -e 's/|/ /g')
|
||||
IFS="|"; set -- $requiredoption; IFS=$OLDIFS; alternatives="$*"
|
||||
found=
|
||||
for alt in $alternatives; do
|
||||
if echo "$FEATURES" | grep -qw "\+$alt"; then
|
||||
@ -188,7 +208,7 @@ _findtests() {
|
||||
done
|
||||
|
||||
for requiredservice in $require_services; do
|
||||
alternatives=$(echo "$requiredservice" | sed -e 's/|/ /g')
|
||||
IFS="|"; set -- $requiredservice; IFS=$OLDIFS; alternatives="$*"
|
||||
found=
|
||||
for alt in $alternatives; do
|
||||
if echo "$SERVICES" | grep -qw "$alt"; then
|
||||
@ -291,6 +311,8 @@ HAPROXY_ARGS="${HAPROXY_ARGS--dM}"
|
||||
VTEST_PROGRAM="${VTEST_PROGRAM:-vtest}"
|
||||
TESTDIR="${TMPDIR:-/tmp}"
|
||||
REGTESTS=""
|
||||
LINEFEED="
|
||||
"
|
||||
|
||||
jobcount=""
|
||||
verbose="-q"
|
||||
|
Loading…
Reference in New Issue
Block a user