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)
36 for (int step = 1; step < num_ints; step++)
41 debug (" Step of %d\n", step);
42 for (int i = 0; i < num_ints; i += step)
44 debug (" Setting %d\n", i);
45 clib_interrupt_set (interrupts, i);
49 clib_interrupt_get_next_and_clear (interrupts, int_num)) != -1)
51 debug (" Got %d, expecting %d\n", int_num, expected);
52 ASSERT (int_num == expected);
55 int_num = clib_interrupt_get_next_and_clear (interrupts, -1);
56 ASSERT (int_num == -1);
61 main (int argc, char *argv[])
63 clib_mem_init (0, 3ULL << 30);
67 void *interrupts = NULL;
69 for (int num_ints = 0; num_ints < MAX_INTS; num_ints++)
71 clib_interrupt_resize (&interrupts, num_ints);
72 debug ("Size now %d\n", num_ints);
74 set_and_check_bits (interrupts, num_ints);