Skip to content

Commit ecfe687

Browse files
committed
selftests:timers: remove local CLOCKID defines
timers tests defines CLOCKIDs locally. Remove all local CLOCKIDs except CLOCK_HWSPECIFIC and use defines from time.h header file. CLOCK_HWSPECIFIC and CLOCK_SGI_CYCLE are the same and CLOCK_SGI_CYCLE is deprecated, Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> Acked-by: John Stultz <jstultz@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 488be88 commit ecfe687

7 files changed

Lines changed: 15 additions & 76 deletions

File tree

tools/testing/selftests/timers/adjtick.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
#include "../kselftest.h"
2828

29-
#define CLOCK_MONOTONIC_RAW 4
30-
3129
#define MILLION 1000000
3230

3331
long systick;

tools/testing/selftests/timers/alarmtimer-suspend.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,6 @@
3232
#include <errno.h>
3333
#include "../kselftest.h"
3434

35-
#define CLOCK_REALTIME 0
36-
#define CLOCK_MONOTONIC 1
37-
#define CLOCK_PROCESS_CPUTIME_ID 2
38-
#define CLOCK_THREAD_CPUTIME_ID 3
39-
#define CLOCK_MONOTONIC_RAW 4
40-
#define CLOCK_REALTIME_COARSE 5
41-
#define CLOCK_MONOTONIC_COARSE 6
42-
#define CLOCK_BOOTTIME 7
43-
#define CLOCK_REALTIME_ALARM 8
44-
#define CLOCK_BOOTTIME_ALARM 9
45-
#define CLOCK_HWSPECIFIC 10
46-
#define CLOCK_TAI 11
47-
#define NR_CLOCKIDS 12
48-
49-
5035
#define UNREASONABLE_LAT (NSEC_PER_SEC * 5) /* hopefully we resume in 5 secs */
5136

5237
#define SUSPEND_SECS 15

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,10 @@
3131
#include <include/vdso/time64.h>
3232
#include "../kselftest.h"
3333

34-
#define CALLS_PER_LOOP 64
35-
36-
#define CLOCK_REALTIME 0
37-
#define CLOCK_MONOTONIC 1
38-
#define CLOCK_PROCESS_CPUTIME_ID 2
39-
#define CLOCK_THREAD_CPUTIME_ID 3
40-
#define CLOCK_MONOTONIC_RAW 4
41-
#define CLOCK_REALTIME_COARSE 5
42-
#define CLOCK_MONOTONIC_COARSE 6
43-
#define CLOCK_BOOTTIME 7
44-
#define CLOCK_REALTIME_ALARM 8
45-
#define CLOCK_BOOTTIME_ALARM 9
34+
/* CLOCK_HWSPECIFIC == CLOCK_SGI_CYCLE (Deprecated) */
4635
#define CLOCK_HWSPECIFIC 10
47-
#define CLOCK_TAI 11
48-
#define NR_CLOCKIDS 12
36+
37+
#define CALLS_PER_LOOP 64
4938

