mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Current test use pseudo rand function with fixed seed, which means the test data is the same pattern each time. Add random seed parameter to randomize the test. Link: https://lkml.kernel.org/r/20250310074938.26756-4-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>
48 lines
1.1 KiB
C
48 lines
1.1 KiB
C
// 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;
|
|
}
|