builtin-test.c (406254918b232db198ed60f5bf1f8b84d96bca00) builtin-test.c (eb7261f14e1a86f0fd299a2ec408990d349ce3d1)
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>

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

21#include "color.h"
22#include <subcmd/parse-options.h>
23#include "string2.h"
24#include "symbol.h"
25#include "util/rlimit.h"
26#include <linux/kernel.h>
27#include <linux/string.h>
28#include <subcmd/exec-cmd.h>
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>

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

21#include "color.h"
22#include <subcmd/parse-options.h>
23#include "string2.h"
24#include "symbol.h"
25#include "util/rlimit.h"
26#include <linux/kernel.h>
27#include <linux/string.h>
28#include <subcmd/exec-cmd.h>
29#include <linux/zalloc.h>
29
30static bool dont_fork;
31
32struct test __weak arch_tests[] = {
33 {
34 .func = NULL,
35 },
36};

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

535 free(exec_path);
536 return path;
537}
538
539static int shell_tests__max_desc_width(void)
540{
541 struct dirent **entlist;
542 struct dirent *ent;
30
31static bool dont_fork;
32
33struct test __weak arch_tests[] = {
34 {
35 .func = NULL,
36 },
37};

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

536 free(exec_path);
537 return path;
538}
539
540static int shell_tests__max_desc_width(void)
541{
542 struct dirent **entlist;
543 struct dirent *ent;
543 int n_dirs;
544 int n_dirs, e;
544 char path_dir[PATH_MAX];
545 const char *path = shell_tests__dir(path_dir, sizeof(path_dir));
546 int width = 0;
547
548 if (path == NULL)
549 return -1;
550
551 n_dirs = scandir(path, &entlist, NULL, alphasort);

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

559 if (desc) {
560 int len = strlen(desc);
561
562 if (width < len)
563 width = len;
564 }
565 }
566
545 char path_dir[PATH_MAX];
546 const char *path = shell_tests__dir(path_dir, sizeof(path_dir));
547 int width = 0;
548
549 if (path == NULL)
550 return -1;
551
552 n_dirs = scandir(path, &entlist, NULL, alphasort);

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

560 if (desc) {
561 int len = strlen(desc);
562
563 if (width < len)
564 width = len;
565 }
566 }
567
568 for (e = 0; e < n_dirs; e++)
569 zfree(&entlist[e]);
567 free(entlist);
570 free(entlist);
568
569 return width;
570}
571
572struct shell_test {
573 const char *dir;
574 const char *file;
575};
576

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

591
592 return WEXITSTATUS(err) == 2 ? TEST_SKIP : TEST_FAIL;
593}
594
595static int run_shell_tests(int argc, const char *argv[], int i, int width)
596{
597 struct dirent **entlist;
598 struct dirent *ent;
571 return width;
572}
573
574struct shell_test {
575 const char *dir;
576 const char *file;
577};
578

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

593
594 return WEXITSTATUS(err) == 2 ? TEST_SKIP : TEST_FAIL;
595}
596
597static int run_shell_tests(int argc, const char *argv[], int i, int width)
598{
599 struct dirent **entlist;
600 struct dirent *ent;
599 int n_dirs;
601 int n_dirs, e;
600 char path_dir[PATH_MAX];
601 struct shell_test st = {
602 .dir = shell_tests__dir(path_dir, sizeof(path_dir)),
603 };
604
605 if (st.dir == NULL)
606 return -1;
607

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

624 if (!perf_test__matches(test.desc, curr, argc, argv))
625 continue;
626
627 st.file = ent->d_name;
628 pr_info("%2d: %-*s:", i, width, test.desc);
629 test_and_print(&test, false, -1);
630 }
631
602 char path_dir[PATH_MAX];
603 struct shell_test st = {
604 .dir = shell_tests__dir(path_dir, sizeof(path_dir)),
605 };
606
607 if (st.dir == NULL)
608 return -1;
609

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

626 if (!perf_test__matches(test.desc, curr, argc, argv))
627 continue;
628
629 st.file = ent->d_name;
630 pr_info("%2d: %-*s:", i, width, test.desc);
631 test_and_print(&test, false, -1);
632 }
633
634 for (e = 0; e < n_dirs; e++)
635 zfree(&entlist[e]);
632 free(entlist);
633 return 0;
634}
635
636static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
637{
638 struct test *t;
639 unsigned int j;

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

725
726 return run_shell_tests(argc, argv, i, width);
727}
728
729static int perf_test__list_shell(int argc, const char **argv, int i)
730{
731 struct dirent **entlist;
732 struct dirent *ent;
636 free(entlist);
637 return 0;
638}
639
640static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
641{
642 struct test *t;
643 unsigned int j;

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

729
730 return run_shell_tests(argc, argv, i, width);
731}
732
733static int perf_test__list_shell(int argc, const char **argv, int i)
734{
735 struct dirent **entlist;
736 struct dirent *ent;
733 int n_dirs;
737 int n_dirs, e;
734 char path_dir[PATH_MAX];
735 const char *path = shell_tests__dir(path_dir, sizeof(path_dir));
736
737 if (path == NULL)
738 return -1;
739
740 n_dirs = scandir(path, &entlist, NULL, alphasort);
741 if (n_dirs == -1)

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

747 struct test t = {
748 .desc = shell_test__description(bf, sizeof(bf), path, ent->d_name),
749 };
750
751 if (!perf_test__matches(t.desc, curr, argc, argv))
752 continue;
753
754 pr_info("%2d: %s\n", i, t.desc);
738 char path_dir[PATH_MAX];
739 const char *path = shell_tests__dir(path_dir, sizeof(path_dir));
740
741 if (path == NULL)
742 return -1;
743
744 n_dirs = scandir(path, &entlist, NULL, alphasort);
745 if (n_dirs == -1)

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

751 struct test t = {
752 .desc = shell_test__description(bf, sizeof(bf), path, ent->d_name),
753 };
754
755 if (!perf_test__matches(t.desc, curr, argc, argv))
756 continue;
757
758 pr_info("%2d: %s\n", i, t.desc);
759
755 }
756
760 }
761
762 for (e = 0; e < n_dirs; e++)
763 zfree(&entlist[e]);
757 free(entlist);
758 return 0;
759}
760
761static int perf_test__list(int argc, const char **argv)
762{
763 unsigned int j;
764 struct test *t;

--- 69 unchanged lines hidden ---
764 free(entlist);
765 return 0;
766}
767
768static int perf_test__list(int argc, const char **argv)
769{
770 unsigned int j;
771 struct test *t;

--- 69 unchanged lines hidden ---