Skip to content

Commit 04fd937

Browse files
Wolfram Sangshuahkh
authored andcommitted
selftests: timers: inconsistency-check: adapt to kselftest framework
So we have proper counters at the end of a test, e.g.: # Totals: pass:11 fail:0 xfail:0 xpass:0 skip:1 error:0 Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: John Stultz <jstultz@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 2d87048 commit 04fd937

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

tools/testing/selftests/timers/inconsistency-check.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,30 +122,28 @@ int consistency_test(int clock_type, unsigned long seconds)
122122
if (inconsistent >= 0) {
123123
unsigned long long delta;
124124

125-
printf("\%s\n", start_str);
125+
ksft_print_msg("\%s\n", start_str);
126126
for (i = 0; i < CALLS_PER_LOOP; i++) {
127127
if (i == inconsistent)
128-
printf("--------------------\n");
129-
printf("%lu:%lu\n", list[i].tv_sec,
128+
ksft_print_msg("--------------------\n");
129+
ksft_print_msg("%lu:%lu\n", list[i].tv_sec,
130130
list[i].tv_nsec);
131131
if (i == inconsistent + 1)
132-
printf("--------------------\n");
132+
ksft_print_msg("--------------------\n");
133133
}
134134
delta = list[inconsistent].tv_sec * NSEC_PER_SEC;
135135
delta += list[inconsistent].tv_nsec;
136136
delta -= list[inconsistent+1].tv_sec * NSEC_PER_SEC;
137137
delta -= list[inconsistent+1].tv_nsec;
138-
printf("Delta: %llu ns\n", delta);
138+
ksft_print_msg("Delta: %llu ns\n", delta);
139139
fflush(0);
140140
/* timestamp inconsistency*/
141141
t = time(0);
142-
printf("%s\n", ctime(&t));
143-
printf("[FAILED]\n");
142+
ksft_print_msg("%s\n", ctime(&t));
144143
return -1;
145144
}
146145
now = list[0].tv_sec;
147146
}
148-
printf("[OK]\n");
149147
return 0;
150148
}
151149

@@ -178,16 +176,22 @@ int main(int argc, char *argv[])
178176

179177
setbuf(stdout, NULL);
180178

179+
ksft_print_header();
180+
ksft_set_plan(maxclocks - userclock);
181+
181182
for (clockid = userclock; clockid < maxclocks; clockid++) {
182183

183-
if (clockid == CLOCK_HWSPECIFIC)
184+
if (clockid == CLOCK_HWSPECIFIC || clock_gettime(clockid, &ts)) {
185+
ksft_test_result_skip("%-31s\n", clockstring(clockid));
184186
continue;
187+
}
185188

186-
if (!clock_gettime(clockid, &ts)) {
187-
printf("Consistent %-30s ", clockstring(clockid));
188-
if (consistency_test(clockid, runtime))
189-
return ksft_exit_fail();
189+
if (consistency_test(clockid, runtime)) {
190+
ksft_test_result_fail("%-31s\n", clockstring(clockid));
191+
ksft_exit_fail();
192+
} else {
193+
ksft_test_result_pass("%-31s\n", clockstring(clockid));
190194
}
191195
}
192-
return ksft_exit_pass();
196+
ksft_exit_pass();
193197
}

0 commit comments

Comments
 (0)