Commit 0a6fa8f0 authored by Mark Brown's avatar Mark Brown Committed by Shuah Khan
Browse files

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: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 071af0c9
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -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();
}