rbtree_test.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * rbtree_test.c: Userspace Red Black Tree test-suite
  4. * Copyright (c) 2025 Wei Yang <richard.weiyang@gmail.com>
  5. */
  6. #include <linux/init.h>
  7. #include <linux/math64.h>
  8. #include <linux/kern_levels.h>
  9. #include "shared.h"
  10. #include "../../../lib/rbtree_test.c"
  11. int usage(void)
  12. {
  13. fprintf(stderr, "Userland rbtree test cases\n");
  14. fprintf(stderr, " -n: Number of nodes in the rb-tree\n");
  15. fprintf(stderr, " -p: Number of iterations modifying the rb-tree\n");
  16. fprintf(stderr, " -c: Number of iterations modifying and verifying the rb-tree\n");
  17. fprintf(stderr, " -r: Random seed\n");
  18. exit(-1);
  19. }
  20. void rbtree_tests(void)
  21. {
  22. rbtree_test_init();
  23. rbtree_test_exit();
  24. }
  25. int main(int argc, char **argv)
  26. {
  27. int opt;
  28. while ((opt = getopt(argc, argv, "n:p:c:r:")) != -1) {
  29. if (opt == 'n')
  30. nnodes = strtoul(optarg, NULL, 0);
  31. else if (opt == 'p')
  32. perf_loops = strtoul(optarg, NULL, 0);
  33. else if (opt == 'c')
  34. check_loops = strtoul(optarg, NULL, 0);
  35. else if (opt == 'r')
  36. seed = strtoul(optarg, NULL, 0);
  37. else
  38. usage();
  39. }
  40. rbtree_tests();
  41. return 0;
  42. }