Split <test/build_info.h> 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 <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2026-03-11 19:45:29 +01:00
parent 9b92164c47
commit 30d9a6210b
2 changed files with 28 additions and 8 deletions
+24
View File
@@ -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 <mbedtls/build_info.h>
/* 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 */
+4 -8
View File
@@ -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 <mbedtls/build_info.h>
/* 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 <test/build_info.h>
#endif /* TEST_TEST_COMMON_H */