Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Mark Brown and committed by
Shuah Khan
0a6fa8f0 071af0c9

+12 -14
+12 -14
tools/testing/selftests/timers/nsleep-lat.c
··· 118 118 clock_gettime(clockid, &end); 119 119 120 120 if (((timespec_sub(start, end)/count)-ns) > UNRESONABLE_LATENCY) { 121 - printf("Large rel latency: %lld ns :", (timespec_sub(start, end)/count)-ns); 121 + ksft_print_msg("Large rel latency: %lld ns :", (timespec_sub(start, end)/count)-ns); 122 122 return -1; 123 123 } 124 124 ··· 132 132 } 133 133 134 134 if (latency/count > UNRESONABLE_LATENCY) { 135 - printf("Large abs latency: %lld ns :", latency/count); 135 + ksft_print_msg("Large abs latency: %lld ns :", latency/count); 136 136 return -1; 137 137 } 138 138 139 139 return 0; 140 140 } 141 141 142 - 142 + #define SKIPPED_CLOCK_COUNT 3 143 143 144 144 int main(int argc, char **argv) 145 145 { 146 146 long long length; 147 147 int clockid, ret; 148 + 149 + ksft_print_header(); 150 + ksft_set_plan(NR_CLOCKIDS - CLOCK_REALTIME - SKIPPED_CLOCK_COUNT); 148 151 149 152 for (clockid = CLOCK_REALTIME; clockid < NR_CLOCKIDS; clockid++) { 150 153 ··· 156 153 clockid == CLOCK_THREAD_CPUTIME_ID || 157 154 clockid == CLOCK_HWSPECIFIC) 158 155 continue; 159 - 160 - printf("nsleep latency %-26s ", clockstring(clockid)); 161 - fflush(stdout); 162 156 163 157 length = 10; 164 158 while (length <= (NSEC_PER_SEC * 10)) { ··· 167 167 } 168 168 169 169 if (ret == UNSUPPORTED) { 170 - printf("[UNSUPPORTED]\n"); 171 - continue; 170 + ksft_test_result_skip("%s\n", clockstring(clockid)); 171 + } else { 172 + ksft_test_result(ret >= 0, "%s\n", 173 + clockstring(clockid)); 172 174 } 173 - if (ret < 0) { 174 - printf("[FAILED]\n"); 175 - return ksft_exit_fail(); 176 - } 177 - printf("[OK]\n"); 178 175 } 179 - return ksft_exit_pass(); 176 + 177 + ksft_finished(); 180 178 }