perf test tsc: Fix error message report when not supported.
PATCH v2 1/1 perf test tsc: Fix error message report when not supported.
By default perf test tsc does not return the error message when child process detected kernel does not support. Instead, child process print error message to stderr, unfortunately the stderr is redirected to /dev/null when verbose <= 0.
This patch did three things:
- returns TEST_SKIP to parent process instead of TEST_OK when perf_read_tsc_conversion() is not supported.
- add a new subtest of testing if TSC is supported on current architecture by moving exist code to a separate function.
- extended test suite definition to contain above two subtests.
Changes since v1 (thanks for the feedback from Adrian Hunter):
- rebase commit to current source.
--- tools/perf/tests/perf-time-to-tsc.c | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-)
tools/perf/tests/perf-time-to-tsc.c +27 -9
@@ -47,6 +47,17 @@ } \ } +static int test__tsc_is_supported (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +if (!TSC_IS_SUPPORTED ) { +pr_debug ("Test not supported on this architecture" ); +return TEST_SKIP ; + } + +return TEST_OK ; +} +/** * test__perf_time_to_tsc - test converting perf time to TSC. *
@@ -70,7 +81,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sustruct 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;
@@ -79,10 +90,6 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suu64 test_time, comm1_time =0 , comm2_time =0 ;struct mmap *md; -if (!TSC_IS_SUPPORTED ) { -pr_debug ("Test not supported on this architecture" ); -return TEST_SKIP ; - } threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads);
@@ -124,8 +131,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su ret =perf_read_tsc_conversion (pc, &tc);if (ret) {if (ret == -EOPNOTSUPP ) { -fprintf (stderr," (not supported)" ); -return 0 ; +pr_debug ("perf_read_tsc_conversion is not supported in current kernel" ); + err =TEST_SKIP ; } goto out_err; }
@@ -191,7 +198,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su test_tsc >= comm2_tsc) goto out_err; - err =0 ; + err =TEST_OK ; out_err:evlist__delete (evlist);
@@ -200,4 +207,15 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sureturn err; } -DEFINE_SUITE ("Convert perf time to TSC" , perf_time_to_tsc); +static struct test_case time_to_tsc_tests[] = { +TEST_CASE_REASON ("TSC support" , tsc_is_supported, +"This architecture does not support" ), +TEST_CASE_REASON ("Perf time to TSC" , perf_time_to_tsc, +"perf_read_tsc_conversion is not supported" ), + { .name =NULL , } +}; + +struct test_suite suite__perf_time_to_tsc = { + .desc ="Convert perf time to TSC" , + .test_cases = time_to_tsc_tests, +};
Signature · 1 line
2.27.0
Adrian Hunter
reviewerQuoted 25 lines · Chengdong Li
By default
perf test tscdoes not return the error message when child process detected kernel does not support. Instead, child process print error message to stderr, unfortunately the stderr is redirected to/dev/nullwhen verbose <= 0.This patch did three things:
- returnsTEST_SKIPto parent process instead ofTEST_OKwhenperf_read_tsc_conversion()is not supported.
- add a new subtest of testing if TSC is supported on current architecture by moving exist code to a separate function.
- extended test suite definition to contain above two subtests.Changes since v1 (thanks for the feedback from Adrian Hunter):
- rebase commit to current source.Signed-off-by Chengdong Li <[email protected]>--- tools/perf/tests/perf-time-to-tsc.c | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-)tools/perf/tests/perf-time-to-tsc.c +0
-0
tools/perf/tests/perf-time-to-tsc.c line 54
Quoted 8 lines
tools/perf/tests/perf-time-to-tsc.c +5
-0@@ -47,6 +47,17 @@ } \ } +static int test__tsc_is_supported (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +if (!TSC_IS_SUPPORTED ) { +pr_debug ("Test not supported on this architecture" );
Message better ending with "\n" I think
Quoted 50 lines
tools/perf/tests/perf-time-to-tsc.c +10
-8+return TEST_SKIP ; + } + +return TEST_OK ; +} +/** * test__perf_time_to_tsc - test converting perf time to TSC. * @@ -70,7 +81,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sustruct 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;@@ -79,10 +90,6 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suu64 test_time, comm1_time =0 , comm2_time =0 ;struct mmap *md; -if (!TSC_IS_SUPPORTED ) { -pr_debug ("Test not supported on this architecture" ); -return TEST_SKIP ; - } threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads);@@ -124,8 +131,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su ret =perf_read_tsc_conversion (pc, &tc);if (ret) {if (ret == -EOPNOTSUPP ) { -fprintf (stderr," (not supported)" ); -return 0 ; +pr_debug ("perf_read_tsc_conversion is not supported in current kernel" ); + err =TEST_SKIP ; } goto out_err; }@@ -191,7 +198,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su test_tsc >= comm2_tsc) goto out_err; - err =0 ; + err =TEST_OK ; out_err:evlist__delete (evlist);
tools/perf/tests/perf-time-to-tsc.c static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su · line 212
Quoted 7 lines
tools/perf/tests/perf-time-to-tsc.c +3
-1@@ -200,4 +207,15 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sureturn err; } -DEFINE_SUITE ("Convert perf time to TSC" , perf_time_to_tsc); +static struct test_case time_to_tsc_tests[] = { +TEST_CASE_REASON ("TSC support" , tsc_is_supported, +"This architecture does not support" ),
The 2nd test case runs anyway, so I am not sure another test case is needed?
Quoted 9 lines
tools/perf/tests/perf-time-to-tsc.c +9
-0+TEST_CASE_REASON ("Perf time to TSC" , perf_time_to_tsc, +"perf_read_tsc_conversion is not supported" ), + { .name = NULL, } +}; + +struct test_suite suite__perf_time_to_tsc = { + .desc ="Convert perf time to TSC" , + .test_cases = time_to_tsc_tests, +};
Quoted 30 lines · Adrian Hunter
Quoted 28 lines · Chengdong Li
By default
perf test tscdoes not return the error message when child process detected kernel does not support. Instead, child process print error message to stderr, unfortunately the stderr is redirected to/dev/nullwhen verbose <= 0.This patch did three things:
- returnsTEST_SKIPto parent process instead ofTEST_OKwhenperf_read_tsc_conversion()is not supported.
- add a new subtest of testing if TSC is supported on current architecture by moving exist code to a separate function.
- extended test suite definition to contain above two subtests.Changes since v1 (thanks for the feedback from Adrian Hunter):
- rebase commit to current source.Signed-off-by Chengdong Li <[email protected]>--- tools/perf/tests/perf-time-to-tsc.c | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-)tools/perf/tests/perf-time-to-tsc.c +0
-0@@ -47,6 +47,17 @@ } \ }
Quoted 7 lines
tools/perf/tests/perf-time-to-tsc.c line 54
Quoted 5 lines
tools/perf/tests/perf-time-to-tsc.c +5
-0+static int test__tsc_is_supported (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +if (!TSC_IS_SUPPORTED ) { +pr_debug ("Test not supported on this architecture" );Message better ending with "\n" I think
OK, I will fix it.
Quoted 54 lines
Quoted 54 lines
tools/perf/tests/perf-time-to-tsc.c +10
-8+return TEST_SKIP ; + } + +return TEST_OK ; +} +/** * test__perf_time_to_tsc - test converting perf time to TSC. * @@ -70,7 +81,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sustruct 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;@@ -79,10 +90,6 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suu64 test_time, comm1_time =0 , comm2_time =0 ;struct mmap *md; -if (!TSC_IS_SUPPORTED ) { -pr_debug ("Test not supported on this architecture" ); -return TEST_SKIP ; - } threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads);@@ -124,8 +131,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su ret =perf_read_tsc_conversion (pc, &tc);if (ret) {if (ret == -EOPNOTSUPP ) { -fprintf (stderr," (not supported)" ); -return 0 ; +pr_debug ("perf_read_tsc_conversion is not supported in current kernel" ); + err =TEST_SKIP ; } goto out_err; }@@ -191,7 +198,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su test_tsc >= comm2_tsc) goto out_err; - err =0 ; + err =TEST_OK ; out_err:evlist__delete (evlist);@@ -200,4 +207,15 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sureturn err; }
Quoted 7 lines
tools/perf/tests/perf-time-to-tsc.c static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su · line 212
Quoted 4 lines
tools/perf/tests/perf-time-to-tsc.c +3
-1-DEFINE_SUITE ("Convert perf time to TSC" , perf_time_to_tsc); +static struct test_case time_to_tsc_tests[] = { +TEST_CASE_REASON ("TSC support" , tsc_is_supported, +"This architecture does not support" ),The 2nd test case runs anyway, so I am not sure another test case is needed?
Yes. But, I think there are two reasons to add two subtests: 1). Original TSC support test is embedded in test__perf_time_to_tsc(), and returns TEST_SKIP
if current architecture doesn't support it. Thus there are two places that return TEST_SKIP in test__perf_time_to_tsc() if we don't move TSC support
to another subtest. 2). Current test_suite and test_case structs don't support printing skip_reason if there is no subtest. To print skip reason we need more than 1 subtests.
Quoted 11 lines
Quoted 10 lines
tools/perf/tests/perf-time-to-tsc.c +9
-0+TEST_CASE_REASON ("Perf time to TSC" , perf_time_to_tsc, +"perf_read_tsc_conversion is not supported" ), + { .name = NULL, } +}; + +struct test_suite suite__perf_time_to_tsc = { + .desc ="Convert perf time to TSC" , + .test_cases = time_to_tsc_tests, +};
Adrian Hunter
reviewerQuoted 101 lines · Bryton Lee
Quoted 30 lines · Adrian Hunter
Quoted 28 lines · Chengdong Li
By default
perf test tscdoes not return the error message when child process detected kernel does not support. Instead, child process print error message to stderr, unfortunately the stderr is redirected to/dev/nullwhen verbose <= 0.This patch did three things:
- returnsTEST_SKIPto parent process instead ofTEST_OKwhenperf_read_tsc_conversion()is not supported.
- add a new subtest of testing if TSC is supported on current architecture by moving exist code to a separate function.
- extended test suite definition to contain above two subtests.Changes since v1 (thanks for the feedback from Adrian Hunter):
- rebase commit to current source.Signed-off-by Chengdong Li <[email protected]>--- tools/perf/tests/perf-time-to-tsc.c | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-)tools/perf/tests/perf-time-to-tsc.c +0
-0@@ -47,6 +47,17 @@ } \ }Quoted 7 lines
tools/perf/tests/perf-time-to-tsc.c line 54
Quoted 5 lines
tools/perf/tests/perf-time-to-tsc.c +5
-0+static int test__tsc_is_supported (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +if (!TSC_IS_SUPPORTED ) { +pr_debug ("Test not supported on this architecture" );Message better ending with "\n" I think
OK, I will fix it.
Quoted 54 lines
Quoted 54 lines
tools/perf/tests/perf-time-to-tsc.c +10
-8+return TEST_SKIP ; + } + +return TEST_OK ; +} +/** * test__perf_time_to_tsc - test converting perf time to TSC. * @@ -70,7 +81,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sustruct 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;@@ -79,10 +90,6 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suu64 test_time, comm1_time =0 , comm2_time =0 ;struct mmap *md; -if (!TSC_IS_SUPPORTED ) { -pr_debug ("Test not supported on this architecture" ); -return TEST_SKIP ; - } threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads);@@ -124,8 +131,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su ret =perf_read_tsc_conversion (pc, &tc);if (ret) {if (ret == -EOPNOTSUPP ) { -fprintf (stderr," (not supported)" ); -return 0 ; +pr_debug ("perf_read_tsc_conversion is not supported in current kernel" ); + err =TEST_SKIP ; } goto out_err; }@@ -191,7 +198,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su test_tsc >= comm2_tsc) goto out_err; - err =0 ; + err =TEST_OK ; out_err:evlist__delete (evlist);@@ -200,4 +207,15 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sureturn err; }Quoted 7 lines
tools/perf/tests/perf-time-to-tsc.c static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su · line 212
Quoted 4 lines
tools/perf/tests/perf-time-to-tsc.c +3
-1-DEFINE_SUITE ("Convert perf time to TSC" , perf_time_to_tsc); +static struct test_case time_to_tsc_tests[] = { +TEST_CASE_REASON ("TSC support" , tsc_is_supported, +"This architecture does not support" ),The 2nd test case runs anyway, so I am not sure another test case is needed?
Quoted 9 lines
Yes. But, I think there are two reasons to add two subtests: 1). Original TSC support test is embedded in
test__perf_time_to_tsc(), and returnsTEST_SKIP
if current architecture doesn't support it. Thus there are two places that returnTEST_SKIPintest__perf_time_to_tsc()if we don't move TSC support
to another subtest. 2). Currenttest_suiteandtest_casestructs don't support printingskip_reasonif there is no subtest. To print skip reason we need more than 1 subtests.
Ok, can that explanation be added to the commit message
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
tools/perf/tests/perf-time-to-tsc.c +9
-0+TEST_CASE_REASON ("Perf time to TSC" , perf_time_to_tsc, +"perf_read_tsc_conversion is not supported" ), + { .name = NULL, } +}; + +struct test_suite suite__perf_time_to_tsc = { + .desc ="Convert perf time to TSC" , + .test_cases = time_to_tsc_tests, +};
PATCH v3 1/1 perf test tsc: Fix error message report when not supported.
By default perf test tsc does not return the error message when the child process detected kernel does not support. Instead, the child process print error message to stderr, unfortunately the stderr is redirected to /dev/null when verbose <= 0.
This patch did three things:
- returns TEST_SKIP to the parent process instead of TEST_OK when perf_read_tsc_conversion() is not supported.
- add a new subtest of testing if TSC is supported on current architecture by moving exist code to a separate function. It avoids two places in test__perf_time_to_tsc() that return TEST_SKIP by doing this.
- extended test suite definition to contain above two subtests. Current test_suite and test_case structs do not support printing skip reason when the number of subtest less than 1. To print skip reason, it is necessary to extend current test suite definition.
Changes since v2:
- refine error message format.
- refine commit log message according to Adrian's review comments.
Changes since v1 (thanks for the feedback from Adrian Hunter):
- rebase commit to current source.
--- tools/perf/tests/perf-time-to-tsc.c | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-)
tools/perf/tests/perf-time-to-tsc.c +27 -9
@@ -47,6 +47,17 @@ } \ } +static int test__tsc_is_supported (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +if (!TSC_IS_SUPPORTED ) { +pr_debug ("Test not supported on this architecture\n" ); +return TEST_SKIP ; + } + +return TEST_OK ; +} +/** * test__perf_time_to_tsc - test converting perf time to TSC. *
@@ -70,7 +81,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sustruct 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;
@@ -79,10 +90,6 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suu64 test_time, comm1_time =0 , comm2_time =0 ;struct mmap *md; -if (!TSC_IS_SUPPORTED ) { -pr_debug ("Test not supported on this architecture" ); -return TEST_SKIP ; - } threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads);
@@ -124,8 +131,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su ret =perf_read_tsc_conversion (pc, &tc);if (ret) {if (ret == -EOPNOTSUPP ) { -fprintf (stderr," (not supported)" ); -return 0 ; +pr_debug ("perf_read_tsc_conversion is not supported in current kernel\n" ); + err =TEST_SKIP ; } goto out_err; }
@@ -191,7 +198,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su test_tsc >= comm2_tsc) goto out_err; - err =0 ; + err =TEST_OK ; out_err:evlist__delete (evlist);
@@ -200,4 +207,15 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sureturn err; } -DEFINE_SUITE ("Convert perf time to TSC" , perf_time_to_tsc); +static struct test_case time_to_tsc_tests[] = { +TEST_CASE_REASON ("TSC support" , tsc_is_supported, +"This architecture does not support" ), +TEST_CASE_REASON ("Perf time to TSC" , perf_time_to_tsc, +"perf_read_tsc_conversion is not supported" ), + { .name =NULL , } +}; + +struct test_suite suite__perf_time_to_tsc = { + .desc ="Convert perf time to TSC" , + .test_cases = time_to_tsc_tests, +};
Signature · 1 line
2.27.0
Quoted 17 lines · Chengdong Li
By default
perf test tscdoes not return the error message when the child process detected kernel does not support. Instead, the child process print error message to stderr, unfortunately the stderr is redirected to/dev/nullwhen verbose <= 0.This patch did three things:
- returnsTEST_SKIPto the parent process instead ofTEST_OKwhenperf_read_tsc_conversion()is not supported.
- add a new subtest of testing if TSC is supported on current architecture by moving exist code to a separate function. It avoids two places intest__perf_time_to_tsc()that returnTEST_SKIPby doing this.
- extended test suite definition to contain above two subtests. Currenttest_suiteandtest_casestructs do not support printing skip reason when the number of subtest less than 1. To print skip reason, it is necessary to extend current test suite definition.
Quoted 8 lines
Changes since v2:
- refine error message format.
- refine commit log message according to Adrian's review comments.Changes since v1 (thanks for the feedback from Adrian Hunter):
- rebase commit to current source.Signed-off-by Chengdong Li <[email protected]>
It is better to try to consistently use the same email address for the same person for git logs, unless you have a sensible reason not to.
So in this case it looks like you should use the same email address for the "From:" and "Signed-off-by:". Note you can optionally put the "From:" line before the commit message e.g.
From: Chengdong Li <[email protected]>
By default perf test tsc does not return the error message
...
Otherwise you can add:
Quoted 83 lines
--- tools/perf/tests/perf-time-to-tsc.c | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-)tools/perf/tests/perf-time-to-tsc.c +27
-9@@ -47,6 +47,17 @@ } \ } +static int test__tsc_is_supported (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +if (!TSC_IS_SUPPORTED ) { +pr_debug ("Test not supported on this architecture\n" ); +return TEST_SKIP ; + } + +return TEST_OK ; +} +/** * test__perf_time_to_tsc - test converting perf time to TSC. * @@ -70,7 +81,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sustruct 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;@@ -79,10 +90,6 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suu64 test_time, comm1_time =0 , comm2_time =0 ;struct mmap *md; -if (!TSC_IS_SUPPORTED ) { -pr_debug ("Test not supported on this architecture" ); -return TEST_SKIP ; - } threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads);@@ -124,8 +131,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su ret =perf_read_tsc_conversion (pc, &tc);if (ret) {if (ret == -EOPNOTSUPP ) { -fprintf (stderr," (not supported)" ); -return 0 ; +pr_debug ("perf_read_tsc_conversion is not supported in current kernel\n" ); + err =TEST_SKIP ; } goto out_err; }@@ -191,7 +198,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su test_tsc >= comm2_tsc) goto out_err; - err =0 ; + err =TEST_OK ; out_err:evlist__delete (evlist);@@ -200,4 +207,15 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sureturn err; } -DEFINE_SUITE ("Convert perf time to TSC" , perf_time_to_tsc); +static struct test_case time_to_tsc_tests[] = { +TEST_CASE_REASON ("TSC support" , tsc_is_supported, +"This architecture does not support" ), +TEST_CASE_REASON ("Perf time to TSC" , perf_time_to_tsc, +"perf_read_tsc_conversion is not supported" ), + { .name =NULL , } +}; + +struct test_suite suite__perf_time_to_tsc = { + .desc ="Convert perf time to TSC" , + .test_cases = time_to_tsc_tests, +};
Quoted 23 lines · Adrian Hunter
Quoted 21 lines · Chengdong Li
By default
perf test tscdoes not return the error message when the child process detected kernel does not support. Instead, the child process print error message to stderr, unfortunately the stderr is redirected to/dev/nullwhen verbose <= 0.This patch did three things:
- returnsTEST_SKIPto the parent process instead ofTEST_OKwhenperf_read_tsc_conversion()is not supported.
- add a new subtest of testing if TSC is supported on current architecture by moving exist code to a separate function. It avoids two places intest__perf_time_to_tsc()that returnTEST_SKIPby doing this.
- extended test suite definition to contain above two subtests. Currenttest_suiteandtest_casestructs do not support printing skip reason when the number of subtest less than 1. To print skip reason, it is necessary to extend current test suite definition.Changes since v2:
- refine error message format.
- refine commit log message according to Adrian's review comments.
Quoted 9 lines
Quoted 4 lines
Changes since v1 (thanks for the feedback from Adrian Hunter):
- rebase commit to current source.Signed-off-by Chengdong Li <[email protected]>It is better to try to consistently use the same email address for the same person for git logs, unless you have a sensible reason not to.
Sorry for the inconvenience. I can not use my company email account to send patches via git send-email due to lack of email protocol support in our email system.
Quoted 8 lines
So in this case it looks like you should use the same email address for the "From:" and "Signed-off-by:". Note you can optionally put the "From:" line before the commit message e.g.
From: Chengdong Li <[email protected]>
By default
perf test tscdoes not return the error message
...
Thanks for your guidance, I will resend this patch again.
Quoted 90 lines
Otherwise you can add:
Reviewed-by Adrian Hunter <[email protected]>Quoted 83 lines
--- tools/perf/tests/perf-time-to-tsc.c | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-)tools/perf/tests/perf-time-to-tsc.c +27
-9@@ -47,6 +47,17 @@ } \ } +static int test__tsc_is_supported (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +if (!TSC_IS_SUPPORTED ) { +pr_debug ("Test not supported on this architecture\n" ); +return TEST_SKIP ; + } + +return TEST_OK ; +} +/** * test__perf_time_to_tsc - test converting perf time to TSC. * @@ -70,7 +81,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sustruct 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;@@ -79,10 +90,6 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suu64 test_time, comm1_time =0 , comm2_time =0 ;struct mmap *md; -if (!TSC_IS_SUPPORTED ) { -pr_debug ("Test not supported on this architecture" ); -return TEST_SKIP ; - } threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads);@@ -124,8 +131,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su ret =perf_read_tsc_conversion (pc, &tc);if (ret) {if (ret == -EOPNOTSUPP ) { -fprintf (stderr," (not supported)" ); -return 0 ; +pr_debug ("perf_read_tsc_conversion is not supported in current kernel\n" ); + err =TEST_SKIP ; } goto out_err; }@@ -191,7 +198,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su test_tsc >= comm2_tsc) goto out_err; - err =0 ; + err =TEST_OK ; out_err:evlist__delete (evlist);@@ -200,4 +207,15 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sureturn err; } -DEFINE_SUITE ("Convert perf time to TSC" , perf_time_to_tsc); +static struct test_case time_to_tsc_tests[] = { +TEST_CASE_REASON ("TSC support" , tsc_is_supported, +"This architecture does not support" ), +TEST_CASE_REASON ("Perf time to TSC" , perf_time_to_tsc, +"perf_read_tsc_conversion is not supported" ), + { .name =NULL , } +}; + +struct test_suite suite__perf_time_to_tsc = { + .desc ="Convert perf time to TSC" , + .test_cases = time_to_tsc_tests, +};
Signature · 3 lines
Best Regards Bryton.Lee
PATCH v4 1/1 perf test tsc: Fix error message report when not supported.
From: Chengdong Li <[email protected]>
By default perf test tsc does not return the error message when the child process detected kernel does not support. Instead, the child process print error message to stderr, unfortunately the stderr is redirected to /dev/null when verbose <= 0.
This patch did three things:
- returns TEST_SKIP to the parent process instead of TEST_OK when perf_read_tsc_conversion() is not supported.
- add a new subtest of testing if TSC is supported on current architecture by moving exist code to a separate function. It avoids two places in test__perf_time_to_tsc() that return TEST_SKIP by doing this.
- extended test suite definition to contain above two subtests. Current test_suite and test_case structs do not support printing skip reason when the number of subtest less than 1. To print skip reason, it is necessary to extend current test suite definition.
Changes since v3:
- refine commit message again to make it clear.
Changes since v2:
- refine error message format.
- refine commit log message according to Adrian's review comments.
Changes since v1 (thanks for the feedback from Adrian Hunter):
- rebase commit to current source.
--- tools/perf/tests/perf-time-to-tsc.c | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-)
tools/perf/tests/perf-time-to-tsc.c +27 -9
@@ -47,6 +47,17 @@ } \ } +static int test__tsc_is_supported (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +if (!TSC_IS_SUPPORTED ) { +pr_debug ("Test not supported on this architecture\n" ); +return TEST_SKIP ; + } + +return TEST_OK ; +} +/** * test__perf_time_to_tsc - test converting perf time to TSC. *
@@ -70,7 +81,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sustruct 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;
@@ -79,10 +90,6 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suu64 test_time, comm1_time =0 , comm2_time =0 ;struct mmap *md; -if (!TSC_IS_SUPPORTED ) { -pr_debug ("Test not supported on this architecture" ); -return TEST_SKIP ; - } threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads);
@@ -124,8 +131,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su ret =perf_read_tsc_conversion (pc, &tc);if (ret) {if (ret == -EOPNOTSUPP ) { -fprintf (stderr," (not supported)" ); -return 0 ; +pr_debug ("perf_read_tsc_conversion is not supported in current kernel\n" ); + err =TEST_SKIP ; } goto out_err; }
@@ -191,7 +198,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su test_tsc >= comm2_tsc) goto out_err; - err =0 ; + err =TEST_OK ; out_err:evlist__delete (evlist);
@@ -200,4 +207,15 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sureturn err; } -DEFINE_SUITE ("Convert perf time to TSC" , perf_time_to_tsc); +static struct test_case time_to_tsc_tests[] = { +TEST_CASE_REASON ("TSC support" , tsc_is_supported, +"This architecture does not support" ), +TEST_CASE_REASON ("Perf time to TSC" , perf_time_to_tsc, +"perf_read_tsc_conversion is not supported" ), + { .name =NULL , } +}; + +struct test_suite suite__perf_time_to_tsc = { + .desc ="Convert perf time to TSC" , + .test_cases = time_to_tsc_tests, +};
Signature · 1 line
2.27.0
Quoted 22 lines · Chengdong Li
From: Chengdong Li <[email protected]>
By default
perf test tscdoes not return the error message when the child process detected kernel does not support. Instead, the child process print error message to stderr, unfortunately the stderr is redirected to/dev/nullwhen verbose <= 0.This patch did three things:
- returnsTEST_SKIPto the parent process instead ofTEST_OKwhenperf_read_tsc_conversion()is not supported.
- add a new subtest of testing if TSC is supported on current architecture by moving exist code to a separate function. It avoids two places intest__perf_time_to_tsc()that returnTEST_SKIPby doing this.
- extended test suite definition to contain above two subtests. Currenttest_suiteandtest_casestructs do not support printing skip reason when the number of subtest less than 1. To print skip reason, it is necessary to extend current test suite definition.Changes since v3:
- refine commit message again to make it clear.
Quoted 8 lines
Changes since v2:
- refine error message format.
- refine commit log message according to Adrian's review comments.Changes since v1 (thanks for the feedback from Adrian Hunter):
- rebase commit to current source.Signed-off-by Chengdong Li <[email protected]>
Quoted 83 lines
--- tools/perf/tests/perf-time-to-tsc.c | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-)tools/perf/tests/perf-time-to-tsc.c +27
-9@@ -47,6 +47,17 @@ } \ } +static int test__tsc_is_supported (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +if (!TSC_IS_SUPPORTED ) { +pr_debug ("Test not supported on this architecture\n" ); +return TEST_SKIP ; + } + +return TEST_OK ; +} +/** * test__perf_time_to_tsc - test converting perf time to TSC. * @@ -70,7 +81,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sustruct 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;@@ -79,10 +90,6 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suu64 test_time, comm1_time =0 , comm2_time =0 ;struct mmap *md; -if (!TSC_IS_SUPPORTED ) { -pr_debug ("Test not supported on this architecture" ); -return TEST_SKIP ; - } threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads);@@ -124,8 +131,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su ret =perf_read_tsc_conversion (pc, &tc);if (ret) {if (ret == -EOPNOTSUPP ) { -fprintf (stderr," (not supported)" ); -return 0 ; +pr_debug ("perf_read_tsc_conversion is not supported in current kernel\n" ); + err =TEST_SKIP ; } goto out_err; }@@ -191,7 +198,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su test_tsc >= comm2_tsc) goto out_err; - err =0 ; + err =TEST_OK ; out_err:evlist__delete (evlist);@@ -200,4 +207,15 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sureturn err; } -DEFINE_SUITE ("Convert perf time to TSC" , perf_time_to_tsc); +static struct test_case time_to_tsc_tests[] = { +TEST_CASE_REASON ("TSC support" , tsc_is_supported, +"This architecture does not support" ), +TEST_CASE_REASON ("Perf time to TSC" , perf_time_to_tsc, +"perf_read_tsc_conversion is not supported" ), + { .name =NULL , } +}; + +struct test_suite suite__perf_time_to_tsc = { + .desc ="Convert perf time to TSC" , + .test_cases = time_to_tsc_tests, +};
Em Fri, Apr 08, 2022 at 12:16:36PM +0300, Adrian Hunter escreveu:
Quoted 27 lines · Chengdong Li
Quoted 26 lines
From: Chengdong Li <[email protected]>
By default
perf test tscdoes not return the error message when the child process detected kernel does not support. Instead, the child process print error message to stderr, unfortunately the stderr is redirected to/dev/nullwhen verbose <= 0.This patch did three things:
- returnsTEST_SKIPto the parent process instead ofTEST_OKwhenperf_read_tsc_conversion()is not supported.
- add a new subtest of testing if TSC is supported on current architecture by moving exist code to a separate function. It avoids two places intest__perf_time_to_tsc()that returnTEST_SKIPby doing this.
- extended test suite definition to contain above two subtests. Currenttest_suiteandtest_casestructs do not support printing skip reason when the number of subtest less than 1. To print skip reason, it is necessary to extend current test suite definition.Changes since v3:
- refine commit message again to make it clear.Changes since v2:
- refine error message format.
- refine commit log message according to Adrian's review comments.
Quoted 6 lines
Quoted 4 lines
Changes since v1 (thanks for the feedback from Adrian Hunter):
- rebase commit to current source.Signed-off-by Chengdong Li <[email protected]>Reviewed-by Adrian Hunter <[email protected]>
Thanks, applied.
- Arnaldo
Quoted 83 lines
Quoted 83 lines
--- tools/perf/tests/perf-time-to-tsc.c | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-)tools/perf/tests/perf-time-to-tsc.c +27
-9@@ -47,6 +47,17 @@ } \ } +static int test__tsc_is_supported (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +if (!TSC_IS_SUPPORTED ) { +pr_debug ("Test not supported on this architecture\n" ); +return TEST_SKIP ; + } + +return TEST_OK ; +} +/** * test__perf_time_to_tsc - test converting perf time to TSC. * @@ -70,7 +81,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sustruct 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;@@ -79,10 +90,6 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suu64 test_time, comm1_time =0 , comm2_time =0 ;struct mmap *md; -if (!TSC_IS_SUPPORTED ) { -pr_debug ("Test not supported on this architecture" ); -return TEST_SKIP ; - } threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads);@@ -124,8 +131,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su ret =perf_read_tsc_conversion (pc, &tc);if (ret) {if (ret == -EOPNOTSUPP ) { -fprintf (stderr," (not supported)" ); -return 0 ; +pr_debug ("perf_read_tsc_conversion is not supported in current kernel\n" ); + err =TEST_SKIP ; } goto out_err; }@@ -191,7 +198,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su test_tsc >= comm2_tsc) goto out_err; - err =0 ; + err =TEST_OK ; out_err:evlist__delete (evlist);@@ -200,4 +207,15 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int sureturn err; } -DEFINE_SUITE ("Convert perf time to TSC" , perf_time_to_tsc); +static struct test_case time_to_tsc_tests[] = { +TEST_CASE_REASON ("TSC support" , tsc_is_supported, +"This architecture does not support" ), +TEST_CASE_REASON ("Perf time to TSC" , perf_time_to_tsc, +"perf_read_tsc_conversion is not supported" ), + { .name =NULL , } +}; + +struct test_suite suite__perf_time_to_tsc = { + .desc ="Convert perf time to TSC" , + .test_cases = time_to_tsc_tests, +};
Signature · 1 line
- Arnaldo