builtin-test.c (14e77332e74603efab8347c89d3cda447c3b97c9) builtin-test.c (f215054d749b17c56e014fdca2fcc592dac4529c)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * builtin-test.c
4 *
5 * Builtin regression testing command: ever growing number of sanity tests
6 */
7#include <fcntl.h>
8#include <errno.h>

--- 104 unchanged lines hidden (view full) ---

113 NULL,
114};
115
116static struct test_suite **tests[] = {
117 generic_tests,
118 arch_tests,
119};
120
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * builtin-test.c
4 *
5 * Builtin regression testing command: ever growing number of sanity tests
6 */
7#include <fcntl.h>
8#include <errno.h>

--- 104 unchanged lines hidden (view full) ---

113 NULL,
114};
115
116static struct test_suite **tests[] = {
117 generic_tests,
118 arch_tests,
119};
120
121static struct test_workload *workloads[] = {
122 &workload__noploop,
123};
124
121static int num_subtests(const struct test_suite *t)
122{
123 int num;
124
125 if (!t->test_cases)
126 return 0;
127
128 num = 0;

--- 341 unchanged lines hidden (view full) ---

470 }
471 }
472
473 perf_test__list_shell(argc, argv, i);
474
475 return 0;
476}
477
125static int num_subtests(const struct test_suite *t)
126{
127 int num;
128
129 if (!t->test_cases)
130 return 0;
131
132 num = 0;

--- 341 unchanged lines hidden (view full) ---

474 }
475 }
476
477 perf_test__list_shell(argc, argv, i);
478
479 return 0;
480}
481
482static int run_workload(const char *work, int argc, const char **argv)
483{
484 unsigned int i = 0;
485 struct test_workload *twl;
486
487 for (i = 0; i < ARRAY_SIZE(workloads); i++) {
488 twl = workloads[i];
489 if (!strcmp(twl->name, work))
490 return twl->func(argc, argv);
491 }
492
493 pr_info("No workload found: %s\n", work);
494 return -1;
495}
496
478int cmd_test(int argc, const char **argv)
479{
480 const char *test_usage[] = {
481 "perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]",
482 NULL,
483 };
484 const char *skip = NULL;
497int cmd_test(int argc, const char **argv)
498{
499 const char *test_usage[] = {
500 "perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]",
501 NULL,
502 };
503 const char *skip = NULL;
504 const char *workload = NULL;
485 const struct option test_options[] = {
486 OPT_STRING('s', "skip", &skip, "tests", "tests to skip"),
487 OPT_INCR('v', "verbose", &verbose,
488 "be more verbose (show symbol address, etc)"),
489 OPT_BOOLEAN('F', "dont-fork", &dont_fork,
490 "Do not fork for testcase"),
505 const struct option test_options[] = {
506 OPT_STRING('s', "skip", &skip, "tests", "tests to skip"),
507 OPT_INCR('v', "verbose", &verbose,
508 "be more verbose (show symbol address, etc)"),
509 OPT_BOOLEAN('F', "dont-fork", &dont_fork,
510 "Do not fork for testcase"),
511 OPT_STRING('w', "workload", &workload, "work", "workload to run for testing"),
491 OPT_END()
492 };
493 const char * const test_subcommands[] = { "list", NULL };
494 struct intlist *skiplist = NULL;
495 int ret = hists__init();
496
497 if (ret < 0)
498 return ret;
499
500 /* Unbuffered output */
501 setvbuf(stdout, NULL, _IONBF, 0);
502
503 argc = parse_options_subcommand(argc, argv, test_options, test_subcommands, test_usage, 0);
504 if (argc >= 1 && !strcmp(argv[0], "list"))
505 return perf_test__list(argc - 1, argv + 1);
506
512 OPT_END()
513 };
514 const char * const test_subcommands[] = { "list", NULL };
515 struct intlist *skiplist = NULL;
516 int ret = hists__init();
517
518 if (ret < 0)
519 return ret;
520
521 /* Unbuffered output */
522 setvbuf(stdout, NULL, _IONBF, 0);
523
524 argc = parse_options_subcommand(argc, argv, test_options, test_subcommands, test_usage, 0);
525 if (argc >= 1 && !strcmp(argv[0], "list"))
526 return perf_test__list(argc - 1, argv + 1);
527
528 if (workload)
529 return run_workload(workload, argc, argv);
530
507 symbol_conf.priv_size = sizeof(int);
508 symbol_conf.sort_by_name = true;
509 symbol_conf.try_vmlinux_path = true;
510
511 if (symbol__init(NULL) < 0)
512 return -1;
513
514 if (skip != NULL)
515 skiplist = intlist__new(skip);
516 /*
517 * Tests that create BPF maps, for instance, need more than the 64K
518 * default:
519 */
520 rlimit__bump_memlock();
521
522 return __cmd_test(argc, argv, skiplist);
523}
531 symbol_conf.priv_size = sizeof(int);
532 symbol_conf.sort_by_name = true;
533 symbol_conf.try_vmlinux_path = true;
534
535 if (symbol__init(NULL) < 0)
536 return -1;
537
538 if (skip != NULL)
539 skiplist = intlist__new(skip);
540 /*
541 * Tests that create BPF maps, for instance, need more than the 64K
542 * default:
543 */
544 rlimit__bump_memlock();
545
546 return __cmd_test(argc, argv, skiplist);
547}