Damjan Marion | e3e3555 | 2021-05-06 17:34:49 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright(c) 2021 Cisco Systems, Inc. |
| 3 | */ |
| 4 | |
| 5 | #ifndef included_test_test_h |
| 6 | #define included_test_test_h |
| 7 | |
| 8 | #include <vppinfra/cpu.h> |
| 9 | |
| 10 | typedef clib_error_t *(test_fn_t) (clib_error_t *); |
| 11 | |
| 12 | typedef struct test_registration_ |
| 13 | { |
| 14 | char *name; |
| 15 | u8 multiarch : 1; |
| 16 | test_fn_t *fn; |
| 17 | struct test_registration_ *next; |
| 18 | } test_registration_t; |
| 19 | |
| 20 | extern test_registration_t *test_registrations[CLIB_MARCH_TYPE_N_VARIANTS]; |
| 21 | |
| 22 | #define __clib_test_fn static __clib_noinline __clib_section (".test_wrapper") |
| 23 | |
| 24 | #define REGISTER_TEST(x) \ |
| 25 | test_registration_t CLIB_MARCH_SFX (__test_##x); \ |
| 26 | static void __clib_constructor CLIB_MARCH_SFX (__test_registration_##x) ( \ |
| 27 | void) \ |
| 28 | { \ |
| 29 | test_registration_t *r = &CLIB_MARCH_SFX (__test_##x); \ |
| 30 | r->next = test_registrations[CLIB_MARCH_SFX (CLIB_MARCH_VARIANT_TYPE)]; \ |
| 31 | test_registrations[CLIB_MARCH_SFX (CLIB_MARCH_VARIANT_TYPE)] = r; \ |
| 32 | } \ |
| 33 | test_registration_t CLIB_MARCH_SFX (__test_##x) |
| 34 | |
| 35 | #endif |