aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/test_vector_funcs.h
blob: bc499fb24e8a10764a54ed4412cee72cd143d27c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* SPDX-License-Identifier: Apache-2.0
 * Copyright(c) 2021 Cisco Systems, Inc.
 */

#ifndef included_test_test_h
#define included_test_test_h

#include <vppinfra/cpu.h>

typedef clib_error_t *(test_fn_t) (clib_error_t *);

typedef struct test_registration_
{
  char *name;
  u8 multiarch : 1;
  test_fn_t *fn;
  struct test_registration_ *next;
} test_registration_t;

extern test_registration_t *test_registrations[CLIB_MARCH_TYPE_N_VARIANTS];

#define __clib_test_fn static __clib_noinline __clib_section (".test_wrapper")

#define REGISTER_TEST(x)                                                      \
  test_registration_t CLIB_MARCH_SFX (__test_##x);                            \
  static void __clib_constructor CLIB_MARCH_SFX (__test_registration_##x) (   \
    void)                                                                     \
  {                                                                           \
    test_registration_t *r = &CLIB_MARCH_SFX (__test_##x);                    \
    r->next = test_registrations[CLIB_MARCH_SFX (CLIB_MARCH_VARIANT_TYPE)];   \
    test_registrations[CLIB_MARCH_SFX (CLIB_MARCH_VARIANT_TYPE)] = r;         \
  }                                                                           \
  test_registration_t CLIB_MARCH_SFX (__test_##x)

#endif