diff options
author | Mark Brown <broonie@kernel.org> | 2023-09-27 12:18:59 +0200 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2023-10-05 15:00:14 -0600 |
commit | 0a6fa8f03e1497d3d1bf2e55f1e5b082dda227d4 (patch) | |
tree | 869685c044c8340ba8ac37a477c6063c4eea9614 | |
parent | 071af0c9e582bc47e379e39490a2bc1adfe4ec68 (diff) | |
download | linux-stable-0a6fa8f03e1497d3d1bf2e55f1e5b082dda227d4.tar.gz linux-stable-0a6fa8f03e1497d3d1bf2e55f1e5b082dda227d4.tar.bz2 linux-stable-0a6fa8f03e1497d3d1bf2e55f1e5b082dda227d4.zip |
selftests: timers: Convert nsleep-lat test to generate KTAP output
Currently the nsleep-lat test does not produce KTAP output but rather a
custom format. This means that we only get a pass/fail for the suite, not
for each individual test that the suite does. Convert to using the standard
kselftest output functions which result in KTAP output being generated.
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
-rw-r--r-- | tools/testing/selftests/timers/nsleep-lat.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/tools/testing/selftests/timers/nsleep-lat.c b/tools/testing/selftests/timers/nsleep-lat.c index eb3e79ed7b4a..edb5acacf214 100644 --- a/tools/testing/selftests/timers/nsleep-lat.c +++ b/tools/testing/selftests/timers/nsleep-lat.c @@ -118,7 +118,7 @@ int nanosleep_lat_test(int clockid, long long ns) clock_gettime(clockid, &end); if (((timespec_sub(start, end)/count)-ns) > UNRESONABLE_LATENCY) { - printf("Large rel latency: %lld ns :", (timespec_sub(start, end)/count)-ns); + ksft_print_msg("Large rel latency: %lld ns :", (timespec_sub(start, end)/count)-ns); return -1; } @@ -132,20 +132,23 @@ int nanosleep_lat_test(int clockid, long long ns) } if (latency/count > UNRESONABLE_LATENCY) { - printf("Large abs latency: %lld ns :", latency/count); + ksft_print_msg("Large abs latency: %lld ns :", latency/count); return -1; } return 0; } - +#define SKIPPED_CLOCK_COUNT 3 int main(int argc, char **argv) { long long length; int clockid, ret; + ksft_print_header(); + ksft_set_plan(NR_CLOCKIDS - CLOCK_REALTIME - SKIPPED_CLOCK_COUNT); + for (clockid = CLOCK_REALTIME; clockid < NR_CLOCKIDS; clockid++) { /* Skip cputime clockids since nanosleep won't increment cputime */ @@ -154,9 +157,6 @@ int main(int argc, char **argv) clockid == CLOCK_HWSPECIFIC) continue; - printf("nsleep latency %-26s ", clockstring(clockid)); - fflush(stdout); - length = 10; while (length <= (NSEC_PER_SEC * 10)) { ret = nanosleep_lat_test(clockid, length); @@ -167,14 +167,12 @@ int main(int argc, char **argv) } if (ret == UNSUPPORTED) { - printf("[UNSUPPORTED]\n"); - continue; - } - if (ret < 0) { - printf("[FAILED]\n"); - return ksft_exit_fail(); + ksft_test_result_skip("%s\n", clockstring(clockid)); + } else { + ksft_test_result(ret >= 0, "%s\n", + clockstring(clockid)); } - printf("[OK]\n"); } - return ksft_exit_pass(); + + ksft_finished(); } |