]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.183/selftests-timers-add-missing-fflush-stdout-calls.patch
Linux 4.9.183
[thirdparty/kernel/stable-queue.git] / releases / 4.9.183 / selftests-timers-add-missing-fflush-stdout-calls.patch
1 From 9e36bd5b4bcbd8560f799bf5dac9ea8db9695c9d Mon Sep 17 00:00:00 2001
2 From: Kees Cook <keescook@chromium.org>
3 Date: Mon, 20 May 2019 15:37:49 -0700
4 Subject: selftests/timers: Add missing fflush(stdout) calls
5
6 [ Upstream commit fe48319243a626c860fd666ca032daacc2ba84a5 ]
7
8 When running under a pipe, some timer tests would not report output in
9 real-time because stdout flushes were missing after printf()s that lacked
10 a newline. This adds them to restore real-time status output that humans
11 can enjoy.
12
13 Signed-off-by: Kees Cook <keescook@chromium.org>
14 Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
15 Signed-off-by: Sasha Levin <sashal@kernel.org>
16 ---
17 tools/testing/selftests/timers/adjtick.c | 1 +
18 tools/testing/selftests/timers/leapcrash.c | 1 +
19 tools/testing/selftests/timers/mqueue-lat.c | 1 +
20 tools/testing/selftests/timers/nanosleep.c | 1 +
21 tools/testing/selftests/timers/nsleep-lat.c | 1 +
22 tools/testing/selftests/timers/raw_skew.c | 1 +
23 tools/testing/selftests/timers/set-tai.c | 1 +
24 tools/testing/selftests/timers/set-tz.c | 2 ++
25 tools/testing/selftests/timers/threadtest.c | 1 +
26 tools/testing/selftests/timers/valid-adjtimex.c | 2 ++
27 10 files changed, 12 insertions(+)
28
29 diff --git a/tools/testing/selftests/timers/adjtick.c b/tools/testing/selftests/timers/adjtick.c
30 index 9887fd538fec..91316ab4b041 100644
31 --- a/tools/testing/selftests/timers/adjtick.c
32 +++ b/tools/testing/selftests/timers/adjtick.c
33 @@ -147,6 +147,7 @@ int check_tick_adj(long tickval)
34
35 eppm = get_ppm_drift();
36 printf("%lld usec, %lld ppm", systick + (systick * eppm / MILLION), eppm);
37 + fflush(stdout);
38
39 tx1.modes = 0;
40 adjtimex(&tx1);
41 diff --git a/tools/testing/selftests/timers/leapcrash.c b/tools/testing/selftests/timers/leapcrash.c
42 index a1071bdbdeb7..a77c70b47495 100644
43 --- a/tools/testing/selftests/timers/leapcrash.c
44 +++ b/tools/testing/selftests/timers/leapcrash.c
45 @@ -114,6 +114,7 @@ int main(void)
46 }
47 clear_time_state();
48 printf(".");
49 + fflush(stdout);
50 }
51 printf("[OK]\n");
52 return ksft_exit_pass();
53 diff --git a/tools/testing/selftests/timers/mqueue-lat.c b/tools/testing/selftests/timers/mqueue-lat.c
54 index a2a3924d0b41..efdb62470052 100644
55 --- a/tools/testing/selftests/timers/mqueue-lat.c
56 +++ b/tools/testing/selftests/timers/mqueue-lat.c
57 @@ -113,6 +113,7 @@ int main(int argc, char **argv)
58 int ret;
59
60 printf("Mqueue latency : ");
61 + fflush(stdout);
62
63 ret = mqueue_lat_test();
64 if (ret < 0) {
65 diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/selftests/timers/nanosleep.c
66 index ff942ff7c9b3..2e6e94c02a33 100644
67 --- a/tools/testing/selftests/timers/nanosleep.c
68 +++ b/tools/testing/selftests/timers/nanosleep.c
69 @@ -153,6 +153,7 @@ int main(int argc, char **argv)
70 continue;
71
72 printf("Nanosleep %-31s ", clockstring(clockid));
73 + fflush(stdout);
74
75 length = 10;
76 while (length <= (NSEC_PER_SEC * 10)) {
77 diff --git a/tools/testing/selftests/timers/nsleep-lat.c b/tools/testing/selftests/timers/nsleep-lat.c
78 index 2d7898fda0f1..ac06cf10a5c2 100644
79 --- a/tools/testing/selftests/timers/nsleep-lat.c
80 +++ b/tools/testing/selftests/timers/nsleep-lat.c
81 @@ -166,6 +166,7 @@ int main(int argc, char **argv)
82 continue;
83
84 printf("nsleep latency %-26s ", clockstring(clockid));
85 + fflush(stdout);
86
87 length = 10;
88 while (length <= (NSEC_PER_SEC * 10)) {
89 diff --git a/tools/testing/selftests/timers/raw_skew.c b/tools/testing/selftests/timers/raw_skew.c
90 index 0ab937a17ebb..4e631da7f956 100644
91 --- a/tools/testing/selftests/timers/raw_skew.c
92 +++ b/tools/testing/selftests/timers/raw_skew.c
93 @@ -124,6 +124,7 @@ int main(int argv, char **argc)
94 printf("WARNING: ADJ_OFFSET in progress, this will cause inaccurate results\n");
95
96 printf("Estimating clock drift: ");
97 + fflush(stdout);
98 sleep(120);
99
100 get_monotonic_and_raw(&mon, &raw);
101 diff --git a/tools/testing/selftests/timers/set-tai.c b/tools/testing/selftests/timers/set-tai.c
102 index dc88dbc8831f..3ae76ab483de 100644
103 --- a/tools/testing/selftests/timers/set-tai.c
104 +++ b/tools/testing/selftests/timers/set-tai.c
105 @@ -66,6 +66,7 @@ int main(int argc, char **argv)
106 printf("tai offset started at %i\n", ret);
107
108 printf("Checking tai offsets can be properly set: ");
109 + fflush(stdout);
110 for (i = 1; i <= 60; i++) {
111 ret = set_tai(i);
112 ret = get_tai();
113 diff --git a/tools/testing/selftests/timers/set-tz.c b/tools/testing/selftests/timers/set-tz.c
114 index f4184928b16b..b038131c9682 100644
115 --- a/tools/testing/selftests/timers/set-tz.c
116 +++ b/tools/testing/selftests/timers/set-tz.c
117 @@ -76,6 +76,7 @@ int main(int argc, char **argv)
118 printf("tz_minuteswest started at %i, dst at %i\n", min, dst);
119
120 printf("Checking tz_minuteswest can be properly set: ");
121 + fflush(stdout);
122 for (i = -15*60; i < 15*60; i += 30) {
123 ret = set_tz(i, dst);
124 ret = get_tz_min();
125 @@ -87,6 +88,7 @@ int main(int argc, char **argv)
126 printf("[OK]\n");
127
128 printf("Checking invalid tz_minuteswest values are caught: ");
129 + fflush(stdout);
130
131 if (!set_tz(-15*60-1, dst)) {
132 printf("[FAILED] %i didn't return failure!\n", -15*60-1);
133 diff --git a/tools/testing/selftests/timers/threadtest.c b/tools/testing/selftests/timers/threadtest.c
134 index e632e116f05e..a4bf736dd842 100644
135 --- a/tools/testing/selftests/timers/threadtest.c
136 +++ b/tools/testing/selftests/timers/threadtest.c
137 @@ -175,6 +175,7 @@ int main(int argc, char **argv)
138 strftime(buf, 255, "%a, %d %b %Y %T %z", localtime(&start));
139 printf("%s\n", buf);
140 printf("Testing consistency with %i threads for %ld seconds: ", thread_count, runtime);
141 + fflush(stdout);
142
143 /* spawn */
144 for (i = 0; i < thread_count; i++)
145 diff --git a/tools/testing/selftests/timers/valid-adjtimex.c b/tools/testing/selftests/timers/valid-adjtimex.c
146 index 60fe3c569bd9..a747645d79f4 100644
147 --- a/tools/testing/selftests/timers/valid-adjtimex.c
148 +++ b/tools/testing/selftests/timers/valid-adjtimex.c
149 @@ -134,6 +134,7 @@ int validate_freq(void)
150 /* Set the leap second insert flag */
151
152 printf("Testing ADJ_FREQ... ");
153 + fflush(stdout);
154 for (i = 0; i < NUM_FREQ_VALID; i++) {
155 tx.modes = ADJ_FREQUENCY;
156 tx.freq = valid_freq[i];
157 @@ -261,6 +262,7 @@ int set_bad_offset(long sec, long usec, int use_nano)
158 int validate_set_offset(void)
159 {
160 printf("Testing ADJ_SETOFFSET... ");
161 + fflush(stdout);
162
163 /* Test valid values */
164 if (set_offset(NSEC_PER_SEC - 1, 1))
165 --
166 2.20.1
167