summaryrefslogtreecommitdiffstats
path: root/tools/testing/rbtree/interval_tree_test.c
blob: 49bc5b534330903bbbcb1735bb86e25350510add (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: GPL-2.0
/*
 * interval_tree.c: Userspace Interval Tree test-suite
 * Copyright (c) 2025 Wei Yang <richard.weiyang@gmail.com>
 */
#include <linux/math64.h>
#include <linux/kern_levels.h>
#include "shared.h"
#include "maple-shared.h"

#include "../../../lib/interval_tree_test.c"

int usage(void)
{
	fprintf(stderr, "Userland interval tree test cases\n");
	fprintf(stderr, "  -n: Number of nodes in the interval tree\n");
	fprintf(stderr, "  -p: Number of iterations modifying the tree\n");
	fprintf(stderr, "  -q: Number of searches to the interval tree\n");
	fprintf(stderr, "  -s: Number of iterations searching the tree\n");
	fprintf(stderr, "  -a: Searches will iterate all nodes in the tree\n");
	fprintf(stderr, "  -m: Largest value for the interval's endpoint\n");
	fprintf(stderr, "  -r: Random seed\n");
	exit(-1);
}

void interval_tree_tests(void)
{
	interval_tree_test_init();
	interval_tree_test_exit();
}

int main(int argc, char **argv)
{
	int opt;

	while ((opt = getopt(argc, argv, "n:p:q:s:am:r:")) != -1) {
		if (opt == 'n')
			nnodes = strtoul(optarg, NULL, 0);
		else if (opt == 'p')
			perf_loops = strtoul(optarg, NULL, 0);
		else if (opt == 'q')
			nsearches = strtoul(optarg, NULL, 0);
		else if (opt == 's')
			search_loops = strtoul(optarg, NULL, 0);
		else if (opt == 'a')
			search_all = true;
		else if (opt == 'm')
			max_endpoint = strtoul(optarg, NULL, 0);
		else if (opt == 'r')
			seed = strtoul(optarg, NULL, 0);
		else
			usage();
	}

	maple_tree_init();
	interval_tree_tests();
	return 0;
}