summaryrefslogtreecommitdiff
path: root/src/test/test-time-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-02 10:22:10 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-02 10:41:26 +0200
commitf1880a4b027c27f13f3d9a7f32f8d4adbbacd369 (patch)
tree9565bb3009c5763b89b95b173ba90644d958159c /src/test/test-time-util.c
parent5fd8d5be118c6b52880e99f38f7f5d8be9cb0f23 (diff)
downloadsystemd-f1880a4b027c27f13f3d9a7f32f8d4adbbacd369.tar.gz
test-time-util: print names of test functions
This makes it easier to find the right spot in the long output.
Diffstat (limited to 'src/test/test-time-util.c')
-rw-r--r--src/test/test-time-util.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/test/test-time-util.c b/src/test/test-time-util.c
index 00d583182d..f2daf401c6 100644
--- a/src/test/test-time-util.c
+++ b/src/test/test-time-util.c
@@ -13,6 +13,8 @@
static void test_parse_sec(void) {
usec_t u;
+ log_info("/* %s */", __func__);
+
assert_se(parse_sec("5s", &u) >= 0);
assert_se(u == 5 * USEC_PER_SEC);
assert_se(parse_sec("5s500ms", &u) >= 0);
@@ -52,6 +54,8 @@ static void test_parse_sec(void) {
static void test_parse_sec_fix_0(void) {
usec_t u;
+ log_info("/* %s */", __func__);
+
assert_se(parse_sec_fix_0("5s", &u) >= 0);
assert_se(u == 5 * USEC_PER_SEC);
assert_se(parse_sec_fix_0("0s", &u) >= 0);
@@ -65,6 +69,8 @@ static void test_parse_sec_fix_0(void) {
static void test_parse_time(void) {
usec_t u;
+ log_info("/* %s */", __func__);
+
assert_se(parse_time("5", &u, 1) >= 0);
assert_se(u == 5);
@@ -87,6 +93,8 @@ static void test_parse_time(void) {
static void test_parse_nsec(void) {
nsec_t u;
+ log_info("/* %s */", __func__);
+
assert_se(parse_nsec("5s", &u) >= 0);
assert_se(u == 5 * NSEC_PER_SEC);
assert_se(parse_nsec("5s500ms", &u) >= 0);
@@ -130,7 +138,6 @@ static void test_format_timespan_one(usec_t x, usec_t accuracy) {
log_info(" = <%s>", t);
assert_se(parse_sec(t, &y) >= 0);
-
log_info(" = "USEC_FMT, y);
if (accuracy <= 0)
@@ -140,6 +147,8 @@ static void test_format_timespan_one(usec_t x, usec_t accuracy) {
}
static void test_format_timespan(usec_t accuracy) {
+ log_info("/* %s accuracy="USEC_FMT" */", __func__, accuracy);
+
test_format_timespan_one(0, accuracy);
test_format_timespan_one(1, accuracy);
test_format_timespan_one(1*USEC_PER_SEC, accuracy);
@@ -166,6 +175,8 @@ static void test_format_timespan(usec_t accuracy) {
}
static void test_timezone_is_valid(void) {
+ log_info("/* %s */", __func__);
+
assert_se(timezone_is_valid("Europe/Berlin", LOG_ERR));
assert_se(timezone_is_valid("Australia/Sydney", LOG_ERR));
assert_se(!timezone_is_valid("Europe/Do not exist", LOG_ERR));
@@ -176,6 +187,8 @@ static void test_get_timezones(void) {
int r;
char **zone;
+ log_info("/* %s */", __func__);
+
r = get_timezones(&zones);
assert_se(r == 0);
@@ -184,6 +197,8 @@ static void test_get_timezones(void) {
}
static void test_usec_add(void) {
+ log_info("/* %s */", __func__);
+
assert_se(usec_add(0, 0) == 0);
assert_se(usec_add(1, 4) == 5);
assert_se(usec_add(USEC_INFINITY, 5) == USEC_INFINITY);
@@ -195,6 +210,8 @@ static void test_usec_add(void) {
}
static void test_usec_sub_unsigned(void) {
+ log_info("/* %s */", __func__);
+
assert_se(usec_sub_unsigned(0, 0) == 0);
assert_se(usec_sub_unsigned(0, 2) == 0);
assert_se(usec_sub_unsigned(0, USEC_INFINITY) == 0);
@@ -216,6 +233,8 @@ static void test_usec_sub_unsigned(void) {
}
static void test_usec_sub_signed(void) {
+ log_info("/* %s */", __func__);
+
assert_se(usec_sub_signed(0, 0) == 0);
assert_se(usec_sub_signed(4, 1) == 3);
assert_se(usec_sub_signed(4, 4) == 0);
@@ -230,6 +249,8 @@ 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++) {
char buf[MAX(FORMAT_TIMESTAMP_MAX, FORMAT_TIMESPAN_MAX)];
usec_t x, y;
@@ -278,6 +299,8 @@ static void test_format_timestamp_utc_one(usec_t val, const char *result) {
}
static void test_format_timestamp_utc(void) {
+ log_info("/* %s */", __func__);
+
test_format_timestamp_utc_one(0, NULL);
test_format_timestamp_utc_one(1, "Thu 1970-01-01 00:00:00 UTC");
test_format_timestamp_utc_one(USEC_PER_SEC, "Thu 1970-01-01 00:00:01 UTC");
@@ -297,6 +320,8 @@ static void test_dual_timestamp_deserialize(void) {
int r;
dual_timestamp t;
+ log_info("/* %s */", __func__);
+
r = dual_timestamp_deserialize("1234 5678", &t);
assert_se(r == 0);
assert_se(t.realtime == 1234);
@@ -344,6 +369,8 @@ static void assert_similar(usec_t a, usec_t b) {
static void test_usec_shift_clock(void) {
usec_t rt, mn, bt;
+ log_info("/* %s */", __func__);
+
rt = now(CLOCK_REALTIME);
mn = now(CLOCK_MONOTONIC);
bt = now(clock_boottime_or_monotonic());
@@ -369,6 +396,8 @@ static void test_usec_shift_clock(void) {
}
static void test_in_utc_timezone(void) {
+ log_info("/* %s */", __func__);
+
assert_se(setenv("TZ", ":UTC", 1) >= 0);
assert_se(in_utc_timezone());
assert_se(streq(tzname[0], "UTC"));