|
| 1 | +# components-configuration.sh |
| 2 | +# |
| 3 | +# Copyright The Mbed TLS Contributors |
| 4 | +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 5 | + |
| 6 | +# This file contains test components that are executed by all.sh |
| 7 | + |
| 8 | +################################################################ |
| 9 | +#### Configuration Testing |
| 10 | +################################################################ |
| 11 | + |
| 12 | +component_tf_psa_crypto_test_default_out_of_box () { |
| 13 | + msg "build: make, default config (out-of-box)" # ~1min |
| 14 | + cd $OUT_OF_SOURCE_DIR |
| 15 | + cmake -DCMAKE_BUILD_TYPE:String=Check -DGEN_FILES=ON "$TF_PSA_CRYPTO_ROOT_DIR" |
| 16 | + make |
| 17 | + # Disable fancy stuff |
| 18 | + unset MBEDTLS_TEST_OUTCOME_FILE |
| 19 | + |
| 20 | + msg "test: main suites make, default config (out-of-box)" # ~10s |
| 21 | + make test |
| 22 | +} |
| 23 | + |
| 24 | +component_tf_psa_crypto_test_default_cmake_gcc_asan () { |
| 25 | + msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
| 26 | + cd $OUT_OF_SOURCE_DIR |
| 27 | + cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE:String=Asan -DGEN_FILES=ON "$TF_PSA_CRYPTO_ROOT_DIR" |
| 28 | + make |
| 29 | + |
| 30 | + msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 31 | + make test |
| 32 | +} |
| 33 | + |
| 34 | +component_tf_psa_crypto_test_default_cmake_gcc_asan_new_bignum () { |
| 35 | + msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
| 36 | + scripts/config.py set MBEDTLS_ECP_WITH_MPI_UINT |
| 37 | + cd $OUT_OF_SOURCE_DIR |
| 38 | + cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE:String=Asan -DGEN_FILES=ON "$TF_PSA_CRYPTO_ROOT_DIR" |
| 39 | + make |
| 40 | + |
| 41 | + msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 42 | + make test |
| 43 | +} |
| 44 | + |
| 45 | +component_tf_psa_crypto_test_full_cmake_gcc_asan () { |
| 46 | + msg "build: full config, cmake, gcc, ASan" |
| 47 | + scripts/config.py full |
| 48 | + cd $OUT_OF_SOURCE_DIR |
| 49 | + cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE:String=Asan -DGEN_FILES=ON "$TF_PSA_CRYPTO_ROOT_DIR" |
| 50 | + make |
| 51 | + |
| 52 | + msg "test: main suites (inc. selftests) (full config, ASan build)" |
| 53 | + make test |
| 54 | +} |
| 55 | + |
| 56 | +component_tf_psa_crypto_test_full_cmake_gcc_asan_new_bignum () { |
| 57 | + msg "build: full config, cmake, gcc, ASan" |
| 58 | + scripts/config.py full |
| 59 | + scripts/config.py set MBEDTLS_ECP_WITH_MPI_UINT |
| 60 | + cd $OUT_OF_SOURCE_DIR |
| 61 | + cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE:String=Asan -DGEN_FILES=ON "$TF_PSA_CRYPTO_ROOT_DIR" |
| 62 | + make |
| 63 | + |
| 64 | + msg "test: main suites (inc. selftests) (full config, new bignum, ASan)" |
| 65 | + make test |
| 66 | +} |
| 67 | + |
| 68 | +component_tf_psa_crypto_test_full_cmake_clang () { |
| 69 | + msg "build: cmake, full config, clang" # ~ 50s |
| 70 | + scripts/config.py full |
| 71 | + cd $OUT_OF_SOURCE_DIR |
| 72 | + cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang -DCMAKE_BUILD_TYPE:String=Release -DENABLE_TESTING=ON -DTEST_CPP=1 -DGEN_FILES=ON "$TF_PSA_CRYPTO_ROOT_DIR" |
| 73 | + make |
| 74 | + |
| 75 | + msg "test: main suites (full config, clang)" # ~ 5s |
| 76 | + make test |
| 77 | +} |
| 78 | + |
| 79 | +component_tf_psa_crypto_build_tfm () { |
| 80 | + # Check that the TF-M configuration can build cleanly with various |
| 81 | + # warning flags enabled. We don't build or run tests, since the |
| 82 | + # TF-M configuration needs a TF-M platform. A tweaked version of |
| 83 | + # the configuration that works on mainstream platforms is in |
| 84 | + # configs/config-tfm.h, tested via test-ref-configs.pl. |
| 85 | + cp configs/ext/crypto_config_profile_medium.h "$CRYPTO_CONFIG_H" |
| 86 | + |
| 87 | + cd $OUT_OF_SOURCE_DIR |
| 88 | + msg "build: TF-M config, clang, armv7-m thumb2" |
| 89 | + cmake -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS="--target=arm-linux-gnueabihf -march=armv7-m -mthumb -Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused -I../framework/tests/include/spe" "$TF_PSA_CRYPTO_ROOT_DIR" |
| 90 | + make |
| 91 | + |
| 92 | + cd $TF_PSA_CRYPTO_ROOT_DIR |
| 93 | + rm -rf $OUT_OF_SOURCE_DIR |
| 94 | + mkdir $OUT_OF_SOURCE_DIR |
| 95 | + cd $OUT_OF_SOURCE_DIR |
| 96 | + msg "build: TF-M config, gcc native build" |
| 97 | + cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_C_FLAGS="-Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wformat-signedness -Wlogical-op -I../framework/tests/include/spe" |
| 98 | + make |
| 99 | +} |
| 100 | + |
| 101 | +component_tf_psa_crypto_test_malloc_0_null () { |
| 102 | + msg "build: malloc(0) returns NULL (ASan+UBSan build)" |
| 103 | + scripts/config.py full |
| 104 | + cd $OUT_OF_SOURCE_DIR |
| 105 | + cmake -DCMAKE_C_COMPILER="$ASAN_CC" -DCMAKE_C_FLAGS="'-DTF_PSA_CRYPTO_USER_CONFIG_FILE=\"$PWD/tests/configs/user-config-malloc-0-null.h\"' $ASAN_CFLAGS" -DCMAKE_EXE_LINKER_FLAGS="$ASAN_CFLAGS" "$TF_PSA_CRYPTO_ROOT_DIR" |
| 106 | + make |
| 107 | + |
| 108 | + msg "test: malloc(0) returns NULL (ASan+UBSan build)" |
| 109 | + make test |
| 110 | +} |
| 111 | + |
| 112 | +component_tf_psa_crypto_test_memory_buffer_allocator_backtrace () { |
| 113 | + msg "build: default config with memory buffer allocator and backtrace enabled" |
| 114 | + scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 115 | + scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 116 | + scripts/config.py set MBEDTLS_MEMORY_BACKTRACE |
| 117 | + scripts/config.py set MBEDTLS_MEMORY_DEBUG |
| 118 | + cd $OUT_OF_SOURCE_DIR |
| 119 | + cmake -DCMAKE_BUILD_TYPE:String=Release -DGEN_FILES=ON "$TF_PSA_CRYPTO_ROOT_DIR" |
| 120 | + make |
| 121 | + |
| 122 | + msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" |
| 123 | + make test |
| 124 | +} |
| 125 | + |
| 126 | +component_tf_psa_crypto_test_memory_buffer_allocator () { |
| 127 | + msg "build: default config with memory buffer allocator" |
| 128 | + scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 129 | + scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 130 | + cd $OUT_OF_SOURCE_DIR |
| 131 | + cmake -DCMAKE_BUILD_TYPE:String=Release -DGEN_FILES=ON "$TF_PSA_CRYPTO_ROOT_DIR" |
| 132 | + make |
| 133 | + |
| 134 | + msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 135 | + make test |
| 136 | +} |
0 commit comments