mailing list of musl libc
 help / color / mirror / code / Atom feed
* Re: date-debug test failure with musl
       [not found] <87929f3b-ce4d-cd2d-0baf-dfae49fee58e@nh2.me>
@ 2019-05-13 18:23 ` Rich Felker
  2019-05-13 22:49   ` Assaf Gordon
  0 siblings, 1 reply; 6+ messages in thread
From: Rich Felker @ 2019-05-13 18:23 UTC (permalink / raw)
  To: Niklas Hambüchen; +Cc: coreutils, mjbauer95, musl

On Mon, May 13, 2019 at 05:02:48AM +0200, Niklas Hambüchen wrote:
> Dear coreutils maintainers,
> 
> when compiling coreutils commit 6e97d36 against musl v1.1.22 on Ubuntu, I get a test failure and differing output than when using glibc.
> 
> Running `src/date --debug -d 'TZ="America/Edmonton" 2006-04-02 02:30:00'` with each:
> 
> With glibc it prints:
> 
> date:        normalized time: '(Y-M-D) 2006-04-02 03:30:00'
> 
> With musl it prints:
> 
> date:        normalized time: '(Y-M-D) 2006-04-02 01:30:00'`
> 
> This difference results in tests/misc/date-debug to fail.
> 
> What's happening here? Is there a bug in musl, or some quirks going on?
> Any insight would be appreciated.

The requested time is right in the middle of the "leap forward" DST
transition; no such time exists. As I understand, it's been requested
from mktime with tm_isdst<0 to "cause mktime() to attempt to determine
whether Daylight Savings Time is in effect for the specified time."
The standard provides no definition for "attempt" or what should
happen if such an attempt fails due to ambiguity or nonexistence, and
I don't see any fundamental reason to prefer the glibc or musl result
here. One is more natural working backwards from 3am; the other is
more natural working forwards from 1:59:59am.

As long as coreutils' date is producing the desired "invalid" error
either way, which it seems to be, I think it's a mistake that the
debug output for "normalized time" is being compared as part of the
test assertion. Only the result should matter, not the path by which
it's reached.

Rich


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: date-debug test failure with musl
  2019-05-13 18:23 ` date-debug test failure with musl Rich Felker
@ 2019-05-13 22:49   ` Assaf Gordon
       [not found]     ` <98551500-3d6a-d123-d1d4-a47a0c6619e1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Assaf Gordon @ 2019-05-13 22:49 UTC (permalink / raw)
  To: musl, Rich Felker, Niklas Hambüchen; +Cc: coreutils, mjbauer95

[-- Attachment #1: Type: text/plain, Size: 817 bytes --]

Hello,

On 2019-05-13 12:23 p.m., Rich Felker wrote:
> On Mon, May 13, 2019 at 05:02:48AM +0200, Niklas Hambüchen wrote:
>> Dear coreutils maintainers,
>>
>> when compiling coreutils commit 6e97d36 against musl v1.1.22 on Ubuntu, I get a test failure and differing output than when using glibc.

Thank you for the report,

[...]

> As long as coreutils' date is producing the desired "invalid" error
> either way, which it seems to be, I think it's a mistake that the
> debug output for "normalized time" is being compared as part of the
> test assertion. Only the result should matter, not the path by which
> it's reached.

And thank you Rich for the quick analysis.

The attached patch implements your suggestion.

It works on glibc, please give it a test on your Ubuntu/musl-1.1.22 system.

regards,
  - assaf



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-tests-avoid-false-positive-in-date-debug-test.patch --]
[-- Type: text/x-patch; name="0001-tests-avoid-false-positive-in-date-debug-test.patch", Size: 2148 bytes --]

From 402c3646e19c199130e7a6db5238cf5908e51fb8 Mon Sep 17 00:00:00 2001
From: Assaf Gordon <assafgordon@gmail.com>
Date: Mon, 13 May 2019 16:37:40 -0600
Subject: [PATCH] tests: avoid false-positive in date-debug test
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When debugging an invalid date due to DST switching, the intermediate
'normalized time' should not be checked - its value can differ between
systems (e.g. glibc vs musl).

Reported by Niklas Hambüchen in
https://lists.gnu.org/r/coreutils/2019-05/msg00031.html
Analyzed by Rich Felker in
https://lists.gnu.org/r/coreutils/2019-05/msg00039.html

* tests/misc/date-debug.sh: Replace the exact normalized time
with 'XX:XX:XX' so different values would not trigger test failure.
---
 tests/misc/date-debug.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tests/misc/date-debug.sh b/tests/misc/date-debug.sh
index aa47f1abb..2ce6f4ce8 100755
--- a/tests/misc/date-debug.sh
+++ b/tests/misc/date-debug.sh
@@ -71,7 +71,7 @@ date: input timezone: TZ="America/Edmonton" in date string
 date: using specified time as starting value: '02:30:00'
 date: error: invalid date/time value:
 date:     user provided time: '(Y-M-D) 2006-04-02 02:30:00'
