diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-29 09:52:07 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-29 11:04:35 -0500 |
commit | e60770a01bd889707faaaeb794f1e278e7160458 (patch) | |
tree | 8b8fa041131470e904326d49367100bf7420d7de /tools/perf/builtin-test.c | |
parent | 806fb63007447622dd61d9767b4403919737e120 (diff) |
perf test: Allow running just a subset of the available tests
To obtain a list of available tests:
[root@emilia linux]# perf test list
1: vmlinux symtab matches kallsyms
2: detect open syscall event
3: detect open syscall event on all cpus
4: read samples using the mmap interface
5: parse events tests
[root@emilia linux]#
To list just a subset:
[root@emilia linux]# perf test list syscall
2: detect open syscall event
3: detect open syscall event on all cpus
[root@emilia linux]#
To run a subset:
[root@emilia linux]# perf test detect
2: detect open syscall event: Ok
3: detect open syscall event on all cpus: Ok
[root@emilia linux]#
Specific tests can be chosen by number:
[root@emilia linux]# perf test 1 3 parse
1: vmlinux symtab matches kallsyms: Ok
3: detect open syscall event on all cpus: Ok
5: parse events tests: Ok
[root@emilia linux]#
Now to write more tests!
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-nqec2145qfxdgimux28aw7v8@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-test.c')
-rw-r--r-- | tools/perf/builtin-test.c | 81 |
1 files changed, 60 insertions, 21 deletions
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index 77d68bfb79da..3ab27223fc67 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c | |||
@@ -15,8 +15,6 @@ | |||
15 | #include "util/thread_map.h" | 15 | #include "util/thread_map.h" |
16 | #include "../../include/linux/hw_breakpoint.h" | 16 | #include "../../include/linux/hw_breakpoint.h" |
17 | 17 | ||
18 | static long page_size; | ||
19 | |||
20 | static int vmlinux_matches_kallsyms_filter(struct map *map __used, struct symbol *sym) | 18 | static int vmlinux_matches_kallsyms_filter(struct map *map __used, struct symbol *sym) |
21 | { | 19 | { |
22 | bool *visited = symbol__priv(sym); | 20 | bool *visited = symbol__priv(sym); |
@@ -32,6 +30,7 @@ static int test__vmlinux_matches_kallsyms(void) | |||
32 | struct map *kallsyms_map, *vmlinux_map; | 30 | struct map *kallsyms_map, *vmlinux_map; |
33 | struct machine kallsyms, vmlinux; | 31 | struct machine kallsyms, vmlinux; |
34 | enum map_type type = MAP__FUNCTION; | 32 | enum map_type type = MAP__FUNCTION; |
33 | long page_size = sysconf(_SC_PAGE_SIZE); | ||
35 | struct ref_reloc_sym ref_reloc_sym = { .name = "_stext", }; | 34 | struct ref_reloc_sym ref_reloc_sym = { .name = "_stext", }; |
36 | 35 | ||
37 | /* | 36 | /* |
@@ -871,41 +870,81 @@ static struct test { | |||
871 | }, | 870 | }, |
872 | }; | 871 | }; |
873 | 872 | ||
874 | static int __cmd_test(void) | 873 | static bool perf_test__matches(int curr, int argc, const char *argv[]) |
875 | { | 874 | { |
876 | int i = 0; | 875 | int i; |
876 | |||
877 | if (argc == 0) | ||
878 | return true; | ||
879 | |||
880 | for (i = 0; i < argc; ++i) { | ||
881 | char *end; | ||
882 | long nr = strtoul(argv[i], &end, 10); | ||
883 | |||
884 | if (*end == '\0') { | ||
885 | if (nr == curr + 1) | ||
886 | return true; | ||
887 | continue; | ||
888 | } | ||
877 | 889 | ||
878 | page_size = sysconf(_SC_PAGE_SIZE); | 890 | if (strstr(tests[curr].desc, argv[i])) |
891 | return true; | ||
892 | } | ||
893 | |||
894 | return false; | ||
895 | } | ||
896 | |||
897 | static int __cmd_test(int argc, const char *argv[]) | ||
898 | { | ||
899 | int i = 0; | ||
879 | 900 | ||
880 | while (tests[i].func) { | 901 | while (tests[i].func) { |
881 | int err; | 902 | int curr = i++, err; |
882 | pr_info("%2d: %s:", i + 1, tests[i].desc); | 903 | |
904 | if (!perf_test__matches(curr, argc, argv)) | ||
905 | continue; | ||
906 | |||
907 | pr_info("%2d: %s:", i, tests[curr].desc); | ||
883 | pr_debug("\n--- start ---\n"); | 908 | pr_debug("\n--- start ---\n"); |
884 | err = tests[i].func(); | 909 | err = tests[curr].func(); |
885 | pr_debug("---- end ----\n%s:", tests[i].desc); | 910 | pr_debug("---- end ----\n%s:", tests[curr].desc); |
886 | pr_info(" %s\n", err ? "FAILED!\n" : "Ok"); | 911 | pr_info(" %s\n", err ? "FAILED!\n" : "Ok"); |
887 | ++i; | ||
888 | } | 912 | } |
889 | 913 | ||
890 | return 0; | 914 | return 0; |
891 | } | 915 | } |
892 | 916 | ||
893 | static const char * const test_usage[] = { | 917 | static int perf_test__list(int argc, const char **argv) |
894 | "perf test [<options>]", | 918 | { |
895 | NULL, | 919 | int i = 0; |
896 | }; | 920 | |
921 | while (tests[i].func) { | ||
922 | int curr = i++; | ||
923 | |||
924 | if (argc > 1 && !strstr(tests[curr].desc, argv[1])) | ||
925 | continue; | ||
926 | |||
927 | pr_info("%2d: %s\n", i, tests[curr].desc); | ||
928 | } | ||
929 | |||
930 | return 0; | ||
931 | } | ||
897 | 932 | ||
898 | static const struct option test_options[] = { | 933 | int cmd_test(int argc, const char **argv, const char *prefix __used) |
934 | { | ||
935 | const char * const test_usage[] = { | ||
936 | "perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]", | ||
937 | NULL, | ||
938 | }; | ||
939 | const struct option test_options[] = { | ||
899 | OPT_INTEGER('v', "verbose", &verbose, | 940 | OPT_INTEGER('v', "verbose", &verbose, |
900 | "be more verbose (show symbol address, etc)"), | 941 | "be more verbose (show symbol address, etc)"), |
901 | OPT_END() | 942 | OPT_END() |
902 | }; | 943 | }; |
903 | 944 | ||
904 | int cmd_test(int argc, const char **argv, const char *prefix __used) | ||
905 | { | ||
906 | argc = parse_options(argc, argv, test_options, test_usage, 0); | 945 | argc = parse_options(argc, argv, test_options, test_usage, 0); |
907 | if (argc) | 946 | if (argc >= 1 && !strcmp(argv[0], "list")) |
908 | usage_with_options(test_usage, test_options); | 947 | return perf_test__list(argc, argv); |
909 | 948 | ||
910 | symbol_conf.priv_size = sizeof(int); | 949 | symbol_conf.priv_size = sizeof(int); |
911 | symbol_conf.sort_by_name = true; | 950 | symbol_conf.sort_by_name = true; |
@@ -916,5 +955,5 @@ int cmd_test(int argc, const char **argv, const char *prefix __used) | |||
916 | 955 | ||
917 | setup_pager(); | 956 | setup_pager(); |
918 | 957 | ||
919 | return __cmd_test(); | 958 | return __cmd_test(argc, argv); |
920 | } | 959 | } |