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 6F55B3858C56 for ; Sun, 10 Apr 2022 21:00:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6F55B3858C56 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=KQXHVE9DadMeKU8rRjDF2Qa2aHCtqkb8nu5Im4OC1+I=; b=INm6uxsM4A+Wi1YbsUt267V6b8 tdtimGVIConBSCXiBRwIhcmNSvtwUtkCDZ9q0lP91sdoPdeWDbXtKYOqdwiXXKuBJjVTGnXNvqyZ5 Mdg0+AjMpcE4y24trc6KFh2Gw8DaSzKDTuYv4cMPoaSReZGXifjP5kd5IuT1CaFmrcxBt5bd9n0Hx Jvt0OJKEIBwRYo7LKHy/AFbV81rOX6nTV3b8iZk4+dYMz8rBhN96PlE1ggjNHsX7syHwMAY+Yj9X0 dPg0Kh65/86oQm+1cqGoV7Js37SvK0tey4RjI7uJjqI1D+yc/h3P00rH0pGDaKdASBD/wSeFeIXhJ 8xuq2Uow==; Received: from [95.87.234.74] (port=49248 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 1ndefZ-0000m4-BD; Mon, 11 Apr 2022 00:00:27 +0300 Date: Mon, 11 Apr 2022 00:00:23 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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=-3.9 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: Sun, 10 Apr 2022 21:00:33 -0000 On Sun, Apr 10, 2022 at 07:55:56PM +0200, jdoubleu wrote: > Hi Dimitar, > > On 4/10/2022 10:43 AM, Dimitar Dimitrov wrote: > > I get the following failure on pru-none-elf and arm-none-eabi targets: > > that is interesting! I just checked and they are still passing on > x86_64-pc-linux-gnu. Which begs the question: What is the difference to your > environment/target platform? Here is how I build a cross toolchain for arm: https://github.com/dinuxbg/gnupru/blob/master/testing/manual-build-arm.sh Then I build and execute the test case using qemu: $ ./arm-opt/bin/arm-none-eabi-gcc -O2 newlib/newlib/testsuite/newlib.time/tzset.c -o tzset-arm.elf $ qemu-arm tzset-arm.elf Assertion failed! Expected 1647906533 to equal 1647916532. winter time, timezone = "3:33:33" For PRU target I'm running a daily regression test for Newlib, using the GNU simulator: https://github.com/dinuxbg/gnupru/blob/master/testing/buildbot-pru.sh > > Are you using any additional compilation flags? Have you enabled/disabled > optimizations? Have you enabled the nano I/O API[1]? > What compiler (and version) are you using? How/Where are you running the > tests? These are the newlib configure options I use for arm: --target=arm-none-eabi --enable-newlib-io-long-long --enable-newlib-io-long-double --enable-newlib-io-c99-formats I use GCC 12 from GIT master branch for both PRU and ARM cross toolchains. > > > [..] timezone = "<+0123456789ABCDEF>3:33:33" > > The given test case aims to check for tzset's parsing behavior when the name > (inside the angle brackets) exceeds the TZNAME_MAX var, i.e. is too long to > be fully stored. The default behavior is to truncate the name and ignore all > remaining chars[2]. The time should still be parsed. > > > Assertion failed! Expected 1647906533 to equal 1647916532. > > Now, the interesting part is, that the diff is 9,999 seconds. The time is > off by 6 hours, 20 minutes and 12 seconds. That is 2 hours, 46 minutes and > 38 seconds too far in the future. I am not sure where this is coming from. 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. Perhaps TZ should be reset to UTC before the bail out? /* 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]) { + _timezone = 0; + _daylight = 0; + _tzname[0] = "GMT"; + _tzname[1] = "GMT"; + free(prev_tzenv); + prev_tzenv = NULL; return; } > > Neither does it look like it bailed early[3], because it couldn't parse the > name. > > Please try and remove the "<+0123456789ABCDEF>" part from the string in the > tests[4] and re-run the tests. 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" Test passes with the following modifcation: {"<+00>3:33:33", IN_SECONDS(3, 33, 33), NO_TIME}, // truncates the name (17 + 1) > > Could you maybe also post the assembly listing and intermediate output of > the compiler? If you're using gcc, just (re)configure newlib and rebuild > libc: > > CFLAGS=-save-temps=obj ../newlib/configure > make clean # get rid of stamp files > make > > then copy and attach the following files: > > libc/time/libc_a-tzset_r.i > libc/time/libc_a-tzset_r.s Sure. Give me a day or two to spin the builds. > > > [1]: https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/README;h=97890b9d20ca0ac9f206d7a2334d55a3d7052289;hb=HEAD#l403 > [2]: https://sourceware.org/pipermail/newlib/2022/019535.html > [3]: https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/time/tzset_r.c;h=9cb30b188f989f65ec9eb6417f5d74020f8c72e9;hb=HEAD#l57 > [4]: https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/testsuite/newlib.time/tzset.c;h=0e5b196c629bcbecae6148c09bbeba82079c5367;hb=HEAD#l96 > > > Cheers > --- > 🙎🏻‍♂️ jdoubleu