From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server28.superhosting.bg (server28.superhosting.bg [217.174.156.11]) by sourceware.org (Postfix) with ESMTPS id 0D08C385DAA3 for ; Mon, 11 Apr 2022 17:27:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0D08C385DAA3 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dinux.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dinux.eu DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dinux.eu; s=default; h=In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=f4E4aUtGjbDSvGadVjXvwkQWGgm3AyAN8YWgQT2HkEU=; b=TiD8SO4jWNA4vZ7m+niuik9Wmf U7DsDDI9nhTRyzE32+UGFQCM5dgISH3QXUwaB8+O6MB9b5vczZTDVi6uL1155g7Rzey3KNBMlVhZz wcPR8VyAEgagQbVzZFMFYTGHS6SEoKl/3EM+Svu5O31QwzGzcJQG3Z1bztNBxjU7b394jJEKLvEx+ JC3L8kkZrJm8SNGRAm4eTwBDsVoPPlUO3SSvLtqxrYgAH5u1897v5zfwMYdWjSdMVuPshC3PjO5BO exbmADwnDrl27nLM0/24rS6oa+MGP8oUin5zTJXhLB48/ZlBtVQ0E8b1Ms7YLcwaagJsdcWxHFjcw ep/zWNcg==; Received: from [95.87.234.74] (port=49284 helo=localhost) by server28.superhosting.bg with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ndxop-00025j-Mg; Mon, 11 Apr 2022 20:27:18 +0300 Date: Mon, 11 Apr 2022 20:27:15 +0300 From: Dimitar Dimitrov To: jdoubleu Cc: newlib@sourceware.org Subject: Re: [PATCH] add tests for tzset(3) Message-ID: References: <569f6ec3-6bc8-8170-c1fb-ed946020e258@jdoubleu.de> <836b0ac6-5e3a-03ca-d696-16adda6554a8@jdoubleu.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <836b0ac6-5e3a-03ca-d696-16adda6554a8@jdoubleu.de> X-OutGoing-Spam-Status: No, score=-2.9 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server28.superhosting.bg X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dinux.eu X-Get-Message-Sender-Via: server28.superhosting.bg: authenticated_id: dimitar@dinux.eu X-Authenticated-Sender: server28.superhosting.bg: dimitar@dinux.eu X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2022 17:27:24 -0000 On Mon, Apr 11, 2022 at 01:17:16PM +0200, jdoubleu wrote: > Hi, > > looks like I'm running the testsuite against glibc and not newlib (for > target x86_64-pc-linux-gnu). I'm not even sure whether there's a backend for > linux. > > I'm currently trying to run only the tzset code against the test vectors > (like Brian Inglis did[1]). > > At least it show, that the newlib implementation differs from glibc. Maybe > the test case is flawed and it should indeed fail. > > > 6:20:12 is the timezone string of the previous test case, whose tzset > > call was successful. Looking at the current code, this is expected > > behaviour. > > Okay. Looks like the condition[2] fails. The question is, which part of it > does? I believe it is the ('>' != tzenv[n]) check that fails, because the maximum parsed string limit of 10 has been reached and n=10. > > I've appended a patch, which prints all variables when the condition fails. > Could you please apply the patch and then recompile and re-run the tests > again? Here is the result for arm-none-eabi: parsing name: tzenv="+0123456789ABCDEF>3:33:33", res=1, n=10, tzenv[n] = 9 Assertion failed! Expected 1647906533 to equal 1647916532. winter time, timezone = "<+0123456789ABCDEF>3:33:33" I assume you no longer need assembly output from compiler? > > I've previously noticed something with the sscanf format[3]. > > > Perhaps TZ should be reset to UTC before the bail out? > > I don't think the implementation should fall back to UTC whenever parsing > failed. It apparently doesn't in glibc. I'm not sure if the behavior is > specified somewhere. The tzset manual page says that UTC is used if TZ cannot be parsed: https://man7.org/linux/man-pages/man3/tzset.3.html > > Maybe resetting it before each test case is a good idea, though. That makes > it clearer, why the test case failed. > > > With that chunk removed, as shown below: > > {"3:33:33", IN_SECONDS(3, 33, 33), NO_TIME}, // truncates the name (17 + 1) > > I still get: > > Assertion failed! Expected 1647906533 to equal 1647916532. winter time, timezone = "3:33:33" > > My bad; "3:33:33" isn't a valid timezone string. It has to be prefixed by a > name e.g. "MESZ" or "<+00>", as you tried. That explains why it is also > failing. > > > Thanks for your effort so far! > > > [1]: https://sourceware.org/pipermail/newlib/2022/019529.html > [2]: https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/time/tzset_r.c;h=9cb30b188f989f65ec9eb6417f5d74020f8c72e9;hb=HEAD#l57 > [3]: https://sourceware.org/pipermail/newlib/2022/019535.html > > > Cheers > --- > 🙎🏻‍♂️ jdoubleu > From 8c698dc63f765d4a5b3a49a25850c1738279d68d Mon Sep 17 00:00:00 2001 > From: jdoubleu > Date: Mon, 11 Apr 2022 13:10:38 +0200 > Subject: [PATCH] debug print condition values of tz string name parsing > > --- > newlib/libc/time/tzset_r.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/newlib/libc/time/tzset_r.c b/newlib/libc/time/tzset_r.c > index 9cb30b188..e20a32a62 100644 > --- a/newlib/libc/time/tzset_r.c > +++ b/newlib/libc/time/tzset_r.c > @@ -54,9 +54,11 @@ _tzset_unlocked_r (struct _reent *reent_ptr) > ++tzenv; > > /* quit if no items, too few or too many chars, or no close quote '>' */ > - if (sscanf (tzenv, "%10[-+0-9A-Za-z]%n", __tzname_std, &n) <= 0 > - || n < TZNAME_MIN || TZNAME_MAX < n || '>' != tzenv[n]) > + int res = sscanf (tzenv, "%10[-+0-9A-Za-z]%n", __tzname_std, &n); > + if (res <= 0 || n < TZNAME_MIN || TZNAME_MAX < n || '>' != tzenv[n]) { > + printf("parsing name: tzenv=\"%s\", res=%d, n=%d, tzenv[n] = %c\n", tzenv, res, n, tzenv[n]); > return; > + } > > ++tzenv; /* bump for close quote '>' */ > } > -- > 2.35.1 >