Skip to content

Commit 30d9a62

Browse files
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>
1 parent 9b92164 commit 30d9a62

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

tests/include/test/build_info.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* \file test/build_info.h
3+
*
4+
* \brief Common things for all Mbed TLS and TF-PSA-Crypto test headers.
5+
*
6+
* Include this header first in all headers in `include/test/`.
7+
*/
8+
9+
/*
10+
* Copyright The Mbed TLS Contributors
11+
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
12+
*/
13+
14+
#ifndef TEST_BUILD_INFO_H
15+
#define TEST_BUILD_INFO_H
16+
17+
#include <mbedtls/build_info.h>
18+
19+
/* Most fields of publicly available structs are private and are wrapped with
20+
* MBEDTLS_PRIVATE macro. This define allows tests to access the private fields
21+
* directly (without using the MBEDTLS_PRIVATE wrapper). */
22+
#define MBEDTLS_ALLOW_PRIVATE_ACCESS
23+
24+
#endif /* TEST_BUILD_INFO_H */

tests/include/test/test_common.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
*
44
* \brief Common things for all Mbed TLS and TF-PSA-Crypto test code.
55
*
6-
* Include this header first in all headers in `include/test/`.
7-
* Include this or another header from `include/test/` in all test C files.
6+
* Include this header first in all test C files.
87
*/
98

109
/*
@@ -24,11 +23,8 @@
2423
#define __USE_MINGW_ANSI_STDIO 1
2524
#endif
2625

27-
#include <mbedtls/build_info.h>
28-
29-
/* Most fields of publicly available structs are private and are wrapped with
30-
* MBEDTLS_PRIVATE macro. This define allows tests to access the private fields
31-
* directly (without using the MBEDTLS_PRIVATE wrapper). */
32-
#define MBEDTLS_ALLOW_PRIVATE_ACCESS
26+
/* Make sure we have the library configuration, and anything else that
27+
* is deemed necessary in test headers. */
28+
#include <test/build_info.h>
3329

3430
#endif /* TEST_TEST_COMMON_H */

0 commit comments

Comments
 (0)