]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-time-util: log less verbosely 20091/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 1 Jul 2021 10:17:40 +0000 (10:17 +0000)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 1 Jul 2021 10:18:32 +0000 (10:18 +0000)
Output can always be kranked up with LOG_LEVEL=debug. But let's make less
predictable noise by default.

src/test/test-time-util.c

index 0ca9beeb5184be56c8c2bf54f36738464d5f205c..6f4675aaf47b7e8520a18efa0fba0c29a3fc1517 100644 (file)
@@ -202,13 +202,13 @@ static void test_format_timespan_one(usec_t x, usec_t accuracy) {
         const char *t;
         usec_t y;
 
-        log_info(USEC_FMT"     (at accuracy "USEC_FMT")", x, accuracy);
+        log_debug(USEC_FMT"     (at accuracy "USEC_FMT")", x, accuracy);
 
         assert_se(t = format_timespan(l, sizeof l, x, accuracy));
-        log_info(" = <%s>", t);
+        log_debug(" = <%s>", t);
 
         assert_se(parse_sec(t, &y) >= 0);
-        log_info(" = "USEC_FMT, y);
+        log_debug(" = "USEC_FMT, y);
 
         if (accuracy <= 0)
                 accuracy = 1;
@@ -329,11 +329,9 @@ static void test_usec_sub_signed(void) {
 }
 
 static void test_format_timestamp(void) {
-        unsigned i;
-
         log_info("/* %s */", __func__);
 
-        for (i = 0; i < 100; i++) {
+        for (unsigned i = 0; i < 100; i++) {
                 char buf[MAX(FORMAT_TIMESTAMP_MAX, FORMAT_TIMESPAN_MAX)];
                 usec_t x, y;
 
@@ -341,27 +339,27 @@ static void test_format_timestamp(void) {
                 x = x % (2147483600 * USEC_PER_SEC) + 1;
 
                 assert_se(format_timestamp(buf, sizeof(buf), x));
-                log_info("%s", buf);
+                log_debug("%s", buf);
                 assert_se(parse_timestamp(buf, &y) >= 0);
                 assert_se(x / USEC_PER_SEC == y / USEC_PER_SEC);
 
                 assert_se(format_timestamp_style(buf, sizeof(buf), x, TIMESTAMP_UTC));
-                log_info("%s", buf);
+                log_debug("%s", buf);
                 assert_se(parse_timestamp(buf, &y) >= 0);
                 assert_se(x / USEC_PER_SEC == y / USEC_PER_SEC);
 
                 assert_se(format_timestamp_style(buf, sizeof(buf), x, TIMESTAMP_US));
-                log_info("%s", buf);
+                log_debug("%s", buf);
                 assert_se(parse_timestamp(buf, &y) >= 0);
                 assert_se(x == y);
 
                 assert_se(format_timestamp_style(buf, sizeof(buf), x, TIMESTAMP_US_UTC));
-                log_info("%s", buf);
+                log_debug("%s", buf);
                 assert_se(parse_timestamp(buf, &y) >= 0);
                 assert_se(x == y);
 
                 assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-                log_info("%s", buf);
+                log_debug("%s", buf);
                 assert_se(parse_timestamp(buf, &y) >= 0);
 
                 /* The two calls above will run with a slightly different local time. Make sure we are in the same
@@ -385,64 +383,64 @@ static void test_format_timestamp_relative(void) {
         /* Years and months */
         x = now(CLOCK_REALTIME) - (1*USEC_PER_YEAR + 1*USEC_PER_MONTH);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "1 year 1 month ago"));
 
         x = now(CLOCK_REALTIME) - (1*USEC_PER_YEAR + 2*USEC_PER_MONTH);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "1 year 2 months ago"));
 
         x = now(CLOCK_REALTIME) - (2*USEC_PER_YEAR + 1*USEC_PER_MONTH);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "2 years 1 month ago"));
 
         x = now(CLOCK_REALTIME) - (2*USEC_PER_YEAR + 2*USEC_PER_MONTH);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "2 years 2 months ago"));
 
         /* Months and days */
         x = now(CLOCK_REALTIME) - (1*USEC_PER_MONTH + 1*USEC_PER_DAY);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "1 month 1 day ago"));
 
         x = now(CLOCK_REALTIME) - (1*USEC_PER_MONTH + 2*USEC_PER_DAY);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "1 month 2 days ago"));
 
         x = now(CLOCK_REALTIME) - (2*USEC_PER_MONTH + 1*USEC_PER_DAY);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "2 months 1 day ago"));
 
         x = now(CLOCK_REALTIME) - (2*USEC_PER_MONTH + 2*USEC_PER_DAY);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "2 months 2 days ago"));
 
         /* Weeks and days */
         x = now(CLOCK_REALTIME) - (1*USEC_PER_WEEK + 1*USEC_PER_DAY);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "1 week 1 day ago"));
 
         x = now(CLOCK_REALTIME) - (1*USEC_PER_WEEK + 2*USEC_PER_DAY);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "1 week 2 days ago"));
 
         x = now(CLOCK_REALTIME) - (2*USEC_PER_WEEK + 1*USEC_PER_DAY);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "2 weeks 1 day ago"));
 
         x = now(CLOCK_REALTIME) - (2*USEC_PER_WEEK + 2*USEC_PER_DAY);
         assert_se(format_timestamp_relative(buf, sizeof(buf), x));
-        log_info("%s", buf);
+        log_debug("%s", buf);
         assert_se(streq(buf, "2 weeks 2 days ago"));
 }