]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: cope with uutils coreutils flag parsing for date command
authorNick Rosbrook <enr0n@ubuntu.com>
Mon, 19 Jan 2026 21:09:52 +0000 (16:09 -0500)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 27 Feb 2026 20:05:57 +0000 (20:05 +0000)
With GNU coreutils, one can pass an argument to the "set" flag like:

 date -s "-3 days"

With uutils coreutils, that gives an error:

 error: unexpected argument '-3' found
    tip: to pass '-3' as a value, use '-- -3'

That's a bug (https://github.com/uutils/coreutils/issues/9679), but both
implementations accept --set="-3 days" just fine, so use that instead.

(cherry picked from commit 9dcfd6e8fe080f959c363e6d896848faeb1b8156)
(cherry picked from commit a45dad1aa5320443a520a47c8c9dd89703b73d2f)
(cherry picked from commit b9e718293142a2b54d801835c6b43b4a88fab193)

test/units/TEST-53-TIMER.RandomizedDelaySec-reload.sh
test/units/TEST-53-TIMER.issue-16347.sh
test/units/TEST-53-TIMER.restart-trigger.sh

index e9b9d4feeeddf217fdac0d83542b744996087b8b..2baa47c028103cd795b2f515568d1428df13ca55 100755 (executable)
@@ -84,7 +84,7 @@ check_elapse_timestamp
 # elapse timestamp (this goes through a slightly different codepath that actually contained the original
 # issue).
 : "Next elapse timestamp after time jump"
-date -"tomorrow 00:10"
+date --set="tomorrow 00:10"
 check_elapse_timestamp
 
 : "Next elapse timestamp after daemon-reload"
index 8b266145cd0df6031e96f80b57fa32fb4c40727e..b4867872dad482e412572baa02124e9fab4e5152 100755 (executable)
@@ -4,8 +4,8 @@ set -eux
 set -o pipefail
 
 # Reset host date to current time, 3 days in the past.
-date -"-3 days"
-trap 'date -"+3 days"' EXIT
+date --set="-3 days"
+trap 'date --set="+3 days"' EXIT
 
 # Run a timer for every 15 minutes.
 systemd-run --unit test-timer --on-calendar "*:0/15:0" true
index 057f379ddc56276726dee0ef2f017d78eb5cc4d2..c10fd9c2ef1b6ac88c66499a6442e20f0cd60462 100755 (executable)
@@ -37,8 +37,8 @@ JOURNAL_TS="$(date "+%s")"
 systemctl restart "$UNIT_NAME.timer"
 systemctl status "$UNIT_NAME.timer"
 
-date -'+2 hours'
-trap 'date -"-2 hours"' EXIT
+date --set='+2 hours'
+trap 'date --set="-2 hours"' EXIT
 sleep 1
 systemctl status "$UNIT_NAME.timer"
 assert_eq "$(journalctl -q -p info --since="@$JOURNAL_TS" --unit="$UNIT_NAME" --grep="$TEST_MESSAGE" | wc -l)" "1"