File: rbtree_test.c

package info (click to toggle)
linux 6.18.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,742,096 kB
  • sloc: ansic: 26,781,576; asm: 272,087; sh: 148,750; python: 79,244; makefile: 57,741; perl: 36,527; xml: 19,542; cpp: 5,911; yacc: 4,939; lex: 2,950; awk: 1,607; sed: 30; ruby: 25
file content (48 lines) | stat: -rw-r--r-- 1,109 bytes parent folder | download | duplicates (9)
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
// SPDX-License-Identifier: GPL-2.0
/*
 * rbtree_test.c: Userspace Red Black Tree test-suite
 * Copyright (c) 2025 Wei Yang <richard.weiyang@gmail.com>
 */
#include <linux/init.h>
#include <linux/math64.h>
#include <linux/kern_levels.h>
#include "shared.h"

#include "../../../lib/rbtree_test.c"

int usage(void)
{
	fprintf(stderr, "Userland rbtree test cases\n");
	fprintf(stderr, "  -n: Number of nodes in the rb-tree\n");
	fprintf(stderr, "  -p: Number of iterations modifying the rb-tree\n");
	fprintf(stderr, "  -c: Number of iterations modifying and verifying the rb-tree\n");
	fprintf(stderr, "  -r: Random seed\n");
	exit(-1);
}

void rbtree_tests(void)
{
	rbtree_test_init();
	rbtree_test_exit();
}

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

	while ((opt = getopt(argc, argv, "n:p:c:r:")) != -1) {
		if (opt == 'n')
			nnodes = strtoul(optarg, NULL, 0);
		else if (opt == 'p')
			perf_loops = strtoul(optarg, NULL, 0);
		else if (opt == 'c')
			check_loops = strtoul(optarg, NULL, 0);
		else if (opt == 'r')
			seed = strtoul(optarg, NULL, 0);
		else
			usage();
	}

	rbtree_tests();
	return 0;
}