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;
}
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;
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
/* 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"));
}