From beb3a815883e3dc7ed04f21892bfbade792ff1b2 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sun, 6 Jan 2019 22:11:25 +0000 Subject: [PATCH] all.sh: Always build the list of components to run Build the list of components to run in $RUN_COMPONENTS as part of command line parsing. After parsing the command line, it no longer matters how this list was built. --- tests/scripts/all.sh | 47 ++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 41a6f8816..a9ac3be66 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -103,8 +103,6 @@ pre_initialize_variables () { CONFIG_H='include/mbedtls/config.h' CONFIG_BAK="$CONFIG_H.bak" - COMPONENTS= - ALL_EXCEPT=0 MEMORY=0 FORCE=0 KEEP_GOING=0 @@ -150,7 +148,7 @@ is_component_excluded() # Is $1 excluded via $COMPONENTS (a space-separated list of wildcard # patterns)? set -f - for pattern in $COMPONENTS; do + for pattern in $COMMAND_LINE_COMPONENTS; do set +f case ${1#component_} in $pattern) return 0;; esac done @@ -291,12 +289,15 @@ check_headers_in_cpp () { } pre_parse_command_line () { + COMMAND_LINE_COMPONENTS= + all_except= + while [ $# -gt 0 ]; do case "$1" in --armcc) RUN_ARMCC=1;; --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; - --except) ALL_EXCEPT=1;; + --except) all_except=1;; --force|-f) FORCE=1;; --gnutls-cli) shift; GNUTLS_CLI="$1";; --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; @@ -323,11 +324,28 @@ pre_parse_command_line () { echo >&2 "Run $0 --help for usage." exit 120 ;; - *) - COMPONENTS="$COMPONENTS $1";; + *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";; esac shift done + + if [ -z "$COMMAND_LINE_COMPONENTS" ]; then + all_except=1 + fi + + # Build the list of components to run. + if [ -n "$all_except" ]; then + RUN_COMPONENTS= + for component in $SUPPORTED_COMPONENTS; do + if ! is_component_excluded "$component"; then + RUN_COMPONENTS="$RUN_COMPONENTS $component" + fi + done + else + RUN_COMPONENTS="$COMMAND_LINE_COMPONENTS" + fi + + unset all_except } pre_check_git () { @@ -1228,19 +1246,10 @@ pre_check_tools pre_print_tools cleanup -if [ -n "$COMPONENTS" ] && [ $ALL_EXCEPT -eq 0 ]; then - # Run the components passed on the command line. - for component in $COMPONENTS; do - run_component "component_$component" - done -else - # Run all components except those excluded on the command line. - for component in $SUPPORTED_COMPONENTS; do - if ! is_component_excluded "$component"; then - run_component "component_$component" - fi - done -fi +# Run the requested tests. +for component in $RUN_COMPONENTS; do + run_component "component_$component" +done # We're done. post_report