mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-17 22:23:45 -04:00
lib/rbtree: split tests
Current tests are gathered in one big function. Split tests into its own function for better understanding and also it is a preparation for introducing new test cases. Link: https://lkml.kernel.org/r/20250310074938.26756-3-richard.weiyang@gmail.com Signed-off-by: Wei Yang <richard.weiyang@gmail.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Michel Lespinasse <michel@lespinasse.org> Cc: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
@@ -239,19 +239,14 @@ static void check_augmented(int nr_nodes)
|
||||
}
|
||||
}
|
||||
|
||||
static int __init rbtree_test_init(void)
|
||||
static int basic_check(void)
|
||||
{
|
||||
int i, j;
|
||||
cycles_t time1, time2, time;
|
||||
struct rb_node *node;
|
||||
|
||||
nodes = kmalloc_array(nnodes, sizeof(*nodes), GFP_KERNEL);
|
||||
if (!nodes)
|
||||
return -ENOMEM;
|
||||
|
||||
printk(KERN_ALERT "rbtree testing");
|
||||
|
||||
prandom_seed_state(&rnd, 3141592653589793238ULL);
|
||||
init();
|
||||
|
||||
time1 = get_cycles();
|
||||
@@ -343,6 +338,14 @@ static int __init rbtree_test_init(void)
|
||||
check(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int augmented_check(void)
|
||||
{
|
||||
int i, j;
|
||||
cycles_t time1, time2, time;
|
||||
|
||||
printk(KERN_ALERT "augmented rbtree testing");
|
||||
|
||||
init();
|
||||
@@ -390,6 +393,20 @@ static int __init rbtree_test_init(void)
|
||||
check_augmented(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __init rbtree_test_init(void)
|
||||
{
|
||||
nodes = kmalloc_array(nnodes, sizeof(*nodes), GFP_KERNEL);
|
||||
if (!nodes)
|
||||
return -ENOMEM;
|
||||
|
||||
prandom_seed_state(&rnd, 3141592653589793238ULL);
|
||||
|
||||
basic_check();
|
||||
augmented_check();
|
||||
|
||||
kfree(nodes);
|
||||
|
||||
return -EAGAIN; /* Fail will directly unload the module */
|
||||
|
||||
Reference in New Issue
Block a user