Some exit code tidying
Ian Rogers
reviewercover Some exit code tidying
I'm interested in varying error codes for things like parse event failures. This is some cleanup to use more intention revealing names in the existing exit/test cases.
Ian Rogers (3):
libperf: Prefer exit(EXIT_SUCCESS) over exit(0)
tools perf: Prefer exit(EXIT_*) over exit(0|1)
perf test: Be more consistent in use of TEST_*
tools/lib/perf/tests/test-evlist.c | 2 +- tools/perf/arch/x86/tests/bp-modify.c | 4 +- tools/perf/arch/x86/tests/rdpmc.c | 8 +- tools/perf/bench/inject-buildid.c | 8 +- tools/perf/bench/numa.c | 2 +- tools/perf/bench/sched-messaging.c | 6 +- tools/perf/bench/sched-pipe.c | 4 +- tools/perf/bench/syscall.c | 2 +- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-ftrace.c | 2 +- tools/perf/builtin-mem.c | 2 +- tools/perf/builtin-script.c | 4 +- tools/perf/perf.c | 8 +- tools/perf/tests/attr.c | 2 +- tools/perf/tests/bitmap.c | 2 +- tools/perf/tests/bp_account.c | 4 +- tools/perf/tests/bp_signal.c | 51 +++++++-- tools/perf/tests/code-reading.c | 12 +- tools/perf/tests/cpumap.c | 10 +- tools/perf/tests/dso-data.c | 8 +- tools/perf/tests/dwarf-unwind.c | 14 ++- tools/perf/tests/event-times.c | 2 +- tools/perf/tests/evsel-roundtrip-name.c | 14 +-- tools/perf/tests/evsel-tp-sched.c | 28 ++--- tools/perf/tests/expr.c | 4 +- tools/perf/tests/fdarray.c | 4 +- tools/perf/tests/genelf.c | 2 +- tools/perf/tests/hists_cumulate.c | 2 +- tools/perf/tests/hists_filter.c | 12 +- tools/perf/tests/hists_link.c | 33 +++--- tools/perf/tests/keep-tracking.c | 4 +- tools/perf/tests/kmod-path.c | 6 +- tools/perf/tests/mem.c | 4 +- tools/perf/tests/mem2node.c | 2 +- tools/perf/tests/mmap-basic.c | 10 +- tools/perf/tests/mmap-thread-lookup.c | 2 +- tools/perf/tests/openat-syscall-all-cpus.c | 4 +- tools/perf/tests/openat-syscall-tp-fields.c | 4 +- tools/perf/tests/openat-syscall.c | 6 +- tools/perf/tests/parse-events.c | 118 ++++++++++---------- tools/perf/tests/parse-metric.c | 16 +-- tools/perf/tests/parse-no-sample-id-all.c | 4 +- tools/perf/tests/perf-hooks.c | 2 +- tools/perf/tests/perf-record.c | 2 +- tools/perf/tests/perf-time-to-tsc.c | 4 +- tools/perf/tests/pfm.c | 4 +- tools/perf/tests/pmu-events.c | 36 +++--- tools/perf/tests/pmu.c | 16 +-- tools/perf/tests/python-use.c | 2 +- tools/perf/tests/sample-parsing.c | 10 +- tools/perf/tests/stat.c | 12 +- tools/perf/tests/sw-clock.c | 8 +- tools/perf/tests/switch-tracking.c | 9 +- tools/perf/tests/task-exit.c | 12 +- tools/perf/tests/tests.h | 4 +- tools/perf/tests/thread-map.c | 8 +- tools/perf/tests/thread-maps-share.c | 2 +- tools/perf/tests/time-utils-test.c | 2 +- tools/perf/tests/topology.c | 2 +- tools/perf/tests/vmlinux-kallsyms.c | 6 +- tools/perf/tests/wp.c | 10 +- tools/perf/ui/tui/setup.c | 4 +- tools/perf/util/dlfilter.c | 2 +- tools/perf/util/help-unknown-cmd.c | 2 +- 64 files changed, 319 insertions(+), 278 deletions(-)
Signature · 1 line
2.32.0.432.gabb21c7263-goog
Ian Rogers
reviewerPATCH 1/3 libperf: Prefer exit(EXIT_SUCCESS) over exit(0)
Change exit code to be more intention revealing.
--- tools/lib/perf/tests/test-evlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/perf/tests/test-evlist.c +1 -1
@@ -251,7 +251,7 @@ static int test_mmap_thread(void)for (i =0 ; i <100 ; i++)prctl (0 ,0 ,0 ,0 ,0 ); -exit (0 ); +exit (EXIT_SUCCESS ); } threads =perf_thread_map__new_dummy ();
Signature · 1 line
2.32.0.432.gabb21c7263-goog
Ian Rogers
reviewerPATCH 2/3 tools perf: Prefer exit(EXIT_*) over exit(0|1)
In reply to Ian RogersChange exit code to be more intention revealing, replacing exit(0) with exit(EXIT_SUCCESS) and exit(1) with exit(EXIT_FAILURE).
--- tools/perf/arch/x86/tests/bp-modify.c | 4 ++-- tools/perf/bench/inject-buildid.c | 8 ++++---- tools/perf/bench/numa.c | 2 +- tools/perf/bench/sched-messaging.c | 6 +++--- tools/perf/bench/sched-pipe.c | 4 ++-- tools/perf/bench/syscall.c | 2 +- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-ftrace.c | 2 +- tools/perf/builtin-mem.c | 2 +- tools/perf/builtin-script.c | 4 ++-- tools/perf/perf.c | 8 ++++---- tools/perf/ui/tui/setup.c | 4 ++-- tools/perf/util/dlfilter.c | 2 +- tools/perf/util/help-unknown-cmd.c | 2 +- 14 files changed, 26 insertions(+), 26 deletions(-)
tools/perf/arch/x86/tests/bp-modify.c +2 -2
@@ -41,12 +41,12 @@ static int spawn_child(void)if (err) {pr_debug ("failed to PTRACE_TRACEME\n" ); -exit (1 ); +exit (EXIT_FAILURE ); }raise (SIGCONT );bp_1 (); -exit (0 ); +exit (EXIT_SUCCESS ); }return child;
tools/perf/bench/inject-buildid.c +4 -4
@@ -106,7 +106,7 @@ static void collect_dso(void) dsos =calloc (nr_mmaps *DSO_MMAP_RATIO ,sizeof (*dsos));if (dsos ==NULL ) {printf (" Memory allocation failed\n" ); -exit (1 ); +exit (EXIT_FAILURE ); }if (nftw ("/usr/lib/" , add_dso,10 ,FTW_PHYS ) <0 )
@@ -305,7 +305,7 @@ static int setup_injection(struct bench_data *data, bool build_id_all) dev_null_fd =open ("/dev/null" ,O_WRONLY );if (dev_null_fd <0 ) -exit (1 ); +exit (EXIT_FAILURE );dup2 (dev_null_fd,STDERR_FILENO );
@@ -314,7 +314,7 @@ static int setup_injection(struct bench_data *data, bool build_id_all) inject_argv =calloc (inject_argc +1 ,sizeof (*inject_argv));if (inject_argv ==NULL ) -exit (1 ); +exit (EXIT_FAILURE ); inject_argv[0 ] =strdup ("inject" ); inject_argv[1 ] =strdup ("-b" );
@@ -326,7 +326,7 @@ static int setup_injection(struct bench_data *data, bool build_id_all)cmd_inject (inject_argc, inject_argv); -exit (0 ); +exit (EXIT_SUCCESS ); }pthread_create (&data->th,NULL , data_reader, data);
tools/perf/bench/numa.c +1 -1
@@ -1551,7 +1551,7 @@ static int __bench_numa(const char *name)/* Child process: */ worker_process (i); -exit (0 ); +exit (EXIT_SUCCESS ); } pids[i] = pid;
tools/perf/bench/sched-messaging.c +3 -3
@@ -149,7 +149,7 @@ static pthread_t create_worker(void *ctx, void *(*func)(void *))break ;case 0 : (*func) (ctx); -exit (0 ); +exit (EXIT_SUCCESS );break ;default :break ;
@@ -182,7 +182,7 @@ static void reap_worker(pthread_t id)/* process mode */ wait (&proc_status);if (!WIFEXITED (proc_status)) -exit (1 ); +exit (EXIT_FAILURE ); }else {pthread_join (id, &thread_status); }
@@ -319,7 +319,7 @@ int bench_sched_messaging(int argc, const char **argv)default :/* reaching here is something disaster */ fprintf (stderr,"Unknown format:%d\n" , bench_format); -exit (1 ); +exit (EXIT_FAILURE );break ; }
tools/perf/bench/sched-pipe.c +2 -2
@@ -135,7 +135,7 @@ int bench_sched_pipe(int argc, const char **argv)if (!pid) {worker_thread (threads +0 ); -exit (0 ); +exit (EXIT_SUCCESS ); }else {worker_thread (threads +1 ); }
@@ -175,7 +175,7 @@ int bench_sched_pipe(int argc, const char **argv)default :/* reaching here is something disaster */ fprintf (stderr,"Unknown format:%d\n" , bench_format); -exit (1 ); +exit (EXIT_FAILURE );break ; }
tools/perf/bench/syscall.c +1 -1
@@ -73,7 +73,7 @@ int bench_syscall_basic(int argc, const char **argv)default :/* reaching here is something disaster */ fprintf (stderr,"Unknown format:%d\n" , bench_format); -exit (1 ); +exit (EXIT_FAILURE );break ; }
tools/perf/builtin-c2c.c +1 -1
@@ -2889,7 +2889,7 @@ static int parse_record_events(const struct option *opt,if (!strcmp (str,"list" )) {perf_mem_events__list (); -exit (0 ); +exit (EXIT_SUCCESS ); }if (perf_mem_events__parse (str))exit (-1 );
tools/perf/builtin-ftrace.c +1 -1
@@ -750,7 +750,7 @@ static int opt_list_avail_functions(const struct option *opt __maybe_unused,if (ret <0 )return ret; -exit (0 ); +exit (EXIT_SUCCESS ); } static int parse_filter_func(const struct option *opt, const char *str,
tools/perf/builtin-mem.c +1 -1
@@ -45,7 +45,7 @@ static int parse_record_events(const struct option *opt,if (!strcmp (str,"list" )) {perf_mem_events__list (); -exit (0 ); +exit (EXIT_SUCCESS ); }if (perf_mem_events__parse (str))exit (-1 );
tools/perf/builtin-script.c +2 -2
@@ -2774,7 +2774,7 @@ static int parse_scriptname(const struct option *opt __maybe_unused,if (strcmp (str,"lang" ) ==0 ) {list_available_languages (); -exit (0 ); +exit (EXIT_SUCCESS ); } script =strchr (str,':' );
@@ -3175,7 +3175,7 @@ static int list_available_scripts(const struct option *opt __maybe_unused, desc->half_liner ? desc->half_liner : ""); } -exit (0 ); +exit (EXIT_SUCCESS ); } static int add_dlarg(const struct option *opt __maybe_unused,
tools/perf/perf.c +4 -4
@@ -214,11 +214,11 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)set_argv_exec_path (cmd +1 ); else {puts (get_argv_exec_path ()); -exit (0 ); +exit (EXIT_SUCCESS ); } }else if (!strcmp (cmd,"--html-path" )) {puts (system_path (PERF_HTML_PATH )); -exit (0 ); +exit (EXIT_SUCCESS ); }else if (!strcmp (cmd,"-p" ) || !strcmp (cmd,"--paginate" )) { use_pager =1 ; }else if (!strcmp (cmd,"--no-pager" )) {
@@ -258,7 +258,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)printf ("%s " , p->cmd); }putchar ('\n' ); -exit (0 ); +exit (EXIT_SUCCESS ); }else if (!strcmp (cmd,"--list-opts" )) {unsigned int i;
@@ -267,7 +267,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)printf ("--%s " , p->long_name); }putchar ('\n' ); -exit (0 ); +exit (EXIT_SUCCESS ); }else if (!strcmp (cmd,"--debug" )) {if (*argc <2 ) {fprintf (stderr,"No variable specified for --debug.\n" );
tools/perf/ui/tui/setup.c +2 -2
@@ -109,7 +109,7 @@ static void ui__signal_backtrace(int sig) size =backtrace (stackdump,ARRAY_SIZE (stackdump));backtrace_symbols_fd (stackdump, size,STDOUT_FILENO ); - exit(0); + exit(EXIT_SUCCESS); }#else # define ui__signal_backtrace ui__signal
@@ -119,7 +119,7 @@ static void ui__signal(int sig) {ui__exit (false);psignal (sig,"perf" ); -exit (0 ); +exit (EXIT_SUCCESS ); }int ui__init (void )
tools/perf/util/dlfilter.c +1 -1
@@ -611,5 +611,5 @@ int list_available_dlfilters(const struct option *opt __maybe_unused,free (exec_path); out: -exit (0 ); +exit (EXIT_SUCCESS ); }
tools/perf/util/help-unknown-cmd.c +1 -1
@@ -114,5 +114,5 @@ const char *help_unknown_cmd(const char *cmd)fprintf (stderr,"\t%s\n" , main_cmds.names[i]->name); } end: -exit (1 ); +exit (EXIT_FAILURE ); }
Signature · 1 line
2.32.0.432.gabb21c7263-goog
Ian Rogers
reviewerPATCH 3/3 perf test: Be more consistent in use of TEST_*
In reply to Ian RogersThe TEST_OK, TEST_FAIL and TEST_SKIP enum values are used inconsistently. Try to reduce this by swapping constants for enum values to try to be more intention revealing.
--- tools/perf/arch/x86/tests/rdpmc.c | 8 +- tools/perf/tests/attr.c | 2 +- tools/perf/tests/bitmap.c | 2 +- tools/perf/tests/bp_account.c | 4 +- tools/perf/tests/bp_signal.c | 51 +++++++-- tools/perf/tests/code-reading.c | 12 +- tools/perf/tests/cpumap.c | 10 +- tools/perf/tests/dso-data.c | 8 +- tools/perf/tests/dwarf-unwind.c | 14 ++- tools/perf/tests/event-times.c | 2 +- tools/perf/tests/evsel-roundtrip-name.c | 14 +-- tools/perf/tests/evsel-tp-sched.c | 28 ++--- tools/perf/tests/expr.c | 4 +- tools/perf/tests/fdarray.c | 4 +- tools/perf/tests/genelf.c | 2 +- tools/perf/tests/hists_cumulate.c | 2 +- tools/perf/tests/hists_filter.c | 12 +- tools/perf/tests/hists_link.c | 33 +++--- tools/perf/tests/keep-tracking.c | 4 +- tools/perf/tests/kmod-path.c | 6 +- tools/perf/tests/mem.c | 4 +- tools/perf/tests/mem2node.c | 2 +- tools/perf/tests/mmap-basic.c | 10 +- tools/perf/tests/mmap-thread-lookup.c | 2 +- tools/perf/tests/openat-syscall-all-cpus.c | 4 +- tools/perf/tests/openat-syscall-tp-fields.c | 4 +- tools/perf/tests/openat-syscall.c | 6 +- tools/perf/tests/parse-events.c | 118 ++++++++++---------- tools/perf/tests/parse-metric.c | 16 +-- tools/perf/tests/parse-no-sample-id-all.c | 4 +- tools/perf/tests/perf-hooks.c | 2 +- tools/perf/tests/perf-record.c | 2 +- tools/perf/tests/perf-time-to-tsc.c | 4 +- tools/perf/tests/pfm.c | 4 +- tools/perf/tests/pmu-events.c | 36 +++--- tools/perf/tests/pmu.c | 16 +-- tools/perf/tests/python-use.c | 2 +- tools/perf/tests/sample-parsing.c | 10 +- tools/perf/tests/stat.c | 12 +- tools/perf/tests/sw-clock.c | 8 +- tools/perf/tests/switch-tracking.c | 9 +- tools/perf/tests/task-exit.c | 12 +- tools/perf/tests/tests.h | 4 +- tools/perf/tests/thread-map.c | 8 +- tools/perf/tests/thread-maps-share.c | 2 +- tools/perf/tests/time-utils-test.c | 2 +- tools/perf/tests/topology.c | 2 +- tools/perf/tests/vmlinux-kallsyms.c | 6 +- tools/perf/tests/wp.c | 10 +- 49 files changed, 292 insertions(+), 251 deletions(-)
tools/perf/arch/x86/tests/rdpmc.c +4 -4
@@ -89,7 +89,7 @@ static void segfault_handler(int sig __maybe_unused, siginfo_t *info __maybe_unused, void *uc __maybe_unused) { -exit (-1 ); +exit (TEST_FAIL ); }static int __test__rdpmc (void )
@@ -119,7 +119,7 @@ static int __test__rdpmc(void)pr_err ("Error: sys_perf_event_open() syscall returned " "with %d (%s)\n" , fd,str_error_r (errno, sbuf,sizeof (sbuf))); -return -1 ; +return TEST_FAIL ; } addr =mmap (NULL , page_size,PROT_READ ,MAP_SHARED , fd,0 );
@@ -152,9 +152,9 @@ static int __test__rdpmc(void)close (fd);if (!delta_sum) -return -1 ; +return TEST_FAIL ; -return 0 ; +return TEST_OK ; }int test__rdpmc (struct test *test__maybe_unused ,int subtest__maybe_unused )
tools/perf/tests/attr.c +1 -1
@@ -194,7 +194,7 @@ int test__attr(struct test *test __maybe_unused, int subtest __maybe_unused) exec_path =get_argv_exec_path ();if (exec_path ==NULL ) -return -1 ; +return TEST_FAIL ;/* Then installed path. */ snprintf (path_dir,PATH_MAX ,"%s/tests" , exec_path);
tools/perf/tests/bitmap.c +1 -1
@@ -49,5 +49,5 @@ int test__bitmap_print(struct test *test __maybe_unused, int subtest __maybe_unuTEST_ASSERT_VAL ("failed to convert map" ,test_bitmap ("1,3-6,8-10,24,35-37" ));TEST_ASSERT_VAL ("failed to convert map" ,test_bitmap ("1,3-6,8-10,24,35-37" ));TEST_ASSERT_VAL ("failed to convert map" ,test_bitmap ("1-10,12-20,22-30,32-40" )); -return 0 ; +return TEST_OK ; }
tools/perf/tests/bp_account.c +2 -2
@@ -49,7 +49,7 @@ static int __event(bool is_x, void *addr, struct perf_event_attr *attr) perf_event_open_cloexec_flag());if (fd <0 ) {pr_debug ("failed opening event %llx\n" , attr->config); -return TEST_FAIL ; +return -1 ; }return fd;
@@ -94,7 +94,7 @@ static int bp_accounting(int wp_cnt, int share)for (i =0 ; i < wp_cnt; i++)close (fd[i]); -return 0 ; +return TEST_OK ; }static int detect_cnt (bool is_x)
tools/perf/tests/bp_signal.c +40 -11
95 lines not on this page · raw message
tools/perf/tests/code-reading.c +6 -6
@@ -725,20 +725,20 @@ int test__code_reading(struct test *test __maybe_unused, int subtest __maybe_unuswitch (ret) {case TEST_CODE_READING_OK : -return 0 ; +return TEST_OK ;case TEST_CODE_READING_NO_VMLINUX :pr_debug ("no vmlinux\n" ); -return 0 ; +return TEST_SKIP ;case TEST_CODE_READING_NO_KCORE :pr_debug ("no kcore\n" ); -return 0 ; +return TEST_SKIP ;case TEST_CODE_READING_NO_ACCESS :pr_debug ("no access\n" ); -return 0 ; +return TEST_SKIP ;case TEST_CODE_READING_NO_KERNEL_OBJ :pr_debug ("no kernel obj\n" ); -return 0 ; +return TEST_SKIP ;default : -return -1 ; +return TEST_FAIL ; }; }
tools/perf/tests/cpumap.c +5 -5
@@ -42,7 +42,7 @@ static int process_event_mask(struct perf_tool *tool __maybe_unused, }perf_cpu_map__put (map); -return 0 ; +return TEST_OK ; } static int process_event_cpus(struct perf_tool *tool __maybe_unused,
@@ -71,7 +71,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,TEST_ASSERT_VAL ("wrong cpu" , map->map[1 ] ==256 );TEST_ASSERT_VAL ("wrong refcnt" ,refcount_read (&map->refcnt) ==1 );perf_cpu_map__put (map); -return 0 ; +return TEST_OK ; }
@@ -94,7 +94,7 @@ int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __may !perf_event__synthesize_cpu_map(NULL, cpus, process_event_cpus, NULL));perf_cpu_map__put (cpus); -return 0 ; +return TEST_OK ; }static int cpu_map_print (const char *str)
@@ -120,7 +120,7 @@ int test__cpu_map_print(struct test *test __maybe_unused, int subtest __maybe_unTEST_ASSERT_VAL ("failed to convert map" ,cpu_map_print ("1,3-6,8-10,24,35-37" ));TEST_ASSERT_VAL ("failed to convert map" ,cpu_map_print ("1,3-6,8-10,24,35-37" ));TEST_ASSERT_VAL ("failed to convert map" ,cpu_map_print ("1-10,12-20,22-30,32-40" )); -return 0 ; +return TEST_OK ; }int test__cpu_map_merge (struct test *test__maybe_unused ,int subtest__maybe_unused )
@@ -135,5 +135,5 @@ int test__cpu_map_merge(struct test *test __maybe_unused, int subtest __maybe_unTEST_ASSERT_VAL ("failed to merge map: bad result" , !strcmp (buf,"1-2,4-5,7" ));perf_cpu_map__put (b);perf_cpu_map__put (c); -return 0 ; +return TEST_OK ; }
tools/perf/tests/dso-data.c +4 -4
@@ -171,7 +171,7 @@ int test__dso_data(struct test *test __maybe_unused, int subtest __maybe_unused)dso__put (dso);unlink (file); -return 0 ; +return TEST_OK ; }static long open_files_cnt (void )
@@ -218,7 +218,7 @@ static int dsos__create(int cnt, int size)TEST_ASSERT_VAL ("failed to get dso" , dsos[i]); } -return 0 ; +return TEST_OK ; }static void dsos__delete (int cnt)
@@ -305,7 +305,7 @@ int test__dso_data_cache(struct test *test __maybe_unused, int subtest __maybe_u nr_end =open_files_cnt ();pr_debug ("nr start %ld, nr stop %ld\n" , nr, nr_end);TEST_ASSERT_VAL ("failed leaking files" , nr == nr_end); -return 0 ; +return TEST_OK ; }int test__dso_data_reopen (struct test *test__maybe_unused ,int subtest__maybe_unused )
@@ -381,5 +381,5 @@ int test__dso_data_reopen(struct test *test __maybe_unused, int subtest __maybe_ nr_end =open_files_cnt ();pr_debug ("nr start %ld, nr stop %ld\n" , nr, nr_end);TEST_ASSERT_VAL ("failed leaking files" , nr == nr_end); -return 0 ; +return TEST_OK ; }
tools/perf/tests/dwarf-unwind.c +8 -6
@@ -95,7 +95,7 @@ noinline int test_dwarf_unwind__thread(struct thread *thread) {struct perf_sample sample;unsigned long cnt =0 ; -int err =-1 ; +int err =TEST_FAIL ;memset (&sample,0 ,sizeof (sample));
@@ -108,10 +108,12 @@ noinline int test_dwarf_unwind__thread(struct thread *thread) &sample, MAX_STACK);if (err)pr_debug ("unwind failed\n" ); -else if (cnt !=MAX_STACK ) { + + err = err ?TEST_FAIL :TEST_OK ; +if (cnt !=MAX_STACK ) {pr_debug ("got wrong number of stack entries %lu != %d\n" , cnt,MAX_STACK ); - err =-1 ; + err =TEST_FAIL ; } out:
@@ -174,17 +176,17 @@ int test__dwarf_unwind(struct test *test __maybe_unused, int subtest __maybe_unu {struct machine *machine;struct thread *thread; -int err =-1 ; +int err =TEST_FAIL ; machine =machine__new_host ();if (!machine) {pr_err ("Could not get machine\n" ); -return -1 ; +return TEST_FAIL ; }if (machine__create_kernel_maps (machine)) {pr_err ("Failed to create kernel maps\n" ); -return -1 ; +return TEST_FAIL ; } callchain_param.record_mode =CALLCHAIN_DWARF ;
tools/perf/tests/event-times.c +1 -1
@@ -218,7 +218,7 @@ static int test_times(int (attach)(struct evlist *),*/ int test__event_times (struct test *test__maybe_unused ,int subtest__maybe_unused ) { -int err, ret =0 ; +int err, ret =TEST_OK ;#define _T (attach, detach) \ err = test_times(attach, detach); \
tools/perf/tests/evsel-roundtrip-name.c +7 -7
@@ -11,12 +11,12 @@static int perf_evsel__roundtrip_cache_name_test (void ) {char name[128 ]; -int type, op, err =0 , ret =0 , i, idx; +int type, op, err, ret =TEST_OK , i, idx;struct evsel *evsel;struct evlist *evlist =evlist__new ();if (evlist ==NULL ) -return -ENOMEM ; +return TEST_FAIL ;for (type =0 ; type <PERF_COUNT_HW_CACHE_MAX ; type++) {for (op =0 ; op <PERF_COUNT_HW_CACHE_OP_MAX ; op++) {
@@ -28,7 +28,7 @@ static int perf_evsel__roundtrip_cache_name_test(void)__evsel__hw_cache_type_op_res_name (type, op, i, name,sizeof (name)); err =parse_events (evlist, name,NULL );if (err) - ret = err; + ret =TEST_FAIL ; } } }
@@ -51,7 +51,7 @@ static int perf_evsel__roundtrip_cache_name_test(void)if (strcmp (evsel__name (evsel), name)) {pr_debug ("%s != %s\n" ,evsel__name (evsel), name); - ret =-1 ; + ret =TEST_FAIL ; } evsel =evsel__next (evsel);
@@ -71,7 +71,7 @@ static int __perf_evsel__name_array_test(const char *names[], int nr_names,struct evlist *evlist =evlist__new ();if (evlist ==NULL ) -return -ENOMEM ; +return TEST_FAIL ;for (i =0 ; i < nr_names; ++i) { err =parse_events (evlist, names[i],NULL );
@@ -82,7 +82,7 @@ static int __perf_evsel__name_array_test(const char *names[], int nr_names, } } - err =0 ; + err =TEST_OK ;evlist__for_each_entry (evlist, evsel) {if (strcmp (evsel__name (evsel), names[evsel->core.idx / distance])) { --err;
@@ -100,7 +100,7 @@ static int __perf_evsel__name_array_test(const char *names[], int nr_names,int test__perf_evsel__roundtrip_name_test (struct test *test__maybe_unused ,int subtest__maybe_unused ) { -int err =0 , ret =0 ; +int err, ret =TEST_OK ;if (perf_pmu__has_hybrid ())return perf_evsel__name_array_test (evsel__hw_names,2 );
tools/perf/tests/evsel-tp-sched.c +14 -14
@@ -35,33 +35,33 @@ static int evsel__test_field(struct evsel *evsel, const char *name, int size, boint test__perf_evsel__tp_sched_test (struct test *test__maybe_unused ,int subtest__maybe_unused ) {struct evsel *evsel =evsel__newtp ("sched" ,"sched_switch" ); -int ret =0 ; +int ret =TEST_OK ;if (IS_ERR (evsel)) {pr_debug ("evsel__newtp failed with %ld\n" ,PTR_ERR (evsel)); -return -1 ; +return TEST_FAIL ; }if (evsel__test_field (evsel,"prev_comm" ,16 , false)) - ret =-1 ; + ret =TEST_FAIL ;if (evsel__test_field (evsel,"prev_pid" ,4 , true)) - ret =-1 ; + ret =TEST_FAIL ;if (evsel__test_field (evsel,"prev_prio" ,4 , true)) - ret =-1 ; + ret =TEST_FAIL ;if (evsel__test_field (evsel,"prev_state" ,sizeof (long ), true)) - ret =-1 ; + ret =TEST_FAIL ;if (evsel__test_field (evsel,"next_comm" ,16 , false)) - ret =-1 ; + ret =TEST_FAIL ;if (evsel__test_field (evsel,"next_pid" ,4 , true)) - ret =-1 ; + ret =TEST_FAIL ;if (evsel__test_field (evsel,"next_prio" ,4 , true)) - ret =-1 ; + ret =TEST_FAIL ;evsel__delete (evsel);
@@ -69,20 +69,20 @@ int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtesif (IS_ERR (evsel)) {pr_debug ("evsel__newtp failed with %ld\n" ,PTR_ERR (evsel)); -return -1 ; +return TEST_FAIL ; }if (evsel__test_field (evsel,"comm" ,16 , false)) - ret =-1 ; + ret =TEST_FAIL ;if (evsel__test_field (evsel,"pid" ,4 , true)) - ret =-1 ; + ret =TEST_FAIL ;if (evsel__test_field (evsel,"prio" ,4 , true)) - ret =-1 ; + ret =TEST_FAIL ;if (evsel__test_field (evsel,"target_cpu" ,4 , true)) - ret =-1 ; + ret =TEST_FAIL ;evsel__delete (evsel);return ret;
tools/perf/tests/expr.c +2 -2
@@ -13,7 +13,7 @@ static int test(struct expr_parse_ctx *ctx, const char *e, double val2)if (expr__parse (&val, ctx, e,1 ))TEST_ASSERT_VAL ("parse test failed" ,0 );TEST_ASSERT_VAL ("unexpected value" , val == val2); -return 0 ; +return TEST_OK ; }int test__expr (struct test *t__maybe_unused ,int subtest__maybe_unused )
@@ -84,5 +84,5 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)expr__ctx_clear (&ctx); -return 0 ; +return TEST_OK ; }
tools/perf/tests/fdarray.c +2 -2
@@ -82,7 +82,7 @@ int test__fdarray__filter(struct test *test __maybe_unused, int subtest __maybe_pr_debug ("\n" ); - err =0 ; + err =TEST_OK ; out_delete:fdarray__delete (fda); out:
@@ -152,7 +152,7 @@ int test__fdarray__add(struct test *test __maybe_unused, int subtest __maybe_unupr_debug ("\n" ); - err =0 ; + err =TEST_OK ; out_delete:fdarray__delete (fda); out:
tools/perf/tests/genelf.c +1 -1
@@ -44,7 +44,7 @@ int test__jit_write_elf(struct test *test __maybe_unused,unlink (path); -return ret ?TEST_FAIL :0 ; +return ret ?TEST_FAIL :TEST_OK ;#else return TEST_SKIP ;#endif
tools/perf/tests/hists_cumulate.c +1 -1
@@ -243,7 +243,7 @@ static int do_test(struct hists *hists, struct result *expected, size_t nr_expec i == nr_expected);TEST_ASSERT_VAL ("Incorrect number of callchain entry" , !symbol_conf.use_callchain || nr_expected == nr_callchain); -return 0 ; +return TEST_OK ; }/* NO callchain + NO children */
tools/perf/tests/hists_filter.c +8 -4
@@ -94,7 +94,7 @@ static int add_hist_entries(struct evlist *evlist, } } -return 0 ; +return TEST_OK ; out:pr_debug ("Not enough memory for adding a hist entry\n" );
@@ -103,7 +103,7 @@ static int add_hist_entries(struct evlist *evlist,int test__hists_filter (struct test *test__maybe_unused ,int subtest__maybe_unused ) { -int err =TEST_FAIL ; +int err;struct machines machines;struct machine *machine;struct evsel *evsel;
@@ -112,11 +112,15 @@ int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unuTEST_ASSERT_VAL ("No memory" , evlist); err =parse_events (evlist,"cpu-clock" ,NULL ); -if (err) +if (err) { + err =TEST_FAIL ; goto out; + } err =parse_events (evlist,"task-clock" ,NULL ); -if (err) +if (err) { + err =TEST_FAIL ; goto out; + } err =TEST_FAIL ;/* default sort order (comm,dso,sym) will be used */
tools/perf/tests/hists_link.c +18 -15
@@ -119,11 +119,11 @@ static int add_hist_entries(struct evlist *evlist, struct machine *machine) i++; } -return 0 ; +return TEST_OK ; out:pr_debug ("Not enough memory for adding a hist entry\n" ); -return -1 ; +return TEST_FAIL ; } static int find_sample(struct sample *samples, size_t nr_samples,
@@ -222,7 +222,7 @@ static int __validate_link(struct hists *hists, int idx) count_pair++; }else if (idx) {pr_debug ("A entry from the other hists should have pair\n" ); -return -1 ; +return TEST_FAIL ; } count++;
@@ -236,27 +236,27 @@ static int __validate_link(struct hists *hists, int idx)if (count_dummy !=ARRAY_SIZE (fake_samples[1 ]) -1 ) {pr_debug ("Invalid count of dummy entries: %zd of %zd\n" , count_dummy,ARRAY_SIZE (fake_samples[1 ]) -1 ); -return -1 ; +return TEST_FAIL ; }if (count != count_pair +ARRAY_SIZE (fake_samples[0 ])) {pr_debug ("Invalid count of total leader entries: %zd of %zd\n" , count, count_pair +ARRAY_SIZE (fake_samples[0 ])); -return -1 ; +return TEST_FAIL ; } }else {if (count != count_pair) {pr_debug ("Invalid count of total other entries: %zd of %zd\n" , count, count_pair); -return -1 ; +return TEST_FAIL ; }if (count_dummy >0 ) {pr_debug ("Other hists should not have dummy entries: %zd\n" , count_dummy); -return -1 ; +return TEST_FAIL ; } } -return 0 ; +return TEST_OK ; }static int validate_link (struct hists *leader,struct hists *other)
@@ -266,7 +266,7 @@ static int validate_link(struct hists *leader, struct hists *other)int test__hists_link (struct test *test__maybe_unused ,int subtest__maybe_unused ) { -int err =-1 ; +int err =TEST_FAIL ;struct hists *hists, *first_hists;struct machines machines;struct machine *machine =NULL ;
@@ -274,15 +274,18 @@ int test__hists_link(struct test *test __maybe_unused, int subtest __maybe_unusestruct evlist *evlist =evlist__new ();if (evlist ==NULL ) -return -ENOMEM ; +return TEST_FAIL ; err =parse_events (evlist,"cpu-clock" ,NULL ); -if (err) +if (err) { + err =TEST_FAIL ; goto out; + } err =parse_events (evlist,"task-clock" ,NULL ); -if (err) +if (err) { + err =TEST_FAIL ; goto out; - + } err =TEST_FAIL ;/* default sort order (comm,dso,sym) will be used */ if (setup_sorting (NULL ) <0 )
@@ -300,7 +303,7 @@ int test__hists_link(struct test *test __maybe_unused, int subtest __maybe_unuse/* process sample events */ err =add_hist_entries (evlist, machine); -if (err <0 ) +if (err !=TEST_OK ) goto out;evlist__for_each_entry (evlist, evsel) {
@@ -329,7 +332,7 @@ int test__hists_link(struct test *test __maybe_unused, int subtest __maybe_unuseif (err) goto out; - err =0 ; + err =TEST_OK ; out:/* tear down everything */
tools/perf/tests/keep-tracking.c +2 -2
@@ -75,7 +75,7 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_unstruct perf_cpu_map *cpus =NULL ;struct evlist *evlist =NULL ;struct evsel *evsel =NULL ; -int found, err =-1 ; +int found, err =TEST_FAIL ;const char *comm; threads =thread_map__new (-1 ,getpid (),UINT_MAX );
@@ -148,7 +148,7 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un goto out_err; } - err =0 ; + err =TEST_OK ; out_err:if (evlist) {
tools/perf/tests/kmod-path.c +3 -3
@@ -29,7 +29,7 @@ static int test(const char *path, bool alloc_name, bool kmod,TEST_ASSERT_VAL ("wrong name" , !m.name);free (m.name); -return 0 ; +return TEST_OK ; }static int test_is_kernel_module (const char *path,int cpumode,bool expect)
@@ -38,7 +38,7 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect) (!!is_kernel_module(path, cpumode)) == (!!expect));pr_debug ("%s (cpumode: %d) - is_kernel_module: %s\n" , path, cpumode, expect ?"true" :"false" ); -return 0 ; +return TEST_OK ; }#define T (path, an, k, c, n) \
@@ -157,5 +157,5 @@ int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unM ("[kernel.kallsyms]" ,PERF_RECORD_MISC_KERNEL , false);M ("[kernel.kallsyms]" ,PERF_RECORD_MISC_USER , false); -return 0 ; +return TEST_OK ; }
tools/perf/tests/mem.c +2 -2
@@ -20,12 +20,12 @@ static int check(union perf_mem_data_src data_src, n +=perf_mem__lvl_scnprintf (out + n,sizeof out - n, &mi);scnprintf (failure,sizeof failure,"unexpected %s" , out);TEST_ASSERT_VAL (failure, !strcmp (string, out)); -return 0 ; +return TEST_OK ; }int test__mem (struct test *text__maybe_unused ,int subtest__maybe_unused ) { -int ret =0 ; +int ret =TEST_OK ;union perf_mem_data_src src;memset (&src,0 ,sizeof (src));
tools/perf/tests/mem2node.c +1 -1
@@ -75,5 +75,5 @@ int test__mem2node(struct test *t __maybe_unused, int subtest __maybe_unused)zfree (&nodes[i].set);mem2node__exit (&map); -return 0 ; +return TEST_OK ; }
tools/perf/tests/mmap-basic.c +5 -5
@@ -31,7 +31,7 @@*/ int test__basic_mmap (struct test *test__maybe_unused ,int subtest__maybe_unused ) { -int err =-1 ; +int err =TEST_FAIL ;union perf_event *event;struct perf_thread_map *threads;struct perf_cpu_map *cpus;
@@ -49,7 +49,7 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse threads =thread_map__new (-1 ,getpid (),UINT_MAX );if (threads ==NULL ) {pr_debug ("thread_map__new\n" ); -return -1 ; +return TEST_FAIL ; } cpus =perf_cpu_map__new (NULL );
@@ -132,7 +132,7 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse goto out_delete_evlist; } - err =-1 ; + err =TEST_FAIL ; evsel =evlist__id2evsel (evlist, sample.id);if (evsel ==NULL ) { pr_debug("event with id %" PRIu64
@@ -145,13 +145,13 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuseperf_mmap__read_done (&md->core); out_init: - err =0 ; + err =TEST_OK ;evlist__for_each_entry (evlist, evsel) {if (nr_events[evsel->core.idx] != expected_nr_events[evsel->core.idx]) {pr_debug ("expected %d %s events, got %d\n" , expected_nr_events[evsel->core.idx],evsel__name (evsel), nr_events[evsel->core.idx]); - err =-1 ; + err =TEST_FAIL ; goto out_delete_evlist; } }
tools/perf/tests/mmap-thread-lookup.c +1 -1
@@ -234,5 +234,5 @@ int test__mmap_thread_lookup(struct test *test __maybe_unused, int subtest __mayTEST_ASSERT_VAL ("failed with sythesizing process" , !mmap_events (synth_process)); -return 0 ; +return TEST_OK ; }
tools/perf/tests/openat-syscall-all-cpus.c +2 -2
@@ -21,7 +21,7 @@int test__openat_syscall_event_on_all_cpus (struct test *test__maybe_unused ,int subtest__maybe_unused ) { -int err =-1 , fd, cpu; +int err =TEST_FAIL , fd, cpu;struct perf_cpu_map *cpus;struct evsel *evsel;unsigned int nr_openat_calls =111 , i;
@@ -94,7 +94,7 @@ int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int goto out_close_fd; } - err =0 ; + err =TEST_OK ;for (cpu =0 ; cpu < cpus->nr; ++cpu) {unsigned int expected;
tools/perf/tests/openat-syscall-tp-fields.c +2 -2
@@ -38,7 +38,7 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtestint flags =O_RDONLY |O_DIRECTORY ;struct evlist *evlist =evlist__new ();struct evsel *evsel; -int err =-1 , i, nr_events =0 , nr_polls =0 ; +int err =TEST_FAIL , i, nr_events =0 , nr_polls =0 ;char sbuf[STRERR_BUFSIZE ];if (evlist ==NULL ) {
@@ -136,7 +136,7 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest } } out_ok: - err =0 ; + err =TEST_OK ; out_delete_evlist:evlist__delete (evlist); out:
tools/perf/tests/openat-syscall.c +3 -3
@@ -15,7 +15,7 @@int test__openat_syscall_event (struct test *test__maybe_unused ,int subtest__maybe_unused ) { -int err =-1 , fd; +int err =TEST_FAIL , fd;struct evsel *evsel;unsigned int nr_openat_calls =111 , i;struct perf_thread_map *threads =thread_map__new (-1 ,getpid (),UINT_MAX );
@@ -24,7 +24,7 @@ int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __mif (threads ==NULL ) {pr_debug ("thread_map__new\n" ); -return -1 ; +return TEST_FAIL ; } evsel =evsel__newtp ("syscalls" ,"sys_enter_openat" );
@@ -57,7 +57,7 @@ int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __m goto out_close_fd; } - err =0 ; + err =TEST_OK ; out_close_fd:perf_evsel__close_fd (&evsel->core); out_evsel_delete:
tools/perf/tests/parse-events.c +59 -59
469 lines not on this page · raw message
tools/perf/tests/parse-metric.c +8 -8
@@ -222,7 +222,7 @@ static int test_ipc(void)TEST_ASSERT_VAL ("IPC failed, wrong ratio" , ratio ==1.5 ); -return 0 ; +return TEST_OK ; }static int test_frontend (void )
@@ -241,7 +241,7 @@ static int test_frontend(void)TEST_ASSERT_VAL ("Frontend_Bound_SMT failed, wrong ratio" , ratio ==0.45 ); -return 0 ; +return TEST_OK ; }static int test_cache_miss_cycles (void )
@@ -259,7 +259,7 @@ static int test_cache_miss_cycles(void)TEST_ASSERT_VAL ("cache_miss_cycles failed, wrong ratio" , ratio ==1.25 ); -return 0 ; +return TEST_OK ; }
@@ -308,7 +308,7 @@ static int test_dcache_l2(void)TEST_ASSERT_VAL ("DCache_L2_Misses failed, wrong ratio" , ratio ==0.7 ); -return 0 ; +return TEST_OK ; }static int test_recursion_fail (void )
@@ -325,7 +325,7 @@ static int test_recursion_fail(void)TEST_ASSERT_VAL ("failed to find recursion" ,compute_metric ("M3" , vals, &ratio) ==-1 ); -return 0 ; +return TEST_OK ; }static int test_memory_bandwidth (void )
@@ -342,7 +342,7 @@ static int test_memory_bandwidth(void)TEST_ASSERT_VAL ("L1D_Cache_Fill_BW, wrong ratio" ,1.28 == ratio); -return 0 ; +return TEST_OK ; }static int test_metric_group (void )
@@ -366,7 +366,7 @@ static int test_metric_group(void)TEST_ASSERT_VAL ("group cache_miss_cycles failed, wrong ratio" , ratio2 ==1.25 ); -return 0 ; +return TEST_OK ; }int test__parse_metric (struct test *test__maybe_unused ,int subtest__maybe_unused )
@@ -381,5 +381,5 @@ int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unuTEST_ASSERT_VAL ("cache_miss_cycles failed" ,test_cache_miss_cycles () ==0 );TEST_ASSERT_VAL ("test metric group" ,test_metric_group () ==0 ); } -return 0 ; +return TEST_OK ; }
tools/perf/tests/parse-no-sample-id-all.c +2 -2
@@ -99,7 +99,7 @@ int test__parse_no_sample_id_all(struct test *test __maybe_unused, int subtest _ err =process_events (events,ARRAY_SIZE (events));if (err) -return -1 ; +return TEST_FAIL ; -return 0 ; +return TEST_OK ; }
tools/perf/tests/perf-hooks.c +1 -1
@@ -12,7 +12,7 @@ static void sigsegv_handler(int sig __maybe_unused)perf_hooks__recover ();signal (SIGSEGV ,SIG_DFL );raise (SIGSEGV ); -exit (-1 ); +exit (TEST_FAIL ); }
tools/perf/tests/perf-record.c +1 -1
@@ -330,5 +330,5 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus out_delete_evlist:evlist__delete (evlist); out: -return (err <0 || errs >0 ) ?-1 :0 ; +return (err <0 || errs >0 ) ?TEST_FAIL :TEST_OK ; }
tools/perf/tests/perf-time-to-tsc.c +2 -2
@@ -59,7 +59,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybestruct perf_cpu_map *cpus =NULL ;struct evlist *evlist =NULL ;struct evsel *evsel =NULL ; -int err =-1 , ret, i; +int err =TEST_FAIL , ret, i;const char *comm1, *comm2;struct perf_tsc_conversion tc;struct perf_event_mmap_page *pc;
@@ -175,7 +175,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe test_tsc >= comm2_tsc) goto out_err; - err =0 ; + err =TEST_OK ; out_err:evlist__delete (evlist);
tools/perf/tests/pfm.c +2 -2
@@ -101,7 +101,7 @@ static int test__pfm_events(void)evlist__delete (evlist); } -return 0 ; +return TEST_OK ; }static int test__pfm_group (void )
@@ -185,7 +185,7 @@ static int test__pfm_group(void) evlist__delete(evlist); } -return 0 ; +return TEST_OK ; }#endif
tools/perf/tests/pmu-events.c +18 -18
@@ -173,7 +173,7 @@ static int test_pmu_event_table(void)ARRAY_SIZE (test_uncore_events) -2 ;if (!map) -return -1 ; +return TEST_FAIL ;for (table = map->table; table->name; table++) {struct perf_pmu_test_event *test;
@@ -196,56 +196,56 @@ static int test_pmu_event_table(void)if (!is_same (table->desc, te->desc)) {pr_debug2 ("testing event table %s: mismatched desc, %s vs %s\n" , table->name, table->desc, te->desc); -return -1 ; +return TEST_FAIL ; }if (!is_same (table->topic, te->topic)) {pr_debug2 ("testing event table %s: mismatched topic, %s vs %s\n" , table->name, table->topic, te->topic); -return -1 ; +return TEST_FAIL ; }if (!is_same (table->long_desc, te->long_desc)) {pr_debug2 ("testing event table %s: mismatched long_desc, %s vs %s\n" , table->name, table->long_desc, te->long_desc); -return -1 ; +return TEST_FAIL ; }if (!is_same (table->unit, te->unit)) {pr_debug2 ("testing event table %s: mismatched unit, %s vs %s\n" , table->name, table->unit, te->unit); -return -1 ; +return TEST_FAIL ; }if (!is_same (table->perpkg, te->perpkg)) {pr_debug2 ("testing event table %s: mismatched perpkg, %s vs %s\n" , table->name, table->perpkg, te->perpkg); -return -1 ; +return TEST_FAIL ; }if (!is_same (table->metric_expr, te->metric_expr)) {pr_debug2 ("testing event table %s: mismatched metric_expr, %s vs %s\n" , table->name, table->metric_expr, te->metric_expr); -return -1 ; +return TEST_FAIL ; }if (!is_same (table->metric_name, te->metric_name)) {pr_debug2 ("testing event table %s: mismatched metric_name, %s vs %s\n" , table->name, table->metric_name, te->metric_name); -return -1 ; +return TEST_FAIL ; }if (!is_same (table->deprecated, te->deprecated)) {pr_debug2 ("testing event table %s: mismatched deprecated, %s vs %s\n" , table->name, table->deprecated, te->deprecated); -return -1 ; +return TEST_FAIL ; }pr_debug ("testing event table %s: pass\n" , table->name);
@@ -254,17 +254,17 @@ static int test_pmu_event_table(void)if (!found) {pr_err ("testing event table: could not find event %s\n" , table->name); -return -1 ; +return TEST_FAIL ; } }if (map_events != expected_events) {pr_err ("testing event table: found %d, but expected %d\n" , map_events, expected_events); -return -1 ; +return TEST_FAIL ; } -return 0 ; +return TEST_OK ; }static struct perf_pmu_alias *find_alias (const char *test_event,struct list_head *aliases)
@@ -386,7 +386,7 @@ static int test_aliases(void)if (__test__pmu_event_aliases (pmu->name, &count)) {pr_debug ("testing PMU %s aliases: failed\n" , pmu->name); -return -1 ; +return TEST_FAIL ; }if (count ==0 )
@@ -396,7 +396,7 @@ static int test_aliases(void)pr_debug ("testing PMU %s aliases: pass\n" , pmu->name); } -return 0 ; +return TEST_OK ; }static bool is_number (const char *str)
@@ -628,7 +628,7 @@ static int metric_parse_fake(const char *str)struct expr_parse_ctx ctx;struct hashmap_entry *cur;double result; -int ret =-1 ; +int ret =TEST_FAIL ;size_t bkt;int i;
@@ -637,7 +637,7 @@ static int metric_parse_fake(const char *str)expr__ctx_init (&ctx);if (expr__find_other (str,NULL , &ctx,0 ) <0 ) {pr_err ("expr__find_other failed\n" ); -return -1 ; +return TEST_FAIL ; }/*
@@ -659,7 +659,7 @@ static int metric_parse_fake(const char *str)if (expr__parse (&result, &ctx, str,0 ))pr_err ("expr__parse failed\n" );else - ret =0 ; + ret =TEST_OK ; out:expr__ctx_clear (&ctx);
@@ -702,7 +702,7 @@ static int test_parsing_fake(void) } } -return 0 ; +return TEST_OK ; } static const struct {
tools/perf/tests/pmu.c +9 -7
@@ -145,7 +145,7 @@ int test__pmu(struct test *test __maybe_unused, int subtest __maybe_unused)int ret;if (!format) -return -EINVAL ; +return TEST_FAIL ; do { struct perf_event_attr attr;
@@ -153,15 +153,17 @@ int test__pmu(struct test *test __maybe_unused, int subtest __maybe_unused)memset (&attr,0 ,sizeof (attr)); ret =perf_pmu__format_parse (format, &formats); -if (ret) +if (ret) { + ret =TEST_FAIL ;break ; - + } ret =perf_pmu__config_terms ("perf-pmu-test" , &formats, &attr, terms, false,NULL ); -if (ret) +if (ret) { + ret =TEST_FAIL ;break ; - - ret = -EINVAL ; + } + ret =TEST_FAIL ;if (attr.config !=0xc00000000002a823 )break ;
@@ -170,7 +172,7 @@ int test__pmu(struct test *test __maybe_unused, int subtest __maybe_unused)if (attr.config2 !=0x0400000020041d07 )break ; - ret =0 ; + ret =TEST_OK ; }while (0 );perf_pmu__del_formats (&formats);
tools/perf/tests/python-use.c +1 -1
@@ -19,7 +19,7 @@ int test__python_use(struct test *test __maybe_unused, int subtest __maybe_unusereturn -1 ;pr_debug ("python usage test: \"%s\"\n" , cmd); - ret =system (cmd) ?-1 :0 ; + ret =system (cmd) ?TEST_FAIL :TEST_OK ;free (cmd);return ret; }
tools/perf/tests/sample-parsing.c +5 -5
@@ -250,7 +250,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format)struct sample_read_value values[] = {{1 ,5 }, {9 ,3 }, {2 ,7 }, {6 ,4 },};struct perf_sample sample_out;size_t i, sz, bufsz; -int err, ret =-1 ; +int err, ret =TEST_FAIL ;if (sample_type &PERF_SAMPLE_REGS_USER ) evsel.core.attr.sample_regs_user = sample_regs;
@@ -277,7 +277,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) event =malloc (bufsz);if (!event) {pr_debug ("malloc failed\n" ); -return -1 ; +return TEST_FAIL ; }memset (event,0xff , bufsz);
@@ -319,7 +319,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) goto out_free; } - ret =0 ; + ret =TEST_OK ; out_free:free (event);if (ret && read_format)
@@ -350,7 +350,7 @@ int test__sample_parsing(struct test *test __maybe_unused, int subtest __maybe_u*/ if (PERF_SAMPLE_MAX >PERF_SAMPLE_WEIGHT_STRUCT <<1 ) {pr_debug ("sample format has changed, some new PERF_SAMPLE_ bit was introduced - test needs updating\n" ); -return -1 ; +return TEST_FAIL ; }/* Test each sample format bit separately */
@@ -391,5 +391,5 @@ int test__sample_parsing(struct test *test __maybe_unused, int subtest __maybe_ureturn err; } -return 0 ; +return TEST_OK ; }
tools/perf/tests/stat.c +6 -6
@@ -44,7 +44,7 @@ static int process_stat_config_event(struct perf_tool *tool __maybe_unused,TEST_ASSERT_VAL ("wrong aggr_mode" , stat_config.aggr_mode ==AGGR_CORE );TEST_ASSERT_VAL ("wrong scale" , stat_config.scale ==1 );TEST_ASSERT_VAL ("wrong interval" , stat_config.interval ==1 ); -return 0 ; +return TEST_OK ; }int test__synthesize_stat_config (struct test *test__maybe_unused ,int subtest__maybe_unused )
@@ -58,7 +58,7 @@ int test__synthesize_stat_config(struct test *test __maybe_unused, int subtest _TEST_ASSERT_VAL ("failed to synthesize stat_config" , !perf_event__synthesize_stat_config (NULL , &stat_config, process_stat_config_event,NULL )); -return 0 ; +return TEST_OK ; } static int process_stat_event(struct perf_tool *tool __maybe_unused,
@@ -74,7 +74,7 @@ static int process_stat_event(struct perf_tool *tool __maybe_unused,TEST_ASSERT_VAL ("wrong val" , st->val ==100 );TEST_ASSERT_VAL ("wrong run" , st->ena ==200 );TEST_ASSERT_VAL ("wrong ena" , st->run ==300 ); -return 0 ; +return TEST_OK ; }int test__synthesize_stat (struct test *test__maybe_unused ,int subtest__maybe_unused )
@@ -88,7 +88,7 @@ int test__synthesize_stat(struct test *test __maybe_unused, int subtest __maybe_TEST_ASSERT_VAL ("failed to synthesize stat_config" , !perf_event__synthesize_stat (NULL ,1 ,2 ,3 , &count, process_stat_event,NULL )); -return 0 ; +return TEST_OK ; } static int process_stat_round_event(struct perf_tool *tool __maybe_unused,
@@ -100,7 +100,7 @@ static int process_stat_round_event(struct perf_tool *tool __maybe_unused,TEST_ASSERT_VAL ("wrong time" , stat_round->time ==0xdeadbeef );TEST_ASSERT_VAL ("wrong type" , stat_round->type ==PERF_STAT_ROUND_TYPE__INTERVAL ); -return 0 ; +return TEST_OK ; }int test__synthesize_stat_round (struct test *test__maybe_unused ,int subtest__maybe_unused )
@@ -109,5 +109,5 @@ int test__synthesize_stat_round(struct test *test __maybe_unused, int subtest __ !perf_event__synthesize_stat_round (NULL ,0xdeadbeef ,PERF_STAT_ROUND_TYPE__INTERVAL , process_stat_round_event, NULL)); -return 0 ; +return TEST_OK ; }
tools/perf/tests/sw-clock.c +4 -4
@@ -26,7 +26,7 @@*/ static int __test__sw_clock_freq (enum perf_sw_ids clock_id) { -int i, err =-1 ; +int i, err =TEST_FAIL ;volatile int tmp =0 ;u64 total_periods =0 ;int nr_samples =0 ;
@@ -51,7 +51,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) evlist =evlist__new ();if (evlist ==NULL ) {pr_debug ("evlist__new\n" ); -return -1 ; +return TEST_FAIL ; } evsel =evsel__new (&attr);
@@ -64,7 +64,6 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) cpus =perf_cpu_map__dummy_new (); threads =thread_map__new_by_tid (getpid ());if (!cpus || !threads) { - err = -ENOMEM ;pr_debug ("Not enough memory to create thread/cpu maps\n" ); goto out_delete_evlist; }
@@ -74,7 +73,6 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)if (evlist__open (evlist)) {const char *knob ="/proc/sys/kernel/perf_event_max_sample_rate" ; - err = -errno;pr_debug ("Couldn't open evlist: %s\nHint: check %s, using %" PRIu64" in this test.\n" ,str_error_r (errno, sbuf,sizeof (sbuf)), knob, (u64 )attr.sample_freq);
@@ -83,6 +81,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) err =evlist__mmap (evlist,128 );if (err <0 ) { + err =TEST_FAIL ;pr_debug ("failed to mmap event: %d (%s)\n" , errno,str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist;
@@ -108,6 +107,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) err =evlist__parse_sample (evlist, event, &sample);if (err <0 ) { + err =TEST_FAIL ;pr_debug ("Error during parse sample\n" ); goto out_delete_evlist; }
tools/perf/tests/switch-tracking.c +5 -4
@@ -340,7 +340,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_struct evsel *evsel, *cpu_clocks_evsel, *cycles_evsel;struct evsel *switch_evsel, *tracking_evsel;const char *comm; -int err =-1 ; +int err =TEST_FAIL ; threads =thread_map__new (-1 ,getpid (),UINT_MAX );if (!threads) {
@@ -386,7 +386,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_/* Third event */ if (!evlist__can_select_event (evlist, sched_switch)) {pr_debug ("No sched_switch\n" ); - err =0 ; + err =TEST_OK ; goto out; }
@@ -462,7 +462,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_if (evlist__open (evlist) <0 ) {pr_debug ("Not supported\n" ); - err =0 ; + err =TEST_OK ; goto out; }
@@ -553,6 +553,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_/* Check all 4 comm events were seen i.e. that evsel->tracking works */ if (!switch_tracking.comm_seen[0 ] || !switch_tracking.comm_seen[1 ] || !switch_tracking.comm_seen[2 ] || !switch_tracking.comm_seen[3 ]) { + err =TEST_FAIL ;pr_debug ("Missing comm events\n" ); goto out_err; }
@@ -585,6 +586,6 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_return err; out_err: - err =-1 ; + err =TEST_FAIL ; goto out; }
tools/perf/tests/task-exit.c +6 -6
@@ -41,7 +41,7 @@ static void workload_exec_failed_signal(int signo __maybe_unused,*/ int test__task_exit (struct test *test__maybe_unused ,int subtest__maybe_unused ) { -int err =-1 ; +int err =TEST_FAIL ;union perf_event *event;struct evsel *evsel;struct evlist *evlist;
@@ -61,7 +61,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused evlist =evlist__new_default ();if (evlist ==NULL ) {pr_debug ("evlist__new_default\n" ); -return -1 ; +return TEST_FAIL ; }/*
@@ -73,7 +73,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused cpus =perf_cpu_map__dummy_new (); threads =thread_map__new_by_tid (-1 );if (!cpus || !threads) { - err = -ENOMEM ; + err =TEST_FAIL ;pr_debug ("Not enough memory to create thread/cpu maps\n" ); goto out_delete_evlist; }
@@ -108,7 +108,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unusedif (evlist__mmap (evlist,128 ) <0 ) {pr_debug ("failed to mmap events: %d (%s)\n" , errno,str_error_r (errno, sbuf,sizeof (sbuf))); - err =-1 ; + err =TEST_FAIL ; goto out_delete_evlist; }
@@ -133,7 +133,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unusedif (retry_count++ >1000 ) {pr_debug ("Failed after retrying 1000 times\n" ); - err =-1 ; + err =TEST_FAIL ; goto out_delete_evlist; }
@@ -142,7 +142,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unusedif (nr_exit !=1 ) {pr_debug ("received %d EXIT records\n" , nr_exit); - err =-1 ; + err =TEST_FAIL ; } out_delete_evlist:
tools/perf/tests/tests.h +2 -2
@@ -8,7 +8,7 @@do { \if (!(cond)) { \pr_debug ("FAILED %s:%d %s\n" , __FILE__, __LINE__, text); \ -return -1 ; \ +return TEST_FAIL ; \ } \ }while (0 )
@@ -17,7 +17,7 @@ do { \if (val != expected) { \pr_debug ("FAILED %s:%d %s (%d != %d)\n" , \ __FILE__, __LINE__, text, val, expected); \ -return -1 ; \ +return TEST_FAIL ; \ } \ }while (0 )
tools/perf/tests/thread-map.c +4 -4
@@ -56,7 +56,7 @@ int test__thread_map(struct test *test __maybe_unused, int subtest __maybe_unuseTEST_ASSERT_VAL ("wrong refcnt" ,refcount_read (&map->refcnt) ==1 );perf_thread_map__put (map); -return 0 ; +return TEST_OK ; } static int process_event(struct perf_tool *tool __maybe_unused,
@@ -83,7 +83,7 @@ static int process_event(struct perf_tool *tool __maybe_unused,TEST_ASSERT_VAL ("wrong refcnt" ,refcount_read (&threads->refcnt) ==1 );perf_thread_map__put (threads); -return 0 ; +return TEST_OK ; }int test__thread_map_synthesize (struct test *test__maybe_unused ,int subtest__maybe_unused )
@@ -103,7 +103,7 @@ int test__thread_map_synthesize(struct test *test __maybe_unused, int subtest __ !perf_event__synthesize_thread_map2(NULL, threads, process_event, NULL));perf_thread_map__put (threads); -return 0 ; +return TEST_OK ; }int test__thread_map_remove (struct test *test__maybe_unused ,int subtest__maybe_unused )
@@ -143,5 +143,5 @@ int test__thread_map_remove(struct test *test __maybe_unused, int subtest __mayb thread_map__remove(threads, 0));perf_thread_map__put (threads); -return 0 ; +return TEST_OK ; }
tools/perf/tests/thread-maps-share.c +1 -1
@@ -94,5 +94,5 @@ int test__thread_maps_share(struct test *test __maybe_unused, int subtest __maybthread__put (other);machines__exit (&machines); -return 0 ; +return TEST_OK ; }
tools/perf/tests/time-utils-test.c +1 -1
@@ -247,5 +247,5 @@ int test__time_utils(struct test *t __maybe_unused, int subtest __maybe_unused)pr_debug ("\n" ); -return pass ?0 :TEST_FAIL ; +return pass ?TEST_OK :TEST_FAIL ; }
tools/perf/tests/topology.c +1 -1
@@ -169,7 +169,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) }perf_session__delete (session); -return 0 ; +return TEST_OK ; }int test__session_topology (struct test *test__maybe_unused ,int subtest__maybe_unused )
tools/perf/tests/vmlinux-kallsyms.c +3 -3
@@ -16,7 +16,7 @@int test__vmlinux_matches_kallsyms (struct test *test__maybe_unused ,int subtest__maybe_unused ) { -int err =-1 ; +int err =TEST_FAIL ;struct rb_node *nd;struct symbol *sym;struct map *kallsyms_map, *vmlinux_map, *map;
@@ -101,7 +101,7 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest goto out; } - err =0 ; + err =TEST_OK ;/* * Step 7: *
@@ -174,7 +174,7 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest mem_start, sym->name); } - err =-1 ; + err =TEST_FAIL ; }if (verbose <=0 )
tools/perf/tests/wp.c +5 -5
@@ -78,7 +78,7 @@ static int wp_ro_test(void)WP_TEST_ASSERT_VAL (fd,"RO watchpoint" ,1 );close (fd); -return 0 ; +return TEST_OK ; }static int wp_wo_test (void )
@@ -88,7 +88,7 @@ static int wp_wo_test(void) fd =__event (HW_BREAKPOINT_W , (void *)&data1,sizeof (data1));if (fd <0 ) -return -1 ; +return TEST_FAIL ; tmp = data1;WP_TEST_ASSERT_VAL (fd,"WO watchpoint" ,0 );
@@ -97,7 +97,7 @@ static int wp_wo_test(void)WP_TEST_ASSERT_VAL (fd,"WO watchpoint" ,1 );close (fd); -return 0 ; +return TEST_OK ; }static int wp_rw_test (void )
@@ -117,7 +117,7 @@ static int wp_rw_test(void)WP_TEST_ASSERT_VAL (fd,"RW watchpoint" ,2 );close (fd); -return 0 ; +return TEST_OK ; }static int wp_modify_test (void )
@@ -162,7 +162,7 @@ static int wp_modify_test(void)WP_TEST_ASSERT_VAL (fd,"Modify watchpoint" ,2 );close (fd); -return 0 ; +return TEST_OK ; }static bool wp_ro_supported (void )
Signature · 1 line
2.32.0.432.gabb21c7263-goog
Re: [PATCH 3/3] perf test: Be more consistent in use of TEST_*
Hi Ian,
Quoted 57 lines · Ian Rogers
The
TEST_OK,TEST_FAILandTEST_SKIPenum values are used inconsistently. Try to reduce this by swapping constants for enum values to try to be more intention revealing.Signed-off-by Ian Rogers <[email protected]>---
tools/perf/arch/x86/tests/rdpmc.c | 8 +- tools/perf/tests/attr.c | 2 +- tools/perf/tests/bitmap.c | 2 +- tools/perf/tests/bp_account.c | 4 +- tools/perf/tests/bp_signal.c | 51 +++++++-- tools/perf/tests/code-reading.c | 12 +- tools/perf/tests/cpumap.c | 10 +- tools/perf/tests/dso-data.c | 8 +- tools/perf/tests/dwarf-unwind.c | 14 ++- tools/perf/tests/event-times.c | 2 +- tools/perf/tests/evsel-roundtrip-name.c | 14 +-- tools/perf/tests/evsel-tp-sched.c | 28 ++--- tools/perf/tests/expr.c | 4 +- tools/perf/tests/fdarray.c | 4 +- tools/perf/tests/genelf.c | 2 +- tools/perf/tests/hists_cumulate.c | 2 +- tools/perf/tests/hists_filter.c | 12 +- tools/perf/tests/hists_link.c | 33 +++--- tools/perf/tests/keep-tracking.c | 4 +- tools/perf/tests/kmod-path.c | 6 +- tools/perf/tests/mem.c | 4 +- tools/perf/tests/mem2node.c | 2 +- tools/perf/tests/mmap-basic.c | 10 +- tools/perf/tests/mmap-thread-lookup.c | 2 +- tools/perf/tests/openat-syscall-all-cpus.c | 4 +-tools/perf/tests/openat-syscall-tp-fields.c| 4 +- tools/perf/tests/openat-syscall.c | 6 +- tools/perf/tests/parse-events.c | 118 ++++++++++---------- tools/perf/tests/parse-metric.c | 16 +-- tools/perf/tests/parse-no-sample-id-all.c | 4 +- tools/perf/tests/perf-hooks.c | 2 +- tools/perf/tests/perf-record.c | 2 +- tools/perf/tests/perf-time-to-tsc.c | 4 +- tools/perf/tests/pfm.c | 4 +- tools/perf/tests/pmu-events.c | 36 +++--- tools/perf/tests/pmu.c | 16 +-- tools/perf/tests/python-use.c | 2 +- tools/perf/tests/sample-parsing.c | 10 +- tools/perf/tests/stat.c | 12 +- tools/perf/tests/sw-clock.c | 8 +- tools/perf/tests/switch-tracking.c | 9 +- tools/perf/tests/task-exit.c | 12 +- tools/perf/tests/tests.h | 4 +- tools/perf/tests/thread-map.c | 8 +- tools/perf/tests/thread-maps-share.c | 2 +- tools/perf/tests/time-utils-test.c | 2 +- tools/perf/tests/topology.c | 2 +- tools/perf/tests/vmlinux-kallsyms.c | 6 +- tools/perf/tests/wp.c | 10 +-49 files changed, 292 insertions(+), 251 deletions(-)
<SNIP>
Quoted 24 lines
tools/perf/tests/code-reading.c +0
-0@@ -725,20 +725,20 @@ int test__code_reading(struct test *test __maybe_unused,int subtest
__maybe_unu
switch (ret) {
caseTEST_CODE_READING_OK:
- return 0;
+ returnTEST_OK;
caseTEST_CODE_READING_NO_VMLINUX:
pr_debug("no vmlinux\n");
- return 0;
+ returnTEST_SKIP;
caseTEST_CODE_READING_NO_KCORE:
pr_debug("no kcore\n");
- return 0;
+ returnTEST_SKIP;
caseTEST_CODE_READING_NO_ACCESS:
pr_debug("no access\n");
- return 0;
+ returnTEST_SKIP;
caseTEST_CODE_READING_NO_KERNEL_OBJ:
Quoted 8 lines
pr_debug("no kernel obj\n");
- return 0;
+ returnTEST_SKIP;
default:
- return -1;
+ returnTEST_FAIL;
};
}
I think it's better to separate changes that do not change the current behaviour from these changes (0 -> TEST_SKIP) into different patches.
Riccardo
Quoted 58 lines
tools/perf/tests/cpumap.c +0
-0@@ -42,7 +42,7 @@ static int process_event_mask(struct perf_tool *tool __maybe_unused, }
perf_cpu_map__put(map);
- return 0;
+ returnTEST_OK;
}
static int process_event_cpus(structperf_tool*tool__maybe_unused,tools/perf/tests/cpumap.c +1
-1@@ -71,7 +71,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused, TEST_ASSERT_VAL("wrong cpu", map->map[1] == 256); TEST_ASSERT_VAL("wrong refcnt", refcount_read(&map->refcnt) == 1); perf_cpu_map__put(map); - return 0; + return TEST_OK; }
tools/perf/tests/cpumap.c +0
-0@@ -94,7 +94,7 @@ int test__cpu_map_synthesize(struct test *test
__maybe_unused, int subtest__may!perf_event__synthesize_cpu_map(NULL, cpus,process_event_cpus, NULL));
perf_cpu_map__put(cpus);
- return 0;
+ returnTEST_OK;
}
static intcpu_map_print(const char *str)tools/perf/tests/cpumap.c +0
-0@@ -120,7 +120,7 @@ int test__cpu_map_print(struct test *test __maybe_unused,int subtest
__maybe_un
TEST_ASSERT_VAL("failed to convert map",cpu_map_print("1,3-6,8- 10,24,35-37"));
TEST_ASSERT_VAL("failed to convert map",cpu_map_print("1,3-6,8- 10,24,35-37"));
TEST_ASSERT_VAL("failed to convert map",cpu_map_print("1-10,12-20,22- 30,32-40"));
- return 0;
+ returnTEST_OK;
}
inttest__cpu_map_merge(struct test *test __maybe_unused, int subtest __maybe_unused)tools/perf/tests/cpumap.c +0
-0@@ -135,5 +135,5 @@ int test__cpu_map_merge(struct test *test __maybe_unused,int subtest
__maybe_un
TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "1- 2,4-5,7"));
perf_cpu_map__put(b);
perf_cpu_map__put(c);
- return 0;
+ returnTEST_OK;
}
<SNIP>
Ian Rogers
reviewerRe: [PATCH 3/3] perf test: Be more consistent in use of TEST_*
Quoted 90 lines · Riccardo Mancini
Hi Ian,
Quoted 57 lines · Ian Rogers
The
TEST_OK,TEST_FAILandTEST_SKIPenum values are used inconsistently. Try to reduce this by swapping constants for enum values to try to be more intention revealing.Signed-off-by Ian Rogers <[email protected]>--- tools/perf/arch/x86/tests/rdpmc.c | 8 +- tools/perf/tests/attr.c | 2 +- tools/perf/tests/bitmap.c | 2 +- tools/perf/tests/bp_account.c | 4 +- tools/perf/tests/bp_signal.c | 51 +++++++-- tools/perf/tests/code-reading.c | 12 +- tools/perf/tests/cpumap.c | 10 +- tools/perf/tests/dso-data.c | 8 +- tools/perf/tests/dwarf-unwind.c | 14 ++- tools/perf/tests/event-times.c | 2 +- tools/perf/tests/evsel-roundtrip-name.c | 14 +-- tools/perf/tests/evsel-tp-sched.c | 28 ++--- tools/perf/tests/expr.c | 4 +- tools/perf/tests/fdarray.c | 4 +- tools/perf/tests/genelf.c | 2 +- tools/perf/tests/hists_cumulate.c | 2 +- tools/perf/tests/hists_filter.c | 12 +- tools/perf/tests/hists_link.c | 33 +++--- tools/perf/tests/keep-tracking.c | 4 +- tools/perf/tests/kmod-path.c | 6 +- tools/perf/tests/mem.c | 4 +- tools/perf/tests/mem2node.c | 2 +- tools/perf/tests/mmap-basic.c | 10 +- tools/perf/tests/mmap-thread-lookup.c | 2 +- tools/perf/tests/openat-syscall-all-cpus.c | 4 +- tools/perf/tests/openat-syscall-tp-fields.c | 4 +- tools/perf/tests/openat-syscall.c | 6 +- tools/perf/tests/parse-events.c | 118 ++++++++++---------- tools/perf/tests/parse-metric.c | 16 +-- tools/perf/tests/parse-no-sample-id-all.c | 4 +- tools/perf/tests/perf-hooks.c | 2 +- tools/perf/tests/perf-record.c | 2 +- tools/perf/tests/perf-time-to-tsc.c | 4 +- tools/perf/tests/pfm.c | 4 +- tools/perf/tests/pmu-events.c | 36 +++--- tools/perf/tests/pmu.c | 16 +-- tools/perf/tests/python-use.c | 2 +- tools/perf/tests/sample-parsing.c | 10 +- tools/perf/tests/stat.c | 12 +- tools/perf/tests/sw-clock.c | 8 +- tools/perf/tests/switch-tracking.c | 9 +- tools/perf/tests/task-exit.c | 12 +- tools/perf/tests/tests.h | 4 +- tools/perf/tests/thread-map.c | 8 +- tools/perf/tests/thread-maps-share.c | 2 +- tools/perf/tests/time-utils-test.c | 2 +- tools/perf/tests/topology.c | 2 +- tools/perf/tests/vmlinux-kallsyms.c | 6 +- tools/perf/tests/wp.c | 10 +- 49 files changed, 292 insertions(+), 251 deletions(-)<SNIP>
Quoted 28 lines
tools/perf/tests/code-reading.c +0
-0@@ -725,20 +725,20 @@ int test__code_reading(struct test *test __maybe_unused,int subtest
__maybe_unuswitch (ret) { case TEST_CODE_READING_OK:tools/perf/tests/code-reading.c +5
-5-return 0 ; +return TEST_OK ;case TEST_CODE_READING_NO_VMLINUX :pr_debug ("no vmlinux\n" ); -return 0 ; +return TEST_SKIP ;case TEST_CODE_READING_NO_KCORE :pr_debug ("no kcore\n" ); -return 0 ; +return TEST_SKIP ;case TEST_CODE_READING_NO_ACCESS :pr_debug ("no access\n" ); -return 0 ; +return TEST_SKIP ;case TEST_CODE_READING_NO_KERNEL_OBJ :pr_debug ("no kernel obj\n" ); -return 0 ; +return TEST_SKIP ;default :
Quoted 8 lines
tools/perf/tests/code-reading.c int test__code_reading(struct test *test __maybe_unused, int subtest __maybe_unu · line 744
Quoted 4 lines
tools/perf/tests/code-reading.c +1
-1-return -1 ; +return TEST_FAIL ; }; }I think it's better to separate changes that do not change the current behaviour from these changes (0 ->
TEST_SKIP) into different patches.
Ack. This is the only case of this I see as TEST_OK would contradict the debug output. There are also cases where I've swapped things like -ENOMEM or -EINVAL for TEST_FAIL for things that generally won't happen like malloc failures - the test calling function doesn't handle -ENOMEM. Separating all of these out into CLs is work I'd prefer to avoid, but I agree it makes just eye-balling this as a substitution CL hard.
Thanks,
Ian
Quoted 62 lines
Riccardo
Quoted 58 lines
tools/perf/tests/cpumap.c +1
-1@@ -42,7 +42,7 @@ static int process_event_mask(struct perf_tool *tool __maybe_unused, }perf_cpu_map__put (map); -return 0 ; +return TEST_OK ; }static int process_event_cpus(struct
perf_tool*tool__maybe_unused,tools/perf/tests/cpumap.c +1
-1@@ -71,7 +71,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,TEST_ASSERT_VAL ("wrong cpu" , map->map[1 ] ==256 );TEST_ASSERT_VAL ("wrong refcnt" ,refcount_read (&map->refcnt) ==1 );perf_cpu_map__put (map); -return 0 ; +return TEST_OK ; }@@ -94,7 +94,7 @@ int test__cpu_map_synthesize(struct test *test
__maybe_unused, int subtest__may
!perf_event__synthesize_cpu_map(NULL, cpus,process_event_cpus, NULL));perf_cpu_map__put(cpus);tools/perf/tests/cpumap.c +1
-1-return 0 ; +return TEST_OK ; }static int cpu_map_print (const char *str)@@ -120,7 +120,7 @@ int test__cpu_map_print(struct test *test __maybe_unused,int subtest
__maybe_unTEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,3-6,8- 10,24,35-37")); TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,3-6,8- 10,24,35-37")); TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1-10,12-20,22-30,32-40"));
tools/perf/tests/cpumap.c +1
-1-return 0 ; +return TEST_OK ; } int test__cpu_map_merge(struct test *test __maybe_unused, int subtest
__maybe_unused)tools/perf/tests/cpumap.c +0
-0@@ -135,5 +135,5 @@ int test__cpu_map_merge(struct test *test __maybe_unused,int subtest
__maybe_un
TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "1-2,4-5,7")); perf_cpu_map__put(b); perf_cpu_map__put(c);tools/perf/tests/cpumap.c +1
-1-return 0 ; +return TEST_OK ; }<SNIP>