test-time-util: add test cases to invalidate "show" and "cancel"

Ensure that systemctl reboot --when=show and --when=cancel will not result in ambiguities
This commit is contained in:
Mike Yuan
2023-03-14 19:21:11 +08:00
parent 1433e1f998
commit 165655cb1d
+5
View File
@@ -663,6 +663,11 @@ static bool timezone_equal(usec_t today, usec_t target) {
static void test_parse_timestamp_impl(const char *tz) {
usec_t today, now_usec;
/* Invalid: Ensure that systemctl reboot --when=show and --when=cancel
* will not result in ambiguities */
assert_se(parse_timestamp("show", NULL) == -EINVAL);
assert_se(parse_timestamp("cancel", NULL) == -EINVAL);
/* UTC */
test_parse_timestamp_one("Thu 1970-01-01 00:01 UTC", 0, USEC_PER_MINUTE);
test_parse_timestamp_one("Thu 1970-01-01 00:00:01 UTC", 0, USEC_PER_SEC);