From 30d9a6210be01c66dcb374ad31e240e5425420e8 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 11 Mar 2026 19:45:29 +0100 Subject: [PATCH] Split out of test_common.h The header `test_common.h` contains two kinds of things: * Things to do at the beginning of individual C files. Specifically, defining macros that notify system headers about what we want from them. Keep those in `test_common.h`, which will subsequently be moved out of the include directory. * Things to do at the beginning of every header. In particular, read the library configuration. Move them to a new header `build_info.h`, which is the only one intended to be included from headers. Signed-off-by: Gilles Peskine --- tests/include/test/build_info.h | 24 ++++++++++++++++++++++++ tests/include/test/test_common.h | 12 ++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 tests/include/test/build_info.h diff --git a/tests/include/test/build_info.h b/tests/include/test/build_info.h new file mode 100644 index 000000000..cb8b809b1 --- /dev/null +++ b/tests/include/test/build_info.h @@ -0,0 +1,24 @@ +/** + * \file test/build_info.h + * + * \brief Common things for all Mbed TLS and TF-PSA-Crypto test headers. + * + * Include this header first in all headers in `include/test/`. + */ + +/* + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + */ + +#ifndef TEST_BUILD_INFO_H +#define TEST_BUILD_INFO_H + +#include + +/* Most fields of publicly available structs are private and are wrapped with + * MBEDTLS_PRIVATE macro. This define allows tests to access the private fields + * directly (without using the MBEDTLS_PRIVATE wrapper). */ +#define MBEDTLS_ALLOW_PRIVATE_ACCESS + +#endif /* TEST_BUILD_INFO_H */ diff --git a/tests/include/test/test_common.h b/tests/include/test/test_common.h index baab6671c..aaeb1e7c8 100644 --- a/tests/include/test/test_common.h +++ b/tests/include/test/test_common.h @@ -3,8 +3,7 @@ * * \brief Common things for all Mbed TLS and TF-PSA-Crypto test code. * - * Include this header first in all headers in `include/test/`. - * Include this or another header from `include/test/` in all test C files. + * Include this header first in all test C files. */ /* @@ -24,11 +23,8 @@ #define __USE_MINGW_ANSI_STDIO 1 #endif -#include - -/* Most fields of publicly available structs are private and are wrapped with - * MBEDTLS_PRIVATE macro. This define allows tests to access the private fields - * directly (without using the MBEDTLS_PRIVATE wrapper). */ -#define MBEDTLS_ALLOW_PRIVATE_ACCESS +/* Make sure we have the library configuration, and anything else that + * is deemed necessary in test headers. */ +#include #endif /* TEST_TEST_COMMON_H */