vppinfra: add array mask func
[vpp.git] / src / vppinfra / vector / test / test.c
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright(c) 2021 Cisco Systems, Inc.
3  */
4
5 #include <vppinfra/format.h>
6 #include <vppinfra/vector/test/test.h>
7
8 test_registration_t *test_registrations[CLIB_MARCH_TYPE_N_VARIANTS] = {};
9
10 int
11 test_march_supported (clib_march_variant_type_t type)
12 {
13 #define _(s, n)                                                               \
14   if (CLIB_MARCH_VARIANT_TYPE_##s == type)                                    \
15     return clib_cpu_march_priority_##s ();
16   foreach_march_variant
17 #undef _
18     return 0;
19 }
20
21 int
22 main (int argc, char *argv[])
23 {
24   clib_mem_init (0, 64ULL << 20);
25
26   for (int i = 0; i < CLIB_MARCH_TYPE_N_VARIANTS; i++)
27     {
28       test_registration_t *r = test_registrations[i];
29
30       if (r == 0 || test_march_supported (i) < 0)
31         continue;
32
33       fformat (stdout, "\nMultiarch Variant: %U\n", format_march_variant, i);
34       fformat (stdout,
35                "-------------------------------------------------------\n");
36       while (r)
37         {
38           clib_error_t *err;
39           err = (r->fn) (0);
40           fformat (stdout, "%-50s %s\n", r->name, err ? "FAIL" : "PASS");
41           if (err)
42             {
43               clib_error_report (err);
44               fformat (stdout, "\n");
45             }
46
47           r = r->next;
48         }
49     }
50
51   fformat (stdout, "\n");
52   return 0;
53 }