interval_tree_test.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * interval_tree.c: Userspace Interval Tree test-suite
  4. * Copyright (c) 2025 Wei Yang <richard.weiyang@gmail.com>
  5. */
  6. #include <linux/math64.h>
  7. #include <linux/kern_levels.h>
  8. #include "shared.h"
  9. #include "maple-shared.h"
  10. #include "../../../lib/interval_tree_test.c"
  11. int usage(void)
  12. {
  13. fprintf(stderr, "Userland interval tree test cases\n");
  14. fprintf(stderr, " -n: Number of nodes in the interval tree\n");
  15. fprintf(stderr, " -p: Number of iterations modifying the tree\n");
  16. fprintf(stderr, " -q: Number of searches to the interval tree\n");
  17. fprintf(stderr, " -s: Number of iterations searching the tree\n");
  18. fprintf(stderr, " -a: Searches will iterate all nodes in the tree\n");
  19. fprintf(stderr, " -m: Largest value for the interval's endpoint\n");
  20. fprintf(stderr, " -r: Random seed\n");
  21. exit(-1);
  22. }
  23. void interval_tree_tests(void)
  24. {
  25. interval_tree_test_init();
  26. interval_tree_test_exit();
  27. }
  28. int main(int argc, char **argv)
  29. {
  30. int opt;
  31. while ((opt = getopt(argc, argv, "n:p:q:s:am:r:")) != -1) {
  32. if (opt == 'n')
  33. nnodes = strtoul(optarg, NULL, 0);
  34. else if (opt == 'p')
  35. perf_loops = strtoul(optarg, NULL, 0);
  36. else if (opt == 'q')
  37. nsearches = strtoul(optarg, NULL, 0);
  38. else if (opt == 's')
  39. search_loops = strtoul(optarg, NULL, 0);
  40. else if (opt == 'a')
  41. search_all = true;
  42. else if (opt == 'm')
  43. max_endpoint = strtoul(optarg, NULL, 0);
  44. else if (opt == 'r')
  45. seed = strtoul(optarg, NULL, 0);
  46. else
  47. usage();
  48. }
  49. maple_tree_init();
  50. interval_tree_tests();
  51. return 0;
  52. }