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

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 <keescook@chromium.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Kees Cook and committed by
Shuah Khan
fe483192 e8108866

+12
+1
tools/testing/selftests/timers/adjtick.c
··· 136 136 137 137 eppm = get_ppm_drift(); 138 138 printf("%lld usec, %lld ppm", systick + (systick * eppm / MILLION), eppm); 139 + fflush(stdout); 139 140 140 141 tx1.modes = 0; 141 142 adjtimex(&tx1);
+1
tools/testing/selftests/timers/leapcrash.c
··· 101 101 } 102 102 clear_time_state(); 103 103 printf("."); 104 + fflush(stdout); 104 105 } 105 106 printf("[OK]\n"); 106 107 return ksft_exit_pass();
+1
tools/testing/selftests/timers/mqueue-lat.c
··· 102 102 int ret; 103 103 104 104 printf("Mqueue latency : "); 105 + fflush(stdout); 105 106 106 107 ret = mqueue_lat_test(); 107 108 if (ret < 0) {
+1
tools/testing/selftests/timers/nanosleep.c
··· 142 142 continue; 143 143 144 144 printf("Nanosleep %-31s ", clockstring(clockid)); 145 + fflush(stdout); 145 146 146 147 length = 10; 147 148 while (length <= (NSEC_PER_SEC * 10)) {
+1
tools/testing/selftests/timers/nsleep-lat.c
··· 155 155 continue; 156 156 157 157 printf("nsleep latency %-26s ", clockstring(clockid)); 158 + fflush(stdout); 158 159 159 160 length = 10; 160 161 while (length <= (NSEC_PER_SEC * 10)) {
+1
tools/testing/selftests/timers/raw_skew.c
··· 112 112 printf("WARNING: ADJ_OFFSET in progress, this will cause inaccurate results\n"); 113 113 114 114 printf("Estimating clock drift: "); 115 + fflush(stdout); 115 116 sleep(120); 116 117 117 118 get_monotonic_and_raw(&mon, &raw);
+1
tools/testing/selftests/timers/set-tai.c
··· 55 55 printf("tai offset started at %i\n", ret); 56 56 57 57 printf("Checking tai offsets can be properly set: "); 58 + fflush(stdout); 58 59 for (i = 1; i <= 60; i++) { 59 60 ret = set_tai(i); 60 61 ret = get_tai();
+2
tools/testing/selftests/timers/set-tz.c
··· 65 65 printf("tz_minuteswest started at %i, dst at %i\n", min, dst); 66 66 67 67 printf("Checking tz_minuteswest can be properly set: "); 68 + fflush(stdout); 68 69 for (i = -15*60; i < 15*60; i += 30) { 69 70 ret = set_tz(i, dst); 70 71 ret = get_tz_min(); ··· 77 76 printf("[OK]\n"); 78 77 79 78 printf("Checking invalid tz_minuteswest values are caught: "); 79 + fflush(stdout); 80 80 81 81 if (!set_tz(-15*60-1, dst)) { 82 82 printf("[FAILED] %i didn't return failure!\n", -15*60-1);
+1
tools/testing/selftests/timers/threadtest.c
··· 163 163 strftime(buf, 255, "%a, %d %b %Y %T %z", localtime(&start)); 164 164 printf("%s\n", buf); 165 165 printf("Testing consistency with %i threads for %ld seconds: ", thread_count, runtime); 166 + fflush(stdout); 166 167 167 168 /* spawn */ 168 169 for (i = 0; i < thread_count; i++)
+2
tools/testing/selftests/timers/valid-adjtimex.c
··· 123 123 /* Set the leap second insert flag */ 124 124 125 125 printf("Testing ADJ_FREQ... "); 126 + fflush(stdout); 126 127 for (i = 0; i < NUM_FREQ_VALID; i++) { 127 128 tx.modes = ADJ_FREQUENCY; 128 129 tx.freq = valid_freq[i]; ··· 251 250 int validate_set_offset(void) 252 251 { 253 252 printf("Testing ADJ_SETOFFSET... "); 253 + fflush(stdout); 254 254 255 255 /* Test valid values */ 256 256 if (set_offset(NSEC_PER_SEC - 1, 1))