summaryrefslogtreecommitdiffstats
path: root/src/test/test-calendarspec.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-07-14 09:14:08 +0200
committerGitHub <noreply@github.com>2021-07-14 09:14:08 +0200
commite18f21e34924d02dd7c330a644149d89fcc38042 (patch)
tree28782cf9a88b12e13f57e10069a795c4b6998865 /src/test/test-calendarspec.c
parentnetwork: update interface name stored in various network engines (diff)
parentnetworkd: minor refactoring (diff)
downloadsystemd-e18f21e34924d02dd7c330a644149d89fcc38042.tar.xz
systemd-e18f21e34924d02dd7c330a644149d89fcc38042.zip
Merge pull request #20109 from keszybz/timestamp-macros
Add macros that define scratch buffer internally for timestamp/timespan formatting
Diffstat (limited to 'src/test/test-calendarspec.c')
-rw-r--r--src/test/test-calendarspec.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c
index 4f1d0f64d5..5d680f9b9a 100644
--- a/src/test/test-calendarspec.c
+++ b/src/test/test-calendarspec.c
@@ -10,7 +10,6 @@ static void _test_one(int line, const char *input, const char *output) {
CalendarSpec *c;
_cleanup_free_ char *p = NULL, *q = NULL;
usec_t u;
- char buf[FORMAT_TIMESTAMP_MAX];
int r;
assert_se(calendar_spec_from_string(input, &c) >= 0);
@@ -22,7 +21,7 @@ static void _test_one(int line, const char *input, const char *output) {
u = now(CLOCK_REALTIME);
r = calendar_spec_next_usec(c, u, &u);
- log_info("Next: %s", r < 0 ? strerror_safe(r) : format_timestamp(buf, sizeof buf, u));
+ log_info("Next: %s", r < 0 ? strerror_safe(r) : FORMAT_TIMESTAMP(u));
calendar_spec_free(c);
assert_se(calendar_spec_from_string(p, &c) >= 0);
@@ -37,7 +36,6 @@ static void _test_next(int line, const char *input, const char *new_tz, usec_t a
CalendarSpec *c;
usec_t u;
char *old_tz;
- char buf[FORMAT_TIMESTAMP_MAX];
int r;
old_tz = getenv("TZ");
@@ -56,7 +54,7 @@ static void _test_next(int line, const char *input, const char *new_tz, usec_t a
u = after;
r = calendar_spec_next_usec(c, after, &u);
- log_info("At: %s", r < 0 ? strerror_safe(r) : format_timestamp_style(buf, sizeof buf, u, TIMESTAMP_US));
+ log_info("At: %s", r < 0 ? strerror_safe(r) : FORMAT_TIMESTAMP_STYLE(u, TIMESTAMP_US));
if (expect != USEC_INFINITY)
assert_se(r >= 0 && u == expect);
else
@@ -93,18 +91,17 @@ static void test_timestamp(void) {
static void test_hourly_bug_4031(void) {
CalendarSpec *c;
usec_t n, u, w;
- char buf[FORMAT_TIMESTAMP_MAX], zaf[FORMAT_TIMESTAMP_MAX];
int r;
assert_se(calendar_spec_from_string("hourly", &c) >= 0);
n = now(CLOCK_REALTIME);
assert_se((r = calendar_spec_next_usec(c, n, &u)) >= 0);
- log_info("Now: %s (%"PRIu64")", format_timestamp_style(buf, sizeof buf, n, TIMESTAMP_US), n);
- log_info("Next hourly: %s (%"PRIu64")", r < 0 ? strerror_safe(r) : format_timestamp_style(buf, sizeof buf, u, TIMESTAMP_US), u);
+ log_info("Now: %s (%"PRIu64")", FORMAT_TIMESTAMP_STYLE(n, TIMESTAMP_US), n);
+ log_info("Next hourly: %s (%"PRIu64")", r < 0 ? strerror_safe(r) : FORMAT_TIMESTAMP_STYLE(u, TIMESTAMP_US), u);
assert_se((r = calendar_spec_next_usec(c, u, &w)) >= 0);
- log_info("Next hourly: %s (%"PRIu64")", r < 0 ? strerror_safe(r) : format_timestamp_style(zaf, sizeof zaf, w, TIMESTAMP_US), w);
+ log_info("Next hourly: %s (%"PRIu64")", r < 0 ? strerror_safe(r) : FORMAT_TIMESTAMP_STYLE(w, TIMESTAMP_US), w);
assert_se(n < u);
assert_se(u <= n + USEC_PER_HOUR);