2 * Copyright (c) 2021 Graphiant, Inc.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #include <vppinfra/clib.h>
17 #include <vppinfra/format.h>
18 #include <vppinfra/error.h>
19 #include <vppinfra/random.h>
20 #include <vppinfra/time.h>
21 #include <vppinfra/interrupt.h>
27 #define debug(format, args...) \
30 fformat (stdout, format, ##args); \
34 set_and_check_bits (void *interrupts, int num_ints)
39 for (step = 1; step < num_ints; step++)
44 debug (" Step of %d\n", step);
45 for (int i = 0; i < num_ints; i += step)
47 debug (" Setting %d\n", i);
48 clib_interrupt_set (interrupts, i);
51 while ((int_num = clib_interrupt_get_next (interrupts, int_num)) != -1)
53 debug (" Got %d, expecting %d\n", int_num, expected);
54 ASSERT (int_num == expected);
56 clib_interrupt_clear (interrupts, int_num);
62 main (int argc, char *argv[])
64 clib_mem_init (0, 3ULL << 30);
68 void *interrupts = NULL;
70 for (int num_ints = 0; num_ints < MAX_INTS; num_ints++)
72 clib_interrupt_resize (&interrupts, num_ints);
73 debug ("Size now %d\n", num_ints);
75 set_and_check_bits (interrupts, num_ints);