Skip to content

Commit

Permalink
Add all.sh component that exercises invalid_param checks
Browse files Browse the repository at this point in the history
With the config changes, there were no longer any tests that exercise
invalid-parameter behavior. The test suite exercises invalid-parameter
behavior by calling TEST_INVALID_PARAM and friends, relying on the
test suite's mbedtls_check_param function, which is only enabled if
MBEDTLS_CHECK_PARAMS is not defined. Add a component to all.sh that
enables MBEDTLS_CHECK_PARAMS but doesn't define MBEDTLS_PARAM_FAILED
so that these tests are exercised. Since sample programs don't provide
a mbedtls_check_param function, this component doesn't build the
sample programs.
  • Loading branch information
gilles-peskine-arm committed Jun 12, 2019
1 parent 9912205 commit ac1858b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/scripts/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -859,9 +859,23 @@ component_test_do_use_psa_crypto_full_cmake_asan() {
if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
}

component_test_check_params_tests () {
msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()"
scripts/config.pl full # includes CHECK_PARAMS
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
# With MBEDTLS_PARAM_FAILED unset in config.h, the
# mbedtls_param_failed function gets called.
scripts/config.pl unset MBEDTLS_CHECK_PARAMS
# Only build and run tests. Do not build sample programs, because
# they don't have a mbedtls_param_failed function.
make CC=gcc CFLAGS='-Werror -O1' lib test
}

component_test_check_params_without_platform () {
msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C"
scripts/config.pl full # includes CHECK_PARAMS
# Set MBEDTLS_PARAM_FAILED to assert
# sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond ).*\)/\1/' "$CONFIG_H"
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Expand All @@ -880,6 +894,7 @@ component_test_check_params_silent () {
msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()"
scripts/config.pl veryfull # includes CHECK_PARAMS
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
# Set MBEDTLS_PARAM_FAILED to nothing
sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H"
make CC=gcc CFLAGS='-Werror -O1' all test
}
Expand Down

0 comments on commit ac1858b

Please sign in to comment.