1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * interval_tree.c: Userspace Interval Tree test-suite
4 * Copyright (c) 2025 Wei Yang <richard.weiyang@gmail.com>
5 */
6 #include <linux/math64.h>
7 #include <linux/kern_levels.h>
8 #include "shared.h"
9 #include "maple-shared.h"
10
11 #include "../../../lib/interval_tree_test.c"
12
usage(void)13 int usage(void)
14 {
15 fprintf(stderr, "Userland interval tree test cases\n");
16 fprintf(stderr, " -n: Number of nodes in the interval tree\n");
17 fprintf(stderr, " -p: Number of iterations modifying the tree\n");
18 fprintf(stderr, " -q: Number of searches to the interval tree\n");
19 fprintf(stderr, " -s: Number of iterations searching the tree\n");
20 fprintf(stderr, " -a: Searches will iterate all nodes in the tree\n");
21 fprintf(stderr, " -m: Largest value for the interval's endpoint\n");
22 fprintf(stderr, " -r: Random seed\n");
23 exit(-1);
24 }
25
interval_tree_tests(void)26 void interval_tree_tests(void)
27 {
28 interval_tree_test_init();
29 interval_tree_test_exit();
30 }
31
main(int argc,char ** argv)32 int main(int argc, char **argv)
33 {
34 int opt;
35
36 while ((opt = getopt(argc, argv, "n:p:q:s:am:r:")) != -1) {
37 if (opt == 'n')
38 nnodes = strtoul(optarg, NULL, 0);
39 else if (opt == 'p')
40 perf_loops = strtoul(optarg, NULL, 0);
41 else if (opt == 'q')
42 nsearches = strtoul(optarg, NULL, 0);
43 else if (opt == 's')
44 search_loops = strtoul(optarg, NULL, 0);
45 else if (opt == 'a')
46 search_all = true;
47 else if (opt == 'm')
48 max_endpoint = strtoul(optarg, NULL, 0);
49 else if (opt == 'r')
50 seed = strtoul(optarg, NULL, 0);
51 else
52 usage();
53 }
54
55 maple_tree_init();
56 interval_tree_tests();
57 return 0;
58 }
59