5039
char *clockstring(int clockid)
5140
{
@@ -152,7 +141,7 @@ int main(int argc, char *argv[])
152141
{
153142
int clockid, opt;
154143
int userclock = CLOCK_REALTIME;
155-
int maxclocks = NR_CLOCKIDS;
144+
int maxclocks = CLOCK_TAI + 1;
156145
int runtime = 10;
157146
struct timespec ts;
158147

tools/testing/selftests/timers/nanosleep.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,8 @@
3030
#include <include/vdso/time64.h>
3131
#include "../kselftest.h"
3232

33-
#define CLOCK_REALTIME 0
34-
#define CLOCK_MONOTONIC 1
35-
#define CLOCK_PROCESS_CPUTIME_ID 2
36-
#define CLOCK_THREAD_CPUTIME_ID 3
37-
#define CLOCK_MONOTONIC_RAW 4
38-
#define CLOCK_REALTIME_COARSE 5
39-
#define CLOCK_MONOTONIC_COARSE 6
40-
#define CLOCK_BOOTTIME 7
41-
#define CLOCK_REALTIME_ALARM 8
42-
#define CLOCK_BOOTTIME_ALARM 9
33+
/* CLOCK_HWSPECIFIC == CLOCK_SGI_CYCLE (Deprecated) */
4334
#define CLOCK_HWSPECIFIC 10
44-
#define CLOCK_TAI 11
45-
#define NR_CLOCKIDS 12
4635

4736
#define UNSUPPORTED 0xf00f
4837

@@ -131,11 +120,12 @@ int main(int argc, char **argv)
131120
{
132121
long long length;
133122
int clockid, ret;
123+
int max_clocks = CLOCK_TAI + 1;
134124

135125
ksft_print_header();
136-
ksft_set_plan(NR_CLOCKIDS);
126+
ksft_set_plan(max_clocks);
137127

138-
for (clockid = CLOCK_REALTIME; clockid < NR_CLOCKIDS; clockid++) {
128+
for (clockid = CLOCK_REALTIME; clockid < max_clocks; clockid++) {
139129

140130
/* Skip cputime clockids since nanosleep won't increment cputime */
141131
if (clockid == CLOCK_PROCESS_CPUTIME_ID ||

tools/testing/selftests/timers/nsleep-lat.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,8 @@
2929

3030
#define UNRESONABLE_LATENCY 40000000 /* 40ms in nanosecs */
3131

32-
33-
#define CLOCK_REALTIME 0
34-
#define CLOCK_MONOTONIC 1
35-
#define CLOCK_PROCESS_CPUTIME_ID 2
36-
#define CLOCK_THREAD_CPUTIME_ID 3
37-
#define CLOCK_MONOTONIC_RAW 4
38-
#define CLOCK_REALTIME_COARSE 5
39-
#define CLOCK_MONOTONIC_COARSE 6
40-
#define CLOCK_BOOTTIME 7
41-
#define CLOCK_REALTIME_ALARM 8
42-
#define CLOCK_BOOTTIME_ALARM 9
32+
/* CLOCK_HWSPECIFIC == CLOCK_SGI_CYCLE (Deprecated) */
4333
#define CLOCK_HWSPECIFIC 10
44-
#define CLOCK_TAI 11
45-
#define NR_CLOCKIDS 12
4634

4735
#define UNSUPPORTED 0xf00f
4836

@@ -144,11 +132,12 @@ int main(int argc, char **argv)
144132
{
145133
long long length;
146134
int clockid, ret;
135+
int max_clocks = CLOCK_TAI + 1;
147136

148137
ksft_print_header();
149-
ksft_set_plan(NR_CLOCKIDS - CLOCK_REALTIME - SKIPPED_CLOCK_COUNT);
138+
ksft_set_plan(max_clocks - CLOCK_REALTIME - SKIPPED_CLOCK_COUNT);
150139

151-
for (clockid = CLOCK_REALTIME; clockid < NR_CLOCKIDS; clockid++) {
140+
for (clockid = CLOCK_REALTIME; clockid < max_clocks; clockid++) {
152141

153142
/* Skip cputime clockids since nanosleep won't increment cputime */
154143
if (clockid == CLOCK_PROCESS_CPUTIME_ID ||

tools/testing/selftests/timers/raw_skew.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#include <include/vdso/time64.h>
2929
#include "../kselftest.h"
3030

31-
#define CLOCK_MONOTONIC_RAW 4
32-
3331
#define shift_right(x, s) ({ \
3432
__typeof__(x) __x = (x); \
3533
__typeof__(s) __s = (s); \

tools/testing/selftests/timers/set-timer-lat.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,8 @@
3131
#include <include/vdso/time64.h>
3232
#include "../kselftest.h"
3333

34-
#define CLOCK_REALTIME 0
35-
#define CLOCK_MONOTONIC 1
36-
#define CLOCK_PROCESS_CPUTIME_ID 2
37-
#define CLOCK_THREAD_CPUTIME_ID 3
38-
#define CLOCK_MONOTONIC_RAW 4
39-
#define CLOCK_REALTIME_COARSE 5
40-
#define CLOCK_MONOTONIC_COARSE 6
41-
#define CLOCK_BOOTTIME 7
42-
#define CLOCK_REALTIME_ALARM 8
43-
#define CLOCK_BOOTTIME_ALARM 9
34+
/* CLOCK_HWSPECIFIC == CLOCK_SGI_CYCLE (Deprecated) */
4435
#define CLOCK_HWSPECIFIC 10
45-
#define CLOCK_TAI 11
46-
#define NR_CLOCKIDS 12
4736

4837
#define UNRESONABLE_LATENCY 40000000 /* 40ms in nanosecs */
4938

@@ -253,6 +242,7 @@ int main(void)
253242
struct sigaction act;
254243
int signum = SIGRTMAX;
255244
int ret = 0;
245+
int max_clocks = CLOCK_TAI + 1;
256246

257247
/* Set up signal handler: */
258248
sigfillset(&act.sa_mask);
@@ -261,7 +251,7 @@ int main(void)
261251
sigaction(signum, &act, NULL);
262252

263253
printf("Setting timers for every %i seconds\n", TIMER_SECS);
264-
for (clock_id = 0; clock_id < NR_CLOCKIDS; clock_id++) {
254+
for (clock_id = 0; clock_id < max_clocks; clock_id++) {
265255

266256
if ((clock_id == CLOCK_PROCESS_CPUTIME_ID) ||
267257
(clock_id == CLOCK_THREAD_CPUTIME_ID) ||

0 commit comments

Comments
 (0)