summaryrefslogtreecommitdiff
path: root/tools/testing/radix-tree/maple.c
blob: 35082671928ad5305efd743d5955f4556f3bba45 (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
59
// SPDX-License-Identifier: GPL-2.0+
/*
 * maple_tree.c: Userspace shim for maple tree test-suite
 * Copyright (c) 2018 Liam R. Howlett <Liam.Howlett@Oracle.com>
 */

#define CONFIG_DEBUG_MAPLE_TREE
#define CONFIG_MAPLE_SEARCH
#include "test.h"

#define module_init(x)
#define module_exit(x)
#define MODULE_AUTHOR(x)
#define MODULE_LICENSE(x)
#define dump_stack()	assert(0)

#include "../../../lib/maple_tree.c"
#undef CONFIG_DEBUG_MAPLE_TREE
#include "../../../lib/test_maple_tree.c"

void farmer_tests(void)
{
	struct maple_node *node;
	DEFINE_MTREE(tree);

	mt_dump(&tree);

	tree.ma_root = xa_mk_value(0);
	mt_dump(&tree);

	node = mt_alloc_one(GFP_KERNEL);
	node->parent = (void *)((unsigned long)(&tree) | 1);
	node->slot[0] = xa_mk_value(0);
	node->slot[1] = xa_mk_value(1);
	node->mr64.pivot[0] = 0;
	node->mr64.pivot[1] = 1;
	node->mr64.pivot[2] = 0;
	tree.ma_root = mt_mk_node(node, maple_leaf_64);
	mt_dump(&tree);

	ma_free_rcu(node);
}

void maple_tree_tests(void)
{
	farmer_tests();
	maple_tree_seed();
	maple_tree_harvest();
}

int __weak main(void)
{
	maple_tree_init();
	maple_tree_tests();
	rcu_barrier();
	if (nr_allocated)
		printf("nr_allocated = %d\n", nr_allocated);
	return 0;
}