summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-09-29 07:31:14 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-09-29 11:09:39 -0400
commitb1d6dcf5a5c5aa02843c026dede0638f77798cb4 (patch)
tree6065b8eedce06acb651c6ad2d378749049951fcb /src/test
parentee26bcc0387f6eda83878eb85a08c01ee0d82c44 (diff)
Do not format USEC_INFINITY as NULL
systemctl would print 'CPUQuotaPerSecUSec=(null)' for no limit. This does not look right. Since USEC_INFINITY is one of the valid values, format_timespan() could return NULL, and we should wrap every use of it in strna() or similar. But most callers didn't do that, and it seems more robust to return a string ("infinity") that makes sense most of the time, even if in some places the result will not be grammatically correct.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-time.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/test-time.c b/src/test/test-time.c
index 87e7ae742a..8cfc4cc4fe 100644
--- a/src/test/test-time.c
+++ b/src/test/test-time.c
@@ -43,12 +43,18 @@ static void test_parse_sec(void) {
assert_se(u == 2500 * USEC_PER_MSEC);
assert_se(parse_sec(".7", &u) >= 0);
assert_se(u == 700 * USEC_PER_MSEC);
+ assert_se(parse_sec("infinity", &u) >= 0);
+ assert_se(u == USEC_INFINITY);
+ assert_se(parse_sec(" infinity ", &u) >= 0);
+ assert_se(u == USEC_INFINITY);
assert_se(parse_sec(" xyz ", &u) < 0);
assert_se(parse_sec("", &u) < 0);
assert_se(parse_sec(" . ", &u) < 0);
assert_se(parse_sec(" 5. ", &u) < 0);
assert_se(parse_sec(".s ", &u) < 0);
+ assert_se(parse_sec(" infinity .7", &u) < 0);
+ assert_se(parse_sec(".3 infinity", &u) < 0);
}
static void test_parse_nsec(void) {
@@ -125,6 +131,7 @@ static void test_format_timespan(usec_t accuracy) {
test_format_timespan_one(986087, accuracy);
test_format_timespan_one(500 * USEC_PER_MSEC, accuracy);
test_format_timespan_one(9*USEC_PER_YEAR/5 - 23, accuracy);
+ test_format_timespan_one(USEC_INFINITY, accuracy);
}
static void test_timezone_is_valid(void) {