all.sh: with non-option arguments, run only these components

This commit is contained in:
Gilles Peskine 2018-11-27 18:15:35 +01:00
parent 348fb9a597
commit 92525111dc

View file

@ -104,6 +104,7 @@ pre_initialize_variables () {
CONFIG_H='include/mbedtls/config.h' CONFIG_H='include/mbedtls/config.h'
CONFIG_BAK="$CONFIG_H.bak" CONFIG_BAK="$CONFIG_H.bak"
COMPONENTS=
MEMORY=0 MEMORY=0
FORCE=0 FORCE=0
INTROSPECTION_MODE= INTROSPECTION_MODE=
@ -131,8 +132,9 @@ pre_initialize_variables () {
usage() usage()
{ {
cat <<EOF cat <<EOF
Usage: $0 [OPTION]... Usage: $0 [OPTION]... [COMPONENT]...
Run mbedtls release validation tests. Run mbedtls release validation tests.
By default, run all tests. With one or more COMPONENT, run only those.
Special options: Special options:
-h|--help Print this help and exit. -h|--help Print this help and exit.
@ -275,11 +277,13 @@ pre_parse_command_line () {
--random-seed) unset SEED;; --random-seed) unset SEED;;
--release-test|-r) SEED=1;; --release-test|-r) SEED=1;;
--seed|-s) shift; SEED="$1";; --seed|-s) shift; SEED="$1";;
*) -*)
echo >&2 "Unknown option: $1" echo >&2 "Unknown option: $1"
echo >&2 "Run $0 --help for usage." echo >&2 "Run $0 --help for usage."
exit 120 exit 120
;; ;;
*)
COMPONENTS="$COMPONENTS $1";;
esac esac
shift shift
done done
@ -1139,44 +1143,7 @@ post_report () {
#### Run all the things #### Run all the things
################################################################ ################################################################
# Run one component and clean up afterwards. run_all_components () {
run_component () {
"$@"
cleanup
}
# Preliminary setup
pre_check_environment
pre_initialize_variables
pre_parse_command_line "$@"
case "$INTROSPECTION_MODE" in
list_components)
components=
newline='
'
run_component () {
components="${components}${newline}${1}"
}
;;
*)
pre_check_git
build_status=0
if [ $KEEP_GOING -eq 1 ]; then
pre_setup_keep_going
else
record_status () {
"$@"
}
fi
pre_print_configuration
pre_check_tools
pre_print_tools
cleanup
;;
esac
# Small things # Small things
run_component component_check_recursion run_component component_check_recursion
run_component component_check_generated_files run_component component_check_generated_files
@ -1244,6 +1211,53 @@ run_component component_test_cmake_out_of_source
run_component component_test_zeroize run_component component_test_zeroize
run_component component_check_python_files run_component component_check_python_files
run_component component_check_generate_test_code run_component component_check_generate_test_code
}
# Run one component and clean up afterwards.
run_component () {
"$@"
cleanup
}
# Preliminary setup
pre_check_environment
pre_initialize_variables
pre_parse_command_line "$@"
case "$INTROSPECTION_MODE" in
list_components)
components=
newline='
'
run_component () {
components="${components}${newline}${1#component_}"
}
;;
*)
pre_check_git
build_status=0
if [ $KEEP_GOING -eq 1 ]; then
pre_setup_keep_going
else
record_status () {
"$@"
}
fi
pre_print_configuration
pre_check_tools
pre_print_tools
cleanup
;;
esac
if [ -n "$COMPONENTS" ]; then
for component in $COMPONENTS; do
run_component "component_$component"
done
else
run_all_components
fi
# We're done. # We're done.
case "$INTROSPECTION_MODE" in case "$INTROSPECTION_MODE" in