Skip to content

Commit fe48319

Browse files
keesshuahkh
authored andcommitted
selftests/timers: Add missing fflush(stdout) calls
When running under a pipe, some timer tests would not report output in real-time because stdout flushes were missing after printf()s that lacked a newline. This adds them to restore real-time status output that humans can enjoy. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent e810886 commit fe48319

File tree

10 files changed

+12
-0
lines changed

10 files changed

+12
-0
lines changed

tools/testing/selftests/timers/adjtick.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ int check_tick_adj(long tickval)
136136

137137
eppm = get_ppm_drift();
138138
printf("%lld usec, %lld ppm", systick + (systick * eppm / MILLION), eppm);
139+
fflush(stdout);
139140

140141
tx1.modes = 0;
141142
adjtimex(&tx1);

tools/testing/selftests/timers/leapcrash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ int main(void)
101101
}
102102
clear_time_state();
103103
printf(".");
104+
fflush(stdout);
104105
}
105106
printf("[OK]\n");
106107
return ksft_exit_pass();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ int main(int argc, char **argv)
102102
int ret;
103103

104104
printf("Mqueue latency : ");
105+
fflush(stdout);
105106

106107
ret = mqueue_lat_test();
107108
if (ret < 0) {

tools/testing/selftests/timers/nanosleep.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ int main(int argc, char **argv)
142142
continue;
143143

144144
printf("Nanosleep %-31s ", clockstring(clockid));
145+
fflush(stdout);
145146

146147
length = 10;
147148
while (length <= (NSEC_PER_SEC * 10)) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ int main(int argc, char **argv)
155155
continue;
156156

157157
printf("nsleep latency %-26s ", clockstring(clockid));
158+
fflush(stdout);
158159

159160
length = 10;
160161
while (length <= (NSEC_PER_SEC * 10)) {

tools/testing/selftests/timers/raw_skew.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ int main(int argv, char **argc)
112112
printf("WARNING: ADJ_OFFSET in progress, this will cause inaccurate results\n");
113113

114114
printf("Estimating clock drift: ");
115+
fflush(stdout);
115116
sleep(120);
116117

117118
get_monotonic_and_raw(&mon, &raw);

tools/testing/selftests/timers/set-tai.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ int main(int argc, char **argv)
5555
printf("tai offset started at %i\n", ret);
5656

5757
printf("Checking tai offsets can be properly set: ");
58+
fflush(stdout);
5859
for (i = 1; i <= 60; i++) {
5960
ret = set_tai(i);
6061
ret = get_tai();

tools/testing/selftests/timers/set-tz.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ int main(int argc, char **argv)
6565
printf("tz_minuteswest started at %i, dst at %i\n", min, dst);
6666

6767
printf("Checking tz_minuteswest can be properly set: ");
68+
fflush(stdout);
6869
for (i = -15*60; i < 15*60; i += 30) {
6970
ret = set_tz(i, dst);
7071
ret = get_tz_min();
@@ -76,6 +77,7 @@ int main(int argc, char **argv)
7677
printf("[OK]\n");
7778

7879
printf("Checking invalid tz_minuteswest values are caught: ");
80+
fflush(stdout);
7981

8082
if (!set_tz(-15*60-1, dst)) {
8183
printf("[FAILED] %i didn't return failure!\n", -15*60-1);

tools/testing/selftests/timers/threadtest.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ int main(int argc, char **argv)
163163
strftime(buf, 255, "%a, %d %b %Y %T %z", localtime(&start));
164164
printf("%s\n", buf);
165165
printf("Testing consistency with %i threads for %ld seconds: ", thread_count, runtime);
166+
fflush(stdout);
166167

167168
/* spawn */
168169
for (i = 0; i < thread_count; i++)

tools/testing/selftests/timers/valid-adjtimex.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ int validate_freq(void)
123123
/* Set the leap second insert flag */
124124

125125
printf("Testing ADJ_FREQ... ");
126+
fflush(stdout);
126127
for (i = 0; i < NUM_FREQ_VALID; i++) {
127128
tx.modes = ADJ_FREQUENCY;
128129
tx.freq = valid_freq[i];
@@ -250,6 +251,7 @@ int set_bad_offset(long sec, long usec, int use_nano)
250251
int validate_set_offset(void)
251252
{
252253
printf("Testing ADJ_SETOFFSET... ");
254+
fflush(stdout);
253255

254256
/* Test valid values */
255257
if (set_offset(NSEC_PER_SEC - 1, 1))

0 commit comments

Comments
 (0)