[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230927-ktap-posix-timers-v1-3-399de1cbfbea@kernel.org>
Date: Wed, 27 Sep 2023 12:18:59 +0200
From: Mark Brown <broonie@...nel.org>
To: Shuah Khan <shuah@...nel.org>, John Stultz <jstultz@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Stephen Boyd <sboyd@...nel.org>
Cc: linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
Mark Brown <broonie@...nel.org>
Subject: [PATCH 3/3] 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@...nel.org>
---
tools/testing/selftests/timers/nsleep-lat.c | 26 ++++++++++++--------------
1 file 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();
}
--
2.39.2
Powered by blists - more mailing lists