systemd/1231-test-time-util-add-test-cases-to-invalidate-show-and.patch
Jan Macku 2169d2c18c systemd-252-57
Resolves: RHEL-108555,RHEL-108568,RHEL-108576,RHEL-108584,RHEL-108596,RHEL-108598,RHEL-109096,RHEL-109488,RHEL-111065,RHEL-31756,RHEL-50103
2025-09-16 08:59:46 +02:00

32 lines
1.3 KiB
Diff

From e8f66d4c6570765fd60111ec7e3b5dbdb7d14c69 Mon Sep 17 00:00:00 2001
From: Mike Yuan <me@yhndnzj.com>
Date: Tue, 14 Mar 2023 07:16:18 +0800
Subject: [PATCH] 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
(cherry picked from commit 165655cb1de2e79d954d9165459143140e52c53b)
Related: RHEL-109488
---
src/test/test-time-util.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/test/test-time-util.c b/src/test/test-time-util.c
index ee861135c2..379f55ff2f 100644
--- a/src/test/test-time-util.c
+++ b/src/test/test-time-util.c
@@ -580,6 +580,11 @@ static void test_parse_timestamp_one(const char *str, usec_t max_diff, usec_t ex
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);