blob: e9a2b96d3fed82075989a4a566e2b84f841c694e [file] [log] [blame]
Minos Galanakis6aab5b72024-07-25 14:24:37 +01001# components-platform.sh
2#
3# Copyright The Mbed TLS Contributors
4# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
5
Minos Galanakis609f7492024-07-31 16:39:28 +01006# This file contains test components that are executed by all.sh
Minos Galanakis6aab5b72024-07-25 14:24:37 +01007
8################################################################
9#### Platform Testing
10################################################################
11
Minos Galanakis8a980902024-07-26 17:41:03 +010012component_test_malloc_0_null () {
13 msg "build: malloc(0) returns NULL (ASan+UBSan build)"
14 scripts/config.py full
15 make CC=$ASAN_CC CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"$PWD/tests/configs/user-config-malloc-0-null.h\"' $ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
16
17 msg "test: malloc(0) returns NULL (ASan+UBSan build)"
18 make test
19
20 msg "selftest: malloc(0) returns NULL (ASan+UBSan build)"
21 # Just the calloc selftest. "make test" ran the others as part of the
22 # test suites.
23 programs/test/selftest calloc
24
25 msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)"
26 # Run a subset of the tests. The choice is a balance between coverage
27 # and time (including time indirectly wasted due to flaky tests).
28 # The current choice is to skip tests whose description includes
29 # "proxy", which is an approximation of skipping tests that use the
30 # UDP proxy, which tend to be slower and flakier.
31 tests/ssl-opt.sh -e 'proxy'
32}
33
34component_test_m32_no_asm () {
35 # Build without assembly, so as to use portable C code (in a 32-bit
36 # build) and not the i386-specific inline assembly.
37 #
38 # Note that we require gcc, because clang Asan builds fail to link for
39 # this target (cannot find libclang_rt.lsan-i386.a - this is a known clang issue).
40 msg "build: i386, make, gcc, no asm (ASan build)" # ~ 30s
41 scripts/config.py full
42 scripts/config.py unset MBEDTLS_HAVE_ASM
43 scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
44 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS"
45
46 msg "test: i386, make, gcc, no asm (ASan build)"
47 make test
48}
49
50support_test_m32_no_asm () {
51 case $(uname -m) in
52 amd64|x86_64) true;;
53 *) false;;
54 esac
55}
56
57component_test_m32_o2 () {
58 # Build with optimization, to use the i386 specific inline assembly
59 # and go faster for tests.
60 msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s
61 scripts/config.py full
62 scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
63 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS"
64
65 msg "test: i386, make, gcc -O2 (ASan build)"
66 make test
67
68 msg "test ssl-opt.sh, i386, make, gcc-O2"
69 tests/ssl-opt.sh
70}
71
72support_test_m32_o2 () {
73 support_test_m32_no_asm "$@"
74}
75
76component_test_m32_everest () {
77 msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
78 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
79 scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
80 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS"
81
82 msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
83 make test
84
85 msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
86 tests/ssl-opt.sh -f ECDH
87
88 msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
89 # Exclude some symmetric ciphers that are redundant here to gain time.
90 tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA'
91}
92
93support_test_m32_everest () {
94 support_test_m32_no_asm "$@"
95}
96
97component_test_mx32 () {
98 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
99 scripts/config.py full
100 make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -mx32' LDFLAGS='-mx32'
101
102 msg "test: 64-bit ILP32, make, gcc"
103 make test
104}
105
106support_test_mx32 () {
107 case $(uname -m) in
108 amd64|x86_64) true;;
109 *) false;;
110 esac
111}
112
113component_build_zeroize_checks () {
114 msg "build: check for obviously wrong calls to mbedtls_platform_zeroize()"
115
116 scripts/config.py full
117
118 # Only compile - we're looking for sizeof-pointer-memaccess warnings
119 make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-zeroize-memset.h\"' -DMBEDTLS_TEST_DEFINES_ZEROIZE -Werror -Wsizeof-pointer-memaccess"
120}
121