ref: addf2d55bf9bbf090ea26173ac03cfa725bb73cd
parent: 96bf1d3ebd2f9a1051a60e880fb158ea4341b0bc
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Oct 6 12:14:29 EDT 2024
test/zones.rc: Fix instability, read current time once. The test just called date twice assuming they all execute in the same second. This causes false positives with the following errors (usually just 1 second difference): term% while(){./zones.rc} /adm/timezone/US_Arizona Sun, 06 Oct 2024 09:09:12 -0700 1728230953 1728230952 are not equal /adm/timezone/Uruguay Sun, 06 Oct 2024 14:09:17 -0200 1728230958 1728230957 are not equal /adm/timezone/Japan Mon, 07 Oct 2024 01:09:19 +0900 1728230960 1728230959 are not equal /adm/timezone/Iran Sun, 06 Oct 2024 19:39:25 +0330 1728230966 1728230965 are not equal /adm/timezone/Australia_West Mon, 07 Oct 2024 00:09:27 +0800 1728230968 1728230967 are not equal /adm/timezone/US_Eastern Sun, 06 Oct 2024 12:09:29 -0400 1728230970 1728230969 are not equal /adm/timezone/GMT Sun, 06 Oct 2024 16:09:31 +0000 1728230972 1728230971 are not equal /adm/timezone/local Sun, 06 Oct 2024 18:09:34 +0200 1728230975 1728230974 are not equal /adm/timezone/Mexico_BajaSur Sun, 06 Oct 2024 09:09:36 -0700 1728230977 1728230976 are not equal The fix is to get the current time once, with date -n and then pass that to date to format the time and then concert back and compare.
--- a/sys/src/cmd/test/zones.rc
+++ b/sys/src/cmd/test/zones.rc
@@ -6,8 +6,8 @@
for(f in /adm/timezone/*){
if(! ~ $f /adm/timezone/README){
cat $f >/env/timezone
- tm=`{../$O.date -f'WW, DD MMM YYYY hh:mm:ss Z'}
x=`{../$O.date -n}
+ tm=`{../$O.date -f'WW, DD MMM YYYY hh:mm:ss Z' $x}
y=`{../$O.seconds $"tm}
if(! ~ $x $y){
echo $f $tm $x $y are not equal