Skip to content

Commit 34a0272

Browse files
Support wildcard patterns with a positive list of components to run
Wildcard patterns now work with command line COMPONENT arguments without --except as well as with. You can now run e.g. `all.sh "check_*` to run all the sanity checks.
1 parent 98fe8d4 commit 34a0272

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

tests/scripts/all.sh

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,9 @@ pre_initialize_variables () {
154154
done
155155
}
156156

157-
# Test whether $1 is excluded via the command line.
158-
is_component_excluded()
157+
# Test whether the component $1 is included in the command line patterns.
158+
is_component_included()
159159
{
160-
# Is $1 excluded via $COMPONENTS (a space-separated list of wildcard
161-
# patterns)?
162160
set -f
163161
for pattern in $COMMAND_LINE_COMPONENTS; do
164162
set +f
@@ -174,6 +172,13 @@ usage()
174172
Usage: $0 [OPTION]... [COMPONENT]...
175173
Run mbedtls release validation tests.
176174
By default, run all tests. With one or more COMPONENT, run only those.
175+
COMPONENT can be the name of a component or a shell wildcard pattern.
176+
177+
Examples:
178+
$0 "check_*"
179+
Run all sanity checks.
180+
$0 --no-armcc --except test_memsan
181+
Run everything except builds that require armcc and MemSan.
177182
178183
Special options:
179184
-h|--help Print this help and exit.
@@ -185,11 +190,8 @@ General options:
185190
-k|--keep-going Run all tests and report errors at the end.
186191
-m|--memory Additional optional memory tests.
187192
--armcc Run ARM Compiler builds (on by default).
188-
--except If some components are passed on the command line,
189-
run all the tests except for these components. In
190-
this mode, you can pass shell wildcard patterns as
191-
component names, e.g. "$0 --except 'test_*'" to
192-
exclude all components that run tests.
193+
--except Exclude the COMPONENTs listed on the command line,
194+
instead of running only those.
193195
--no-armcc Skip ARM Compiler builds.
194196
--no-force Refuse to overwrite modified files (default).
195197
--no-keep-going Stop at the first error (default).
@@ -302,7 +304,7 @@ check_headers_in_cpp () {
302304

303305
pre_parse_command_line () {
304306
COMMAND_LINE_COMPONENTS=
305-
all_except=
307+
all_except=0
306308
no_armcc=
307309

308310
while [ $# -gt 0 ]; do
@@ -342,27 +344,24 @@ pre_parse_command_line () {
342344
shift
343345
done
344346

347+
# With no list of components, run everything.
345348
if [ -z "$COMMAND_LINE_COMPONENTS" ]; then
346349
all_except=1
347350
fi
348351

349352
# --no-armcc is a legacy option. The modern way is --except '*_armcc*'.
350353
# Ignore it if components are listed explicitly on the command line.
351-
if [ -n "$no_armcc" ] && [ -n "$all_except" ]; then
354+
if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then
352355
COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*"
353356
fi
354357

355358
# Build the list of components to run.
356-
if [ -n "$all_except" ]; then
357-
RUN_COMPONENTS=
358-
for component in $SUPPORTED_COMPONENTS; do
359-
if ! is_component_excluded "$component"; then
360-
RUN_COMPONENTS="$RUN_COMPONENTS $component"
361-
fi
362-
done
363-
else
364-
RUN_COMPONENTS="$COMMAND_LINE_COMPONENTS"
365-
fi
359+
RUN_COMPONENTS=
360+
for component in $SUPPORTED_COMPONENTS; do
361+
if is_component_included "$component"; [ $? -eq $all_except ]; then
362+
RUN_COMPONENTS="$RUN_COMPONENTS $component"
363+
fi
364+
done
366365

367366
unset all_except
368367
unset no_armcc

0 commit comments

Comments
 (0)