OSDN Git Service

selftests/timers: Add missing fflush(stdout) calls
authorKees Cook <keescook@chromium.org>
Mon, 20 May 2019 22:37:49 +0000 (15:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Jun 2019 06:17:20 +0000 (08:17 +0200)
[ Upstream commit fe48319243a626c860fd666ca032daacc2ba84a5 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/timers/adjtick.c
tools/testing/selftests/timers/leapcrash.c
tools/testing/selftests/timers/mqueue-lat.c
tools/testing/selftests/timers/nanosleep.c
tools/testing/selftests/timers/nsleep-lat.c
tools/testing/selftests/timers/raw_skew.c
tools/testing/selftests/timers/set-tai.c
tools/testing/selftests/timers/set-tz.c
tools/testing/selftests/timers/threadtest.c
tools/testing/selftests/timers/valid-adjtimex.c

index 9887fd5..91316ab 100644 (file)
@@ -147,6 +147,7 @@ int check_tick_adj(long tickval)
 
        eppm = get_ppm_drift();
        printf("%lld usec, %lld ppm", systick + (systick * eppm / MILLION), eppm);
+       fflush(stdout);
 
        tx1.modes = 0;
        adjtimex(&tx1);
index a1071bd..a77c70b 100644 (file)
@@ -114,6 +114,7 @@ int main(void)
                }
                clear_time_state();
                printf(".");
+               fflush(stdout);
        }
        printf("[OK]\n");
        return ksft_exit_pass();
index a2a3924..efdb624 100644 (file)
@@ -113,6 +113,7 @@ int main(int argc, char **argv)
        int ret;
 
        printf("Mqueue latency :                          ");
+       fflush(stdout);
 
        ret = mqueue_lat_test();
        if (ret < 0) {
index ff942ff..2e6e94c 100644 (file)
@@ -153,6 +153,7 @@ int main(int argc, char **argv)
                        continue;
 
                printf("Nanosleep %-31s ", clockstring(clockid));
+               fflush(stdout);
 
                length = 10;
                while (length <= (NSEC_PER_SEC * 10)) {
index 2d7898f..ac06cf1 100644 (file)
@@ -166,6 +166,7 @@ int main(int argc, char **argv)
                        continue;
 
                printf("nsleep latency %-26s ", clockstring(clockid));
+               fflush(stdout);
 
                length = 10;
                while (length <= (NSEC_PER_SEC * 10)) {
index 0ab937a..4e631da 100644 (file)
@@ -124,6 +124,7 @@ int main(int argv, char **argc)
                printf("WARNING: ADJ_OFFSET in progress, this will cause inaccurate results\n");
 
        printf("Estimating clock drift: ");
+       fflush(stdout);
        sleep(120);
 
        get_monotonic_and_raw(&mon, &raw);
index dc88dbc..3ae76ab 100644 (file)
@@ -66,6 +66,7 @@ int main(int argc, char **argv)
        printf("tai offset started at %i\n", ret);
 
        printf("Checking tai offsets can be properly set: ");
+       fflush(stdout);
        for (i = 1; i <= 60; i++) {
                ret = set_tai(i);
                ret = get_tai();
index f418492..b038131 100644 (file)
@@ -76,6 +76,7 @@ int main(int argc, char **argv)
        printf("tz_minuteswest started at %i, dst at %i\n", min, dst);
 
        printf("Checking tz_minuteswest can be properly set: ");
+       fflush(stdout);
        for (i = -15*60; i < 15*60; i += 30) {
                ret = set_tz(i, dst);
                ret = get_tz_min();
@@ -87,6 +88,7 @@ int main(int argc, char **argv)
        printf("[OK]\n");
 
        printf("Checking invalid tz_minuteswest values are caught: ");
+       fflush(stdout);
 
        if (!set_tz(-15*60-1, dst)) {
                printf("[FAILED] %i didn't return failure!\n", -15*60-1);
index e632e11..a4bf736 100644 (file)
@@ -175,6 +175,7 @@ int main(int argc, char **argv)
        strftime(buf, 255, "%a, %d %b %Y %T %z", localtime(&start));
        printf("%s\n", buf);
        printf("Testing consistency with %i threads for %ld seconds: ", thread_count, runtime);
+       fflush(stdout);
 
        /* spawn */
        for (i = 0; i < thread_count; i++)
index 60fe3c5..a747645 100644 (file)
@@ -134,6 +134,7 @@ int validate_freq(void)
        /* Set the leap second insert flag */
 
        printf("Testing ADJ_FREQ... ");
+       fflush(stdout);
        for (i = 0; i < NUM_FREQ_VALID; i++) {
                tx.modes = ADJ_FREQUENCY;
                tx.freq = valid_freq[i];
@@ -261,6 +262,7 @@ int set_bad_offset(long sec, long usec, int use_nano)
 int validate_set_offset(void)
 {
        printf("Testing ADJ_SETOFFSET... ");
+       fflush(stdout);
 
        /* Test valid values */
        if (set_offset(NSEC_PER_SEC - 1, 1))