mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-21 23:05:55 +03:00
284 lines
12 KiB
Bash
284 lines
12 KiB
Bash
# components-platform.sh
|
|
#
|
|
# Copyright The Mbed TLS Contributors
|
|
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
|
|
|
# This file contains test components that are executed by all.sh
|
|
|
|
################################################################
|
|
#### Platform Testing
|
|
################################################################
|
|
|
|
component_test_malloc_0_null () {
|
|
msg "build: malloc(0) returns NULL (ASan+UBSan build)"
|
|
scripts/config.py full
|
|
make CC=$ASAN_CC CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"$PWD/tests/configs/user-config-malloc-0-null.h\"' $ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
|
|
|
|
msg "test: malloc(0) returns NULL (ASan+UBSan build)"
|
|
make test
|
|
|
|
msg "selftest: malloc(0) returns NULL (ASan+UBSan build)"
|
|
# Just the calloc selftest. "make test" ran the others as part of the
|
|
# test suites.
|
|
programs/test/selftest calloc
|
|
|
|
msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)"
|
|
# Run a subset of the tests. The choice is a balance between coverage
|
|
# and time (including time indirectly wasted due to flaky tests).
|
|
# The current choice is to skip tests whose description includes
|
|
# "proxy", which is an approximation of skipping tests that use the
|
|
# UDP proxy, which tend to be slower and flakier.
|
|
tests/ssl-opt.sh -e 'proxy'
|
|
}
|
|
|
|
component_test_m32_no_asm () {
|
|
# Build without assembly, so as to use portable C code (in a 32-bit
|
|
# build) and not the i386-specific inline assembly.
|
|
#
|
|
# Note that we require gcc, because clang Asan builds fail to link for
|
|
# this target (cannot find libclang_rt.lsan-i386.a - this is a known clang issue).
|
|
msg "build: i386, make, gcc, no asm (ASan build)" # ~ 30s
|
|
scripts/config.py full
|
|
scripts/config.py unset MBEDTLS_HAVE_ASM
|
|
scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
|
|
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS"
|
|
|
|
msg "test: i386, make, gcc, no asm (ASan build)"
|
|
make test
|
|
}
|
|
|
|
support_test_m32_no_asm () {
|
|
case $(uname -m) in
|
|
amd64|x86_64) true;;
|
|
*) false;;
|
|
esac
|
|
}
|
|
|
|
component_test_m32_o2 () {
|
|
# Build with optimization, to use the i386 specific inline assembly
|
|
# and go faster for tests.
|
|
msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s
|
|
scripts/config.py full
|
|
scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
|
|
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS"
|
|
|
|
msg "test: i386, make, gcc -O2 (ASan build)"
|
|
make test
|
|
|
|
msg "test ssl-opt.sh, i386, make, gcc-O2"
|
|
tests/ssl-opt.sh
|
|
}
|
|
|
|
support_test_m32_o2 () {
|
|
support_test_m32_no_asm "$@"
|
|
}
|
|
|
|
component_test_m32_everest () {
|
|
msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
|
|
scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
|
|
scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
|
|
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS"
|
|
|
|
msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
|
|
make test
|
|
|
|
msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
|
|
tests/ssl-opt.sh -f ECDH
|
|
|
|
msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
|
|
# Exclude some symmetric ciphers that are redundant here to gain time.
|
|
tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA'
|
|
}
|
|
|
|
support_test_m32_everest () {
|
|
support_test_m32_no_asm "$@"
|
|
}
|
|
|
|
component_test_mx32 () {
|
|
msg "build: 64-bit ILP32, make, gcc" # ~ 30s
|
|
scripts/config.py full
|
|
make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -mx32' LDFLAGS='-mx32'
|
|
|
|
msg "test: 64-bit ILP32, make, gcc"
|
|
make test
|
|
}
|
|
|
|
support_test_mx32 () {
|
|
case $(uname -m) in
|
|
amd64|x86_64) true;;
|
|
*) false;;
|
|
esac
|
|
}
|
|
|
|
component_build_zeroize_checks () {
|
|
msg "build: check for obviously wrong calls to mbedtls_platform_zeroize()"
|
|
|
|
scripts/config.py full
|
|
|
|
# Only compile - we're looking for sizeof-pointer-memaccess warnings
|
|
make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-zeroize-memset.h\"' -DMBEDTLS_TEST_DEFINES_ZEROIZE -Werror -Wsizeof-pointer-memaccess"
|
|
}
|
|
|
|
component_build_arm_none_eabi_gcc () {
|
|
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug" # ~ 10s
|
|
scripts/config.py baremetal
|
|
make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -O1' lib
|
|
|
|
msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug"
|
|
${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o
|
|
${ARM_NONE_EABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o
|
|
${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
|
|
}
|
|
|
|
component_build_arm_linux_gnueabi_gcc_arm5vte () {
|
|
msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s
|
|
scripts/config.py baremetal
|
|
# Build for a target platform that's close to what Debian uses
|
|
# for its "armel" distribution (https://wiki.debian.org/ArmEabiPort).
|
|
# See https://github.com/Mbed-TLS/mbedtls/pull/2169 and comments.
|
|
# Build everything including programs, see for example
|
|
# https://github.com/Mbed-TLS/mbedtls/pull/3449#issuecomment-675313720
|
|
make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" AR="${ARM_LINUX_GNUEABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te'
|
|
|
|
msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
|
|
${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t library/*.o
|
|
${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o
|
|
${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
|
|
}
|
|
|
|
support_build_arm_linux_gnueabi_gcc_arm5vte () {
|
|
type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1
|
|
}
|
|
|
|
component_build_arm_none_eabi_gcc_arm5vte () {
|
|
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s
|
|
scripts/config.py baremetal
|
|
# This is an imperfect substitute for
|
|
# component_build_arm_linux_gnueabi_gcc_arm5vte
|
|
# in case the gcc-arm-linux-gnueabi toolchain is not available
|
|
make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" CFLAGS='-std=c99 -Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib
|
|
|
|
msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
|
|
${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o
|
|
${ARM_NONE_EABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o
|
|
${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
|
|
}
|
|
|
|
component_build_arm_none_eabi_gcc_m0plus () {
|
|
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus, baremetal_size" # ~ 10s
|
|
scripts/config.py baremetal_size
|
|
make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -mthumb -mcpu=cortex-m0plus -Os' lib
|
|
|
|
msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os, baremetal_size"
|
|
${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o
|
|
${ARM_NONE_EABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o
|
|
${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
|
|
for lib in library/*.a; do
|
|
echo "$lib:"
|
|
${ARM_NONE_EABI_GCC_PREFIX}size -t $lib | grep TOTALS
|
|
done
|
|
}
|
|
|
|
component_build_arm_none_eabi_gcc_no_udbl_division () {
|
|
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
|
|
scripts/config.py baremetal
|
|
scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
|
|
make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra' lib
|
|
echo "Checking that software 64-bit division is not required"
|
|
not grep __aeabi_uldiv library/*.o
|
|
not grep __aeabi_uldiv ${PSA_CORE_PATH}/*.o
|
|
not grep __aeabi_uldiv ${BUILTIN_SRC_PATH}/*.o
|
|
}
|
|
|
|
component_build_arm_none_eabi_gcc_no_64bit_multiplication () {
|
|
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
|
|
scripts/config.py baremetal
|
|
scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
|
|
make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -O1 -march=armv6-m -mthumb' lib
|
|
echo "Checking that software 64-bit multiplication is not required"
|
|
not grep __aeabi_lmul library/*.o
|
|
not grep __aeabi_lmul ${PSA_CORE_PATH}/*.o
|
|
not grep __aeabi_lmul ${BUILTIN_SRC_PATH}/*.o
|
|
}
|
|
|
|
component_build_arm_clang_thumb () {
|
|
# ~ 30s
|
|
|
|
scripts/config.py baremetal
|
|
|
|
msg "build: clang thumb 2, make"
|
|
make clean
|
|
make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -march=armv7-m -mthumb' lib
|
|
|
|
# Some Thumb 1 asm is sensitive to optimisation level, so test both -O0 and -Os
|
|
msg "build: clang thumb 1 -O0, make"
|
|
make clean
|
|
make CC="clang" CFLAGS='-std=c99 -Werror -O0 --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib
|
|
|
|
msg "build: clang thumb 1 -Os, make"
|
|
make clean
|
|
make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib
|
|
}
|
|
|
|
component_build_armcc () {
|
|
msg "build: ARM Compiler 5"
|
|
scripts/config.py baremetal
|
|
# armc[56] don't support SHA-512 intrinsics
|
|
scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT
|
|
|
|
# older versions of armcc/armclang don't support AESCE_C on 32-bit Arm
|
|
scripts/config.py unset MBEDTLS_AESCE_C
|
|
|
|
# Stop armclang warning about feature detection for A64_CRYPTO.
|
|
# With this enabled, the library does build correctly under armclang,
|
|
# but in baremetal builds (as tested here), feature detection is
|
|
# unavailable, and the user is notified via a #warning. So enabling
|
|
# this feature would prevent us from building with -Werror on
|
|
# armclang. Tracked in #7198.
|
|
scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
|
|
|
|
scripts/config.py set MBEDTLS_HAVE_ASM
|
|
|
|
make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
|
|
|
|
msg "size: ARM Compiler 5"
|
|
"$ARMC5_FROMELF" -z library/*.o
|
|
"$ARMC5_FROMELF" -z ${PSA_CORE_PATH}/*.o
|
|
"$ARMC5_FROMELF" -z ${BUILTIN_SRC_PATH}/*.o
|
|
|
|
# Compile mostly with -O1 since some Arm inline assembly is disabled for -O0.
|
|
|
|
# ARM Compiler 6 - Target ARMv7-A
|
|
armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-a"
|
|
|
|
# ARM Compiler 6 - Target ARMv7-M
|
|
armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-m"
|
|
|
|
# ARM Compiler 6 - Target ARMv7-M+DSP
|
|
armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-m+dsp"
|
|
|
|
# ARM Compiler 6 - Target ARMv8-A - AArch32
|
|
armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv8.2-a"
|
|
|
|
# ARM Compiler 6 - Target ARMv8-M
|
|
armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv8-m.main"
|
|
|
|
# ARM Compiler 6 - Target Cortex-M0 - no optimisation
|
|
armc6_build_test "-O0 --target=arm-arm-none-eabi -mcpu=cortex-m0"
|
|
|
|
# ARM Compiler 6 - Target Cortex-M0
|
|
armc6_build_test "-Os --target=arm-arm-none-eabi -mcpu=cortex-m0"
|
|
|
|
# ARM Compiler 6 - Target ARMv8.2-A - AArch64
|
|
#
|
|
# Re-enable MBEDTLS_AESCE_C as this should be supported by the version of armclang
|
|
# that we have in our CI
|
|
scripts/config.py set MBEDTLS_AESCE_C
|
|
armc6_build_test "-O1 --target=aarch64-arm-none-eabi -march=armv8.2-a+crypto"
|
|
}
|
|
|
|
support_build_armcc () {
|
|
armc5_cc="$ARMC5_BIN_DIR/armcc"
|
|
armc6_cc="$ARMC6_BIN_DIR/armclang"
|
|
(check_tools "$armc5_cc" "$armc6_cc" > /dev/null 2>&1)
|
|
} |