Minos Galanakis | 6aab5b7 | 2024-07-25 14:24:37 +0100 | [diff] [blame] | 1 | # components.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 the test components that are executed by all.sh |
| 7 | |
| 8 | # The functions below are named as follows: |
| 9 | # * component_XXX: independent components. They can be run in any order. |
| 10 | # * component_check_XXX: quick tests that aren't worth parallelizing. |
| 11 | # * component_build_XXX: build things but don't run them. |
| 12 | # * component_test_XXX: build and test. |
| 13 | # * component_release_XXX: tests that the CI should skip during PR testing. |
| 14 | # * support_XXX: if support_XXX exists and returns false then |
| 15 | # component_XXX is not run by default. |
| 16 | |
| 17 | # Each component must start by invoking `msg` with a short informative message. |
| 18 | # |
| 19 | # Warning: due to the way bash detects errors, the failure of a command |
| 20 | # inside 'if' or '!' is not detected. Use the 'not' function instead of '!'. |
| 21 | # |
| 22 | # Each component is executed in a separate shell process. The component |
| 23 | # fails if any command in it returns a non-zero status. |
| 24 | # |
| 25 | # The framework in all.sh performs some cleanup tasks after each component. |
| 26 | # This means that components can assume that the working directory is in a |
| 27 | # cleaned-up state, and don't need to perform the cleanup themselves. |
| 28 | # * Run `make clean`. |
| 29 | # * Restore `include/mbedtls/mbedtls_config.h` from a backup made before running |
| 30 | # the component. |
| 31 | # * Check out `Makefile`, `library/Makefile`, `programs/Makefile`, |
| 32 | # `tests/Makefile` and `programs/fuzz/Makefile` from git. |
| 33 | # This cleans up after an in-tree use of CMake. |
| 34 | # |
| 35 | # The tests are roughly in order from fastest to slowest. This doesn't |
| 36 | # have to be exact, but in general you should add slower tests towards |
| 37 | # the end and fast checks near the beginning. |
| 38 | |
| 39 | |
| 40 | ################################################################ |
| 41 | #### Build and test many configurations and targets |
| 42 | ################################################################ |
Minos Galanakis | ada21b0 | 2024-07-26 12:34:19 +0100 | [diff] [blame] | 43 | |
Minos Galanakis | ada21b0 | 2024-07-26 12:34:19 +0100 | [diff] [blame] | 44 | component_test_no_rsa_key_pair_generation() { |
| 45 | msg "build: default config minus PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE" |
| 46 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 47 | scripts/config.py unset MBEDTLS_GENPRIME |
| 48 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE |
| 49 | make |
| 50 | |
| 51 | msg "test: default config minus PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE" |
| 52 | make test |
| 53 | } |
| 54 | |
Minos Galanakis | ada21b0 | 2024-07-26 12:34:19 +0100 | [diff] [blame] | 55 | component_test_full_no_cipher () { |
| 56 | msg "build: full no CIPHER" |
| 57 | |
| 58 | scripts/config.py full |
| 59 | scripts/config.py unset MBEDTLS_CIPHER_C |
| 60 | |
| 61 | # The built-in implementation of the following algs/key-types depends |
| 62 | # on CIPHER_C so we disable them. |
| 63 | # This does not hold for KEY_TYPE_CHACHA20 and ALG_CHACHA20_POLY1305 |
| 64 | # so we keep them enabled. |
| 65 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CCM_STAR_NO_TAG |
| 66 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CMAC |
| 67 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_NO_PADDING |
| 68 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_PKCS7 |
| 69 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CFB |
| 70 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CTR |
| 71 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_ECB_NO_PADDING |
| 72 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_OFB |
| 73 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128 |
| 74 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_STREAM_CIPHER |
| 75 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_KEY_TYPE_DES |
| 76 | |
| 77 | # The following modules directly depends on CIPHER_C |
| 78 | scripts/config.py unset MBEDTLS_CMAC_C |
| 79 | scripts/config.py unset MBEDTLS_NIST_KW_C |
| 80 | |
| 81 | make |
| 82 | |
| 83 | # Ensure that CIPHER_C was not re-enabled |
| 84 | not grep mbedtls_cipher_init ${BUILTIN_SRC_PATH}/cipher.o |
| 85 | |
| 86 | msg "test: full no CIPHER" |
| 87 | make test |
| 88 | } |