-date:        normalized time: '(Y-M-D) 2006-04-02 03:30:00'
+date:        normalized time: '(Y-M-D) 2006-04-02 XX:XX:XX'
 date:                                             --
 date:      possible reasons:
 date:        non-existing due to daylight-saving time;
@@ -81,7 +81,14 @@ date: invalid date 'TZ="America/Edmonton" 2006-04-02 02:30:00'
 EOF
 
 # date should return 1 (error) for invalid date
-returns_ 1 date --debug -d "$in2" >out2 2>&1 || fail=1
+returns_ 1 date --debug -d "$in2" >out2-t 2>&1 || fail=1
+
+# The output line of "normalized time" can differ between systems
+# (e.g. glibc vs musl) and should not be checked.
+# See: https://lists.gnu.org/archive/html/coreutils/2019-05/msg00039.html
+sed '/normalized time:/s/ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/ XX:XX:XX/' \
+    out2-t > out2 || framework_failure_
+
 compare exp2 out2 || fail=1
 
 ##
-- 
2.11.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [musl] Re: date-debug test failure with musl
       [not found]     ` <98551500-3d6a-d123-d1d4-a47a0c6619e1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2019-05-14 13:38       ` Niklas Hambüchen
       [not found]         ` <26965951-d4f2-ae57-2b7e-b307fc39d60f-7wQd5C9ZzNw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Niklas Hambüchen @ 2019-05-14 13:38 UTC (permalink / raw)
  To: Assaf Gordon, musl-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8
  Cc: Rich Felker, mjbauer95-Re5JQEeQqe8AvxtiuMwx3w, coreutils-mXXj517/zsQ

Hello Assaf,

thank you, your patch works well for me.

I've tested it on Ubuntu and NixOS, with both glibc and musl.

Best,
Niklas



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [musl] Re: date-debug test failure with musl
       [not found]         ` <26965951-d4f2-ae57-2b7e-b307fc39d60f-7wQd5C9ZzNw@public.gmane.org>
@ 2019-05-16 17:52           ` Niklas Hambüchen
  2019-06-13  3:35             ` Assaf Gordon
  0 siblings, 1 reply; 6+ messages in thread
From: Niklas Hambüchen @ 2019-05-16 17:52 UTC (permalink / raw)
  To: Assaf Gordon
  Cc: mjbauer95-Re5JQEeQqe8AvxtiuMwx3w, Rich Felker,
	musl-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8, coreutils-mXXj517/zsQ

Hey Assaf,

will you submit your patch for inclusion, given that it works well?

Best,
Niklas



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: date-debug test failure with musl
  2019-05-16 17:52           ` Niklas Hambüchen
@ 2019-06-13  3:35             ` Assaf Gordon
  2019-06-13 12:58               ` Niklas Hambüchen
  0 siblings, 1 reply; 6+ messages in thread
From: Assaf Gordon @ 2019-06-13  3:35 UTC (permalink / raw)
  To: Niklas Hambüchen; +Cc: musl, Rich Felker, coreutils, mjbauer95

Hello,

On 2019-05-16 11:52 a.m., Niklas Hambüchen wrote:
> 
> will you submit your patch for inclusion, given that it works well?

pushed here:
https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=0251229bfd9617e8a35cf9dd7d338d63fff74a0c

-assaf


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: date-debug test failure with musl
  2019-06-13  3:35             ` Assaf Gordon
@ 2019-06-13 12:58               ` Niklas Hambüchen
  0 siblings, 0 replies; 6+ messages in thread
From: Niklas Hambüchen @ 2019-06-13 12:58 UTC (permalink / raw)
  To: Assaf Gordon; +Cc: musl, Rich Felker, coreutils, mjbauer95

On 13/06/2019 5:35 AM, Assaf Gordon wrote:
> pushed here:
> https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=0251229bfd9617e8a35cf9dd7d338d63fff74a0c

Awesome, thanks!


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-06-13 12:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87929f3b-ce4d-cd2d-0baf-dfae49fee58e@nh2.me>
2019-05-13 18:23 ` date-debug test failure with musl Rich Felker
2019-05-13 22:49   ` Assaf Gordon
     [not found]     ` <98551500-3d6a-d123-d1d4-a47a0c6619e1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-05-14 13:38       ` [musl] " Niklas Hambüchen
     [not found]         ` <26965951-d4f2-ae57-2b7e-b307fc39d60f-7wQd5C9ZzNw@public.gmane.org>
2019-05-16 17:52           ` Niklas Hambüchen
2019-06-13  3:35             ` Assaf Gordon
2019-06-13 12:58               ` Niklas Hambüchen

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).