summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/vector/test/test.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-07-13 21:12:41 +0200
committerFlorin Coras <florin.coras@gmail.com>2021-07-13 20:06:19 +0000
commitd154a17989b1da7abbfdb87b98b90cc5f4d3295f (patch)
tree9353de897ec10d0afd3005dd2cf26e0b7ac512ef /src/vppinfra/vector/test/test.h
parentb7e4d4487c0fa02f3869d24799c6573452276396 (diff)
vppinfra: put each vector function into own file
Type: refactor Change-Id: I2dd9a18497992ac7e2686c14f5d17eccccda0cda Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/vector/test/test.h')
-rw-r--r--src/vppinfra/vector/test/test.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/vppinfra/vector/test/test.h b/src/vppinfra/vector/test/test.h
new file mode 100644
index 00000000000..bc499fb24e8
--- /dev/null
+++ b/src/vppinfra/vector/test/test.h
@@ -0,0 +1,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