blob: b408bec618774084dda0f762bb5eaaee5c5a67b7 [file] [log] [blame]
Minos Galanakisada21b02024-07-26 12:34:19 +01001# components-configuration-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 Galanakisada21b02024-07-26 12:34:19 +01007
8################################################################
9#### Configuration Testing - Platform
10################################################################
Minos Galanakisf6e1adc2024-07-26 15:42:20 +010011
12component_build_no_std_function () {
13 # catch compile bugs in _uninit functions
14 msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
15 scripts/config.py full
16 scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
17 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
18 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
19 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
20 make
21}
22
Ronald Croneb16a9d2025-09-03 09:57:29 +020023component_test_psa_driver_get_entropy()
Valerio Setti1afedac2025-05-06 06:27:02 +020024{
Ronald Croneb16a9d2025-09-03 09:57:29 +020025 msg "build: default - MBEDTLS_PSA_BUILTIN_GET_ENTROPY + MBEDTLS_PSA_DRIVER_GET_ENTROPY"
Valerio Setti1afedac2025-05-06 06:27:02 +020026 # Use hardware polling as the only source for entropy
Ronald Croneb16a9d2025-09-03 09:57:29 +020027 scripts/config.py unset MBEDTLS_PSA_BUILTIN_GET_ENTROPY
Valerio Setti1afedac2025-05-06 06:27:02 +020028 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Ronald Croneb16a9d2025-09-03 09:57:29 +020029 scripts/config.py set MBEDTLS_PSA_DRIVER_GET_ENTROPY
Valerio Setti1afedac2025-05-06 06:27:02 +020030
31 make
32
33 # Run all the tests
Ronald Croneb16a9d2025-09-03 09:57:29 +020034 msg "test: default - MBEDTLS_PSA_BUILTIN_GET_ENTROPY + MBEDTLS_PSA_DRIVER_GET_ENTROPY"
Valerio Setti1afedac2025-05-06 06:27:02 +020035 make test
36}
37
Minos Galanakisf6e1adc2024-07-26 15:42:20 +010038component_build_no_sockets () {
39 # Note, C99 compliance can also be tested with the sockets support disabled,
40 # as that requires a POSIX platform (which isn't the same as C99).
41 msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
42 scripts/config.py full
43 scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
Ronald Croneb16a9d2025-09-03 09:57:29 +020044 scripts/config.py unset MBEDTLS_PSA_BUILTIN_GET_ENTROPY # prevent syscall() on GNU/Linux
45 scripts/config.py set MBEDTLS_PSA_DRIVER_GET_ENTROPY
Minos Galanakisf6e1adc2024-07-26 15:42:20 +010046 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib
47}
48
49component_test_no_date_time () {
50 msg "build: default config without MBEDTLS_HAVE_TIME_DATE"
51 scripts/config.py unset MBEDTLS_HAVE_TIME_DATE
52 cmake -D CMAKE_BUILD_TYPE:String=Check .
53 make
54
55 msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites"
56 make test
57}
58
59component_test_platform_calloc_macro () {
60 msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
61 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
62 scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
63 scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free
64 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
65 make
66
67 msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
68 make test
69}
70
71component_test_have_int32 () {
72 msg "build: gcc, force 32-bit bignum limbs"
73 scripts/config.py unset MBEDTLS_HAVE_ASM
74 scripts/config.py unset MBEDTLS_AESNI_C
75 scripts/config.py unset MBEDTLS_AESCE_C
76 make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
77
78 msg "test: gcc, force 32-bit bignum limbs"
79 make test
80}
81
82component_test_have_int64 () {
83 msg "build: gcc, force 64-bit bignum limbs"
84 scripts/config.py unset MBEDTLS_HAVE_ASM
85 scripts/config.py unset MBEDTLS_AESNI_C
86 scripts/config.py unset MBEDTLS_AESCE_C
87 make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
88
89 msg "test: gcc, force 64-bit bignum limbs"
90 make test
91}
92
93component_test_have_int32_cmake_new_bignum () {
94 msg "build: gcc, force 32-bit bignum limbs, new bignum interface, test hooks (ASan build)"
95 scripts/config.py unset MBEDTLS_HAVE_ASM
96 scripts/config.py unset MBEDTLS_AESNI_C
97 scripts/config.py unset MBEDTLS_AESCE_C
98 scripts/config.py set MBEDTLS_TEST_HOOKS
99 scripts/config.py set MBEDTLS_ECP_WITH_MPI_UINT
100 make CC=gcc CFLAGS="$ASAN_CFLAGS -Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32" LDFLAGS="$ASAN_CFLAGS"
101
102 msg "test: gcc, force 32-bit bignum limbs, new bignum interface, test hooks (ASan build)"
103 make test
104}
105
106component_test_no_udbl_division () {
107 msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
108 scripts/config.py full
109 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
110 make CFLAGS='-Werror -O1'
111
112 msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
113 make test
114}
115
116component_test_no_64bit_multiplication () {
117 msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
118 scripts/config.py full
119 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
120 make CFLAGS='-Werror -O1'
121
122 msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
123 make test
124}