perf tests: Pass the subtest index to each test routine
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 721a1f53df6aad3ea941f5fe95519d0d8e02bd65 Gitweb: http://git.kernel.org/tip/721a1f53df6aad3ea941f5fe95519d0d8e02bd65 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Thu, 19 Nov 2015 12:01:48 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 19 Nov 2015 13:19:15 -0300
perf tests: Pass the subtest index to each test routine
Some tests have sub-tests we want to run, so allow passing this.
Wang tried to avoid having to touch all tests, but then, having the test.func in an anonymous union makes the build fail on older compilers, like the one in RHEL6, where:
test a = {
.func = foo,
};
fails.
To fix it leave the func pointer in the main structure and pass the subtest index to all tests, end result function is the same, but we have just one function pointer, not two, with and without the subtest index as an argument.
Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/arch/x86/include/arch-tests.h | 8 +-- tools/perf/arch/x86/tests/insn-x86.c | 2 +- tools/perf/arch/x86/tests/intel-cqm.c | 2 +- tools/perf/arch/x86/tests/perf-time-to-tsc.c | 2 +- tools/perf/arch/x86/tests/rdpmc.c | 2 +- tools/perf/tests/attr.c | 2 +- tools/perf/tests/bp_signal.c | 2 +- tools/perf/tests/bp_signal_overflow.c | 2 +- tools/perf/tests/bpf.c | 2 +- tools/perf/tests/builtin-test.c | 6 +-- tools/perf/tests/code-reading.c | 2 +- tools/perf/tests/dso-data.c | 6 +-- tools/perf/tests/dwarf-unwind.c | 2 +- tools/perf/tests/evsel-roundtrip-name.c | 2 +- tools/perf/tests/evsel-tp-sched.c | 2 +- tools/perf/tests/fdarray.c | 4 +- tools/perf/tests/hists_cumulate.c | 2 +- tools/perf/tests/hists_filter.c | 2 +- tools/perf/tests/hists_link.c | 2 +- tools/perf/tests/hists_output.c | 2 +- tools/perf/tests/keep-tracking.c | 2 +- tools/perf/tests/kmod-path.c | 2 +- tools/perf/tests/llvm.c | 2 +- tools/perf/tests/mmap-basic.c | 2 +- tools/perf/tests/mmap-thread-lookup.c | 2 +- tools/perf/tests/openat-syscall-all-cpus.c | 2 +- tools/perf/tests/openat-syscall-tp-fields.c | 2 +- tools/perf/tests/openat-syscall.c | 2 +- tools/perf/tests/parse-events.c | 2 +- tools/perf/tests/parse-no-sample-id-all.c | 2 +- tools/perf/tests/perf-record.c | 2 +- tools/perf/tests/pmu.c | 2 +- tools/perf/tests/python-use.c | 3 +- tools/perf/tests/sample-parsing.c | 2 +- tools/perf/tests/sw-clock.c | 2 +- tools/perf/tests/switch-tracking.c | 2 +- tools/perf/tests/task-exit.c | 2 +- tools/perf/tests/tests.h | 78 ++++++++++++++-------------- tools/perf/tests/thread-map.c | 2 +- tools/perf/tests/thread-mg-share.c | 2 +- tools/perf/tests/topology.c | 2 +- tools/perf/tests/vmlinux-kallsyms.c | 2 +- 42 files changed, 89 insertions(+), 88 deletions(-)
tools/perf/arch/x86/include/arch-tests.h +4 -4
@@ -2,10 +2,10 @@#define ARCH_TESTS_H /* Tests */ -int test__rdpmc (void ); -int test__perf_time_to_tsc (void ); -int test__insn_x86 (void ); -int test__intel_cqm_count_nmi_context (void ); +int test__rdpmc (int subtest); +int test__perf_time_to_tsc (int subtest); +int test__insn_x86 (int subtest); +int test__intel_cqm_count_nmi_context (int subtest);#ifdef HAVE_DWARF_UNWIND_SUPPORT struct thread ;
tools/perf/arch/x86/tests/insn-x86.c +1 -1
@@ -171,7 +171,7 @@ static int test_data_set(struct test_data *dat_set, int x86_64)* verbose (-v) option to see all the instructions and whether or not they * decoded successfuly. */ -int test__insn_x86 (void ) +int test__insn_x86 (int subtest__maybe_unused ) {int ret =0 ;
tools/perf/arch/x86/tests/intel-cqm.c +1 -1
@@ -33,7 +33,7 @@ static pid_t spawn(void)* the last read counter value to avoid triggering a WARN_ON_ONCE() in * smp_call_function_many() caused by sending IPIs from NMI context. */ -int test__intel_cqm_count_nmi_context (void ) +int test__intel_cqm_count_nmi_context (int subtest__maybe_unused ) {struct perf_evlist *evlist =NULL ;struct perf_evsel *evsel =NULL ;
tools/perf/arch/x86/tests/perf-time-to-tsc.c +1 -1
@@ -35,7 +35,7 @@* %0 is returned, otherwise %-1 is returned. If TSC conversion is not * supported then then the test passes but " (not supported)" is printed. */ -int test__perf_time_to_tsc (void ) +int test__perf_time_to_tsc (int subtest__maybe_unused ) {struct record_opts opts = { .mmap_pages =UINT_MAX ,
tools/perf/arch/x86/tests/rdpmc.c +1 -1
@@ -149,7 +149,7 @@ out_close:return 0 ; } -int test__rdpmc (void ) +int test__rdpmc (int subtest__maybe_unused ) {int status =0 ;int wret =0 ;
tools/perf/tests/attr.c +1 -1
@@ -153,7 +153,7 @@ static int run_dir(const char *d, const char *perf)return system (cmd); } -int test__attr (void ) +int test__attr (int subtest__maybe_unused ) {struct stat st;char path_perf[PATH_MAX ];
tools/perf/tests/bp_signal.c +1 -1
@@ -111,7 +111,7 @@ static long long bp_count(int fd)return count; } -int test__bp_signal (void ) +int test__bp_signal (int subtest__maybe_unused ) {struct sigaction sa;long long count1, count2;
tools/perf/tests/bp_signal_overflow.c +1 -1
@@ -58,7 +58,7 @@ static long long bp_count(int fd)#define EXECUTIONS 10000#define THRESHOLD 100 -int test__bp_signal_overflow (void ) +int test__bp_signal_overflow (int subtest__maybe_unused ) {struct perf_event_attr pe;struct sigaction sa;
tools/perf/tests/bpf.c +1 -1
@@ -215,7 +215,7 @@ out:return ret; } -int test__bpf (void ) +int test__bpf (int subtest__maybe_unused ) {unsigned int i;int err;
tools/perf/tests/builtin-test.c +3 -3
@@ -203,7 +203,7 @@ static bool perf_test__matches(struct test *test, int curr, int argc, const charreturn false; } -static int run_test (struct test *test) +static int run_test (struct test *test,int subtest) {int status, err =-1 , child =fork ();char sbuf[STRERR_BUFSIZE ];
@@ -216,7 +216,7 @@ static int run_test(struct test *test)if (!child) {pr_debug ("test child forked, pid %d\n" ,getpid ()); - err = test->func (); + err = test->func (subtest);exit (err); }
@@ -265,7 +265,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) }pr_debug ("\n--- start ---\n" ); - err =run_test (t); + err =run_test (t, i);pr_debug ("---- end ----\n%s:" , t->desc);switch (err) {
tools/perf/tests/code-reading.c +1 -1
@@ -601,7 +601,7 @@ out_err:return err; } -int test__code_reading (void ) +int test__code_reading (int subtest__maybe_unused ) {int ret;
tools/perf/tests/dso-data.c +3 -3
@@ -110,7 +110,7 @@ static int dso__data_fd(struct dso *dso, struct machine *machine)return fd; } -int test__dso_data (void ) +int test__dso_data (int subtest__maybe_unused ) {struct machine machine;struct dso *dso;
@@ -245,7 +245,7 @@ static int set_fd_limit(int n)return setrlimit (RLIMIT_NOFILE , &rlim); } -int test__dso_data_cache (void ) +int test__dso_data_cache (int subtest__maybe_unused ) {struct machine machine;long nr_end, nr =open_files_cnt ();
@@ -302,7 +302,7 @@ int test__dso_data_cache(void)return 0 ; } -int test__dso_data_reopen (void ) +int test__dso_data_reopen (int subtest__maybe_unused ) {struct machine machine;long nr_end, nr =open_files_cnt ();
tools/perf/tests/dwarf-unwind.c +1 -1
@@ -142,7 +142,7 @@ static int krava_1(struct thread *thread)return krava_2 (thread); } -int test__dwarf_unwind (void ) +int test__dwarf_unwind (int subtest__maybe_unused ) {struct machines machines;struct machine *machine;
tools/perf/tests/evsel-roundtrip-name.c +1 -1
@@ -95,7 +95,7 @@ out_delete_evlist:#define perf_evsel__name_array_test (names) \ __perf_evsel__name_array_test(names, ARRAY_SIZE(names)) -int test__perf_evsel__roundtrip_name_test (void ) +int test__perf_evsel__roundtrip_name_test (int subtest__maybe_unused ) {int err =0 , ret =0 ;
tools/perf/tests/evsel-tp-sched.c +1 -1
@@ -32,7 +32,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,return ret; } -int test__perf_evsel__tp_sched_test (void ) +int test__perf_evsel__tp_sched_test (int subtest__maybe_unused ) {struct perf_evsel *evsel =perf_evsel__newtp ("sched" ,"sched_switch" );int ret =0 ;
tools/perf/tests/fdarray.c +2 -2
@@ -25,7 +25,7 @@ static int fdarray__fprintf_prefix(struct fdarray *fda, const char *prefix, FILEreturn printed +fdarray__fprintf (fda, fp); } -int test__fdarray__filter (void ) +int test__fdarray__filter (int subtest__maybe_unused ) {int nr_fds, expected_fd[2 ], fd, err =TEST_FAIL ;struct fdarray *fda =fdarray__new (5 ,5 );
@@ -103,7 +103,7 @@ out:return err; } -int test__fdarray__add (void ) +int test__fdarray__add (int subtest__maybe_unused ) {int err =TEST_FAIL ;struct fdarray *fda =fdarray__new (2 ,2 );
tools/perf/tests/hists_cumulate.c +1 -1
@@ -686,7 +686,7 @@ out:return err; } -int test__hists_cumulate (void ) +int test__hists_cumulate (int subtest__maybe_unused ) {int err =TEST_FAIL ;struct machines machines;
tools/perf/tests/hists_filter.c +1 -1
@@ -104,7 +104,7 @@ out:return TEST_FAIL ; } -int test__hists_filter (void ) +int test__hists_filter (int subtest__maybe_unused ) {int err =TEST_FAIL ;struct machines machines;
tools/perf/tests/hists_link.c +1 -1
@@ -274,7 +274,7 @@ static int validate_link(struct hists *leader, struct hists *other)return __validate_link (leader,0 ) ||__validate_link (other,1 ); } -int test__hists_link (void ) +int test__hists_link (int subtest__maybe_unused ) {int err =-1 ;struct hists *hists, *first_hists;
tools/perf/tests/hists_output.c +1 -1
@@ -576,7 +576,7 @@ out:return err; } -int test__hists_output (void ) +int test__hists_output (int subtest__maybe_unused ) {int err =TEST_FAIL ;struct machines machines;
tools/perf/tests/keep-tracking.c +1 -1
@@ -49,7 +49,7 @@ static int find_comm(struct perf_evlist *evlist, const char *comm)* when an event is disabled but a dummy software event is not disabled. If the * test passes %0 is returned, otherwise %-1 is returned. */ -int test__keep_tracking (void ) +int test__keep_tracking (int subtest__maybe_unused ) {struct record_opts opts = { .mmap_pages =UINT_MAX ,
tools/perf/tests/kmod-path.c +1 -1
@@ -49,7 +49,7 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect)#define M (path, c, e) \ TEST_ASSERT_VAL("failed", !test_is_kernel_module(path, c, e)) -int test__kmod_path__parse (void ) +int test__kmod_path__parse (int subtest__maybe_unused ) {/* path alloc_name alloc_ext kmod comp name ext */ T ("/xxxx/xxxx/x-x.ko" , true , true , true, false,"[x_x]" ,NULL );
tools/perf/tests/llvm.c +1 -1
@@ -131,7 +131,7 @@ out:return ret; } -int test__llvm (void ) +int test__llvm (int subtest__maybe_unused ) {enum test_llvm__testcase i;
tools/perf/tests/mmap-basic.c +1 -1
@@ -16,7 +16,7 @@* Then it checks if the number of syscalls reported as perf events by * the kernel corresponds to the number of syscalls made. */ -int test__basic_mmap (void ) +int test__basic_mmap (int subtest__maybe_unused ) {int err =-1 ;union perf_event *event;
tools/perf/tests/mmap-thread-lookup.c +1 -1
@@ -221,7 +221,7 @@ static int mmap_events(synth_cb synth)* * by using all thread objects. */ -int test__mmap_thread_lookup (void ) +int test__mmap_thread_lookup (int subtest__maybe_unused ) {/* perf_event__synthesize_threads synthesize */ TEST_ASSERT_VAL("failed with sythesizing all",
tools/perf/tests/openat-syscall-all-cpus.c +1 -1
@@ -7,7 +7,7 @@#include "debug.h" #include "stat.h" -int test__openat_syscall_event_on_all_cpus (void ) +int test__openat_syscall_event_on_all_cpus (int subtest__maybe_unused ) {int err =-1 , fd, cpu;struct cpu_map *cpus;
tools/perf/tests/openat-syscall-tp-fields.c +1 -1
@@ -6,7 +6,7 @@#include "tests.h" #include "debug.h" -int test__syscall_openat_tp_fields (void ) +int test__syscall_openat_tp_fields (int subtest__maybe_unused ) {struct record_opts opts = { .target = {
tools/perf/tests/openat-syscall.c +1 -1
@@ -5,7 +5,7 @@#include "debug.h" #include "tests.h" -int test__openat_syscall_event (void ) +int test__openat_syscall_event (int subtest__maybe_unused ) {int err =-1 , fd;struct perf_evsel *evsel;
tools/perf/tests/parse-events.c +1 -1
@@ -1765,7 +1765,7 @@ static void debug_warn(const char *warn, va_list params)fprintf (stderr," Warning: %s\n" , msg); } -int test__parse_events (void ) +int test__parse_events (int subtest__maybe_unused ) {int ret1, ret2 =0 ;
tools/perf/tests/parse-no-sample-id-all.c +1 -1
@@ -67,7 +67,7 @@ struct test_attr_event {* * Return: %0 on success, %-1 if the test fails. */ -int test__parse_no_sample_id_all (void ) +int test__parse_no_sample_id_all (int subtest__maybe_unused ) {int err;
tools/perf/tests/perf-record.c +1 -1
@@ -32,7 +32,7 @@ realloc:return cpu; } -int test__PERF_RECORD (void ) +int test__PERF_RECORD (int subtest__maybe_unused ) {struct record_opts opts = { .target = {
tools/perf/tests/pmu.c +1 -1
@@ -133,7 +133,7 @@ static struct list_head *test_terms_list(void)return &terms; } -int test__pmu (void ) +int test__pmu (int subtest__maybe_unused ) {char *format =test_format_dir_get ();LIST_HEAD (formats);
tools/perf/tests/python-use.c +2 -1
@@ -4,11 +4,12 @@#include <stdio.h> #include <stdlib.h> +#include <linux/compiler.h> #include "tests.h" extern int verbose; -int test__python_use (void ) +int test__python_use (int subtest__maybe_unused ) {char *cmd;int ret;
tools/perf/tests/sample-parsing.c +1 -1
@@ -290,7 +290,7 @@ out_free:* checks sample format bits separately and together. If the test passes %0 is * returned, otherwise %-1 is returned. */ -int test__sample_parsing (void ) +int test__sample_parsing (int subtest__maybe_unused ) {const u64 rf[] = {4 ,5 ,6 ,7 ,12 ,13 ,14 ,15 };u64 sample_type;
tools/perf/tests/sw-clock.c +1 -1
@@ -122,7 +122,7 @@ out_delete_evlist:return err; } -int test__sw_clock_freq (void ) +int test__sw_clock_freq (int subtest__maybe_unused ) {int ret;
tools/perf/tests/switch-tracking.c +1 -1
@@ -305,7 +305,7 @@ out_free_nodes:* evsel->system_wide and evsel->tracking flags (respectively) with other events * sometimes enabled or disabled. */ -int test__switch_tracking (void ) +int test__switch_tracking (int subtest__maybe_unused ) {const char *sched_switch ="sched:sched_switch" ;struct switch_tracking switch_tracking = { .tids =NULL , };
tools/perf/tests/task-exit.c +1 -1
@@ -31,7 +31,7 @@ static void workload_exec_failed_signal(int signo __maybe_unused,* if the number of exit event reported by the kernel is 1 or not * in order to check the kernel returns correct number of event. */ -int test__task_exit (void ) +int test__task_exit (int subtest__maybe_unused ) {int err =-1 ;union perf_event *event;
tools/perf/tests/tests.h +39 -39
87 lines not on this page · raw message
tools/perf/tests/thread-map.c +1 -1
@@ -4,7 +4,7 @@#include "thread_map.h" #include "debug.h" -int test__thread_map (void ) +int test__thread_map (int subtest__maybe_unused ) {struct thread_map *map;
tools/perf/tests/thread-mg-share.c +1 -1
@@ -4,7 +4,7 @@#include "map.h" #include "debug.h" -int test__thread_mg_share (void ) +int test__thread_mg_share (int subtest__maybe_unused ) {struct machines machines;struct machine *machine;
tools/perf/tests/topology.c +1 -1
@@ -84,7 +84,7 @@ static int check_cpu_topology(char *path, struct cpu_map *map)return 0 ; } -int test_session_topology (void ) +int test_session_topology (int subtest__maybe_unused ) {char path[PATH_MAX ];struct cpu_map *map;
tools/perf/tests/vmlinux-kallsyms.c +1 -1
@@ -18,7 +18,7 @@ static int vmlinux_matches_kallsyms_filter(struct map *map __maybe_unused,#define UM (x) kallsyms_map->unmap_ip(kallsyms_map, (x)) -int test__vmlinux_matches_kallsyms (void ) +int test__vmlinux_matches_kallsyms (int subtest__maybe_unused ) {int err =-1 ;struct rb_node *nd;