mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-22 13:01:10 +00:00
all.sh: list components automatically
Extract the list of available components by looking for definitions of functions called component_xxx. The previous code explicitly listed all components in run_all_components, which opened the risk of forgetting to list a component there. Add a conditional execution facility: if a function support_xxx exists and returns false then component_xxx is not executed (except when the command line lists an explicit set of components to execute).
This commit is contained in:
parent
a1fc4b5ead
commit
878cf60172
|
@ -62,6 +62,8 @@
|
||||||
# * component_check_XXX: quick tests that aren't worth parallelizing
|
# * component_check_XXX: quick tests that aren't worth parallelizing
|
||||||
# * component_build_XXX: build things but don't run them
|
# * component_build_XXX: build things but don't run them
|
||||||
# * component_test_XXX: build and test
|
# * component_test_XXX: build and test
|
||||||
|
# * support_XXX: if support_XXX exists and returns false then
|
||||||
|
# component_XXX is not run by default.
|
||||||
# * post_XXX: things to do after running the tests.
|
# * post_XXX: things to do after running the tests.
|
||||||
# * other: miscellaneous support functions.
|
# * other: miscellaneous support functions.
|
||||||
#
|
#
|
||||||
|
@ -105,7 +107,6 @@ pre_initialize_variables () {
|
||||||
ALL_EXCEPT=0
|
ALL_EXCEPT=0
|
||||||
MEMORY=0
|
MEMORY=0
|
||||||
FORCE=0
|
FORCE=0
|
||||||
INTROSPECTION_MODE=
|
|
||||||
KEEP_GOING=0
|
KEEP_GOING=0
|
||||||
RUN_ARMCC=1
|
RUN_ARMCC=1
|
||||||
|
|
||||||
|
@ -125,12 +126,29 @@ pre_initialize_variables () {
|
||||||
if [ -z "${MAKEFLAGS+set}" ]; then
|
if [ -z "${MAKEFLAGS+set}" ]; then
|
||||||
export MAKEFLAGS="-j"
|
export MAKEFLAGS="-j"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Gather the list of available components. These are the functions
|
||||||
|
# defined in this script whose name starts with "component_".
|
||||||
|
# Parse the script with sed, because in sh there is no way to list
|
||||||
|
# defined functions.
|
||||||
|
ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0")
|
||||||
|
|
||||||
|
# Exclude components that are not supported on this platform.
|
||||||
|
SUPPORTED_COMPONENTS=
|
||||||
|
for component in $ALL_COMPONENTS; do
|
||||||
|
case $(type "support_$component" 2>&1) in
|
||||||
|
*' function'*)
|
||||||
|
if ! support_$component; then continue; fi;;
|
||||||
|
esac
|
||||||
|
SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test whether $1 is excluded via $COMPONENTS (a space-separated list of
|
# Test whether $1 is excluded via the command line.
|
||||||
# wildcard patterns).
|
is_component_excluded()
|
||||||
component_is_excluded()
|
|
||||||
{
|
{
|
||||||
|
# Is $1 excluded via $COMPONENTS (a space-separated list of wildcard
|
||||||
|
# patterns)?
|
||||||
set -f
|
set -f
|
||||||
for pattern in $COMPONENTS; do
|
for pattern in $COMPONENTS; do
|
||||||
set +f
|
set +f
|
||||||
|
@ -149,7 +167,8 @@ 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.
|
||||||
--list-components List available test components and exit.
|
--list-all-components List all available test components and exit.
|
||||||
|
--list-components List components supported on this platform and exit.
|
||||||
|
|
||||||
General options:
|
General options:
|
||||||
-f|--force Force the tests to overwrite any modified files.
|
-f|--force Force the tests to overwrite any modified files.
|
||||||
|
@ -285,7 +304,8 @@ pre_parse_command_line () {
|
||||||
--gnutls-serv) shift; GNUTLS_SERV="$1";;
|
--gnutls-serv) shift; GNUTLS_SERV="$1";;
|
||||||
--help|-h) usage; exit;;
|
--help|-h) usage; exit;;
|
||||||
--keep-going|-k) KEEP_GOING=1;;
|
--keep-going|-k) KEEP_GOING=1;;
|
||||||
--list-components) INTROSPECTION_MODE=list_components;;
|
--list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;;
|
||||||
|
--list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;;
|
||||||
--memory|-m) MEMORY=1;;
|
--memory|-m) MEMORY=1;;
|
||||||
--no-armcc) RUN_ARMCC=0;;
|
--no-armcc) RUN_ARMCC=0;;
|
||||||
--no-force) FORCE=0;;
|
--no-force) FORCE=0;;
|
||||||
|
@ -854,6 +874,12 @@ component_test_m32_o0 () {
|
||||||
msg "test: i386, make, gcc -O0 (ASan build)"
|
msg "test: i386, make, gcc -O0 (ASan build)"
|
||||||
make test
|
make test
|
||||||
}
|
}
|
||||||
|
support_test_m32_o0 () {
|
||||||
|
case $(uname -m) in
|
||||||
|
*64*) true;;
|
||||||
|
*) false;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
component_test_m32_o1 () {
|
component_test_m32_o1 () {
|
||||||
# Build again with -O1, to compile in the i386 specific inline assembly
|
# Build again with -O1, to compile in the i386 specific inline assembly
|
||||||
|
@ -864,6 +890,9 @@ component_test_m32_o1 () {
|
||||||
msg "test: i386, make, gcc -O1 (ASan build)"
|
msg "test: i386, make, gcc -O1 (ASan build)"
|
||||||
make test
|
make test
|
||||||
}
|
}
|
||||||
|
support_test_m32_o1 () {
|
||||||
|
support_test_m32_o0 "$@"
|
||||||
|
}
|
||||||
|
|
||||||
component_test_mx32 () {
|
component_test_mx32 () {
|
||||||
msg "build: 64-bit ILP32, make, gcc" # ~ 30s
|
msg "build: 64-bit ILP32, make, gcc" # ~ 30s
|
||||||
|
@ -873,6 +902,12 @@ component_test_mx32 () {
|
||||||
msg "test: 64-bit ILP32, make, gcc"
|
msg "test: 64-bit ILP32, make, gcc"
|
||||||
make test
|
make test
|
||||||
}
|
}
|
||||||
|
support_test_mx32 () {
|
||||||
|
case $(uname -m) in
|
||||||
|
amd64|x86_64) true;;
|
||||||
|
*) false;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
component_test_have_int32 () {
|
component_test_have_int32 () {
|
||||||
msg "build: gcc, force 32-bit bignum limbs"
|
msg "build: gcc, force 32-bit bignum limbs"
|
||||||
|
@ -1164,79 +1199,8 @@ post_report () {
|
||||||
#### Run all the things
|
#### Run all the things
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
run_all_components () {
|
|
||||||
# Small things
|
|
||||||
run_component component_check_recursion
|
|
||||||
run_component component_check_generated_files
|
|
||||||
run_component component_check_doxy_blocks
|
|
||||||
run_component component_check_files
|
|
||||||
run_component component_check_names
|
|
||||||
run_component component_check_doxygen_warnings
|
|
||||||
|
|
||||||
# Test many different configurations
|
|
||||||
run_component component_test_default_cmake_gcc_asan
|
|
||||||
run_component component_test_ref_configs
|
|
||||||
run_component component_test_sslv3
|
|
||||||
run_component component_test_no_renegotiation
|
|
||||||
run_component component_test_rsa_no_crt
|
|
||||||
run_component component_test_small_ssl_out_content_len
|
|
||||||
run_component component_test_small_ssl_in_content_len
|
|
||||||
run_component component_test_small_ssl_dtls_max_buffering
|
|
||||||
run_component component_test_small_mbedtls_ssl_dtls_max_buffering
|
|
||||||
run_component component_test_full_cmake_clang
|
|
||||||
run_component component_build_deprecated
|
|
||||||
run_component component_test_depends_curves
|
|
||||||
run_component component_test_depends_hashes
|
|
||||||
run_component component_test_depends_pkalgs
|
|
||||||
run_component component_build_key_exchanges
|
|
||||||
run_component component_build_default_make_gcc_and_cxx
|
|
||||||
run_component component_test_check_params_without_platform
|
|
||||||
run_component component_test_check_params_silent
|
|
||||||
run_component component_test_no_platform
|
|
||||||
run_component component_build_no_std_function
|
|
||||||
run_component component_build_no_ssl_srv
|
|
||||||
run_component component_build_no_ssl_cli
|
|
||||||
run_component component_build_no_sockets
|
|
||||||
run_component component_test_no_max_fragment_length
|
|
||||||
run_component component_test_no_max_fragment_length_small_ssl_out_content_len
|
|
||||||
run_component component_test_null_entropy
|
|
||||||
run_component component_test_platform_calloc_macro
|
|
||||||
run_component component_test_aes_fewer_tables
|
|
||||||
run_component component_test_aes_rom_tables
|
|
||||||
run_component component_test_aes_fewer_tables_and_rom_tables
|
|
||||||
run_component component_test_make_shared
|
|
||||||
case $(uname -m) in
|
|
||||||
amd64|x86_64)
|
|
||||||
run_component component_test_m32_o0
|
|
||||||
run_component component_test_m32_o1
|
|
||||||
run_component component_test_mx32
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
run_component component_test_have_int32
|
|
||||||
run_component component_test_have_int64
|
|
||||||
run_component component_test_no_udbl_division
|
|
||||||
run_component component_test_no_64bit_multiplication
|
|
||||||
run_component component_build_arm_none_eabi_gcc
|
|
||||||
run_component component_build_arm_none_eabi_gcc_no_udbl_division
|
|
||||||
run_component component_build_arm_none_eabi_gcc_no_64bit_multiplication
|
|
||||||
run_component component_build_armcc
|
|
||||||
run_component component_test_allow_sha1
|
|
||||||
run_component component_build_mingw
|
|
||||||
run_component component_test_memsan
|
|
||||||
run_component component_test_memcheck
|
|
||||||
run_component component_test_cmake_out_of_source
|
|
||||||
|
|
||||||
# More small things
|
|
||||||
run_component component_test_zeroize
|
|
||||||
run_component component_check_python_files
|
|
||||||
run_component component_check_generate_test_code
|
|
||||||
}
|
|
||||||
|
|
||||||
# Run one component and clean up afterwards.
|
# Run one component and clean up afterwards.
|
||||||
run_component () {
|
run_component () {
|
||||||
if [ $ALL_EXCEPT -ne 0 ] && component_is_excluded "$1"; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
# Back up the configuration in case the component modifies it.
|
# Back up the configuration in case the component modifies it.
|
||||||
# The cleanup function will restore it.
|
# The cleanup function will restore it.
|
||||||
cp -p "$CONFIG_H" "$CONFIG_BAK"
|
cp -p "$CONFIG_H" "$CONFIG_BAK"
|
||||||
|
@ -1250,47 +1214,33 @@ pre_check_environment
|
||||||
pre_initialize_variables
|
pre_initialize_variables
|
||||||
pre_parse_command_line "$@"
|
pre_parse_command_line "$@"
|
||||||
|
|
||||||
case "$INTROSPECTION_MODE" in
|
pre_check_git
|
||||||
list_components)
|
build_status=0
|
||||||
components=
|
if [ $KEEP_GOING -eq 1 ]; then
|
||||||
newline='
|
pre_setup_keep_going
|
||||||
'
|
else
|
||||||
run_component () {
|
record_status () {
|
||||||
components="${components}${newline}${1#component_}"
|
"$@"
|
||||||
}
|
}
|
||||||
;;
|
fi
|
||||||
|
pre_print_configuration
|
||||||
*)
|
pre_check_tools
|
||||||
pre_check_git
|
pre_print_tools
|
||||||
build_status=0
|
cleanup
|
||||||
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" ] && [ $ALL_EXCEPT -eq 0 ]; then
|
if [ -n "$COMPONENTS" ] && [ $ALL_EXCEPT -eq 0 ]; then
|
||||||
|
# Run the components passed on the command line.
|
||||||
for component in $COMPONENTS; do
|
for component in $COMPONENTS; do
|
||||||
run_component "component_$component"
|
run_component "component_$component"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
run_all_components
|
# 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
|
fi
|
||||||
|
|
||||||
# We're done.
|
# We're done.
|
||||||
case "$INTROSPECTION_MODE" in
|
post_report
|
||||||
list_components)
|
|
||||||
echo "$components" | sort
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
post_report
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
Loading…
Reference in a new issue