From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zimbra.cs.ucla.edu (zimbra.cs.ucla.edu [131.179.128.68]) by sourceware.org (Postfix) with ESMTPS id C9BAC389042B for ; Wed, 27 Jan 2021 18:42:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C9BAC389042B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cs.ucla.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eggert@cs.ucla.edu Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 382ED1600FA; Wed, 27 Jan 2021 10:42:39 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id wbA_DNKXhLLj; Wed, 27 Jan 2021 10:42:38 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7A0191600FC; Wed, 27 Jan 2021 10:42:38 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ONrez0_oO-hJ; Wed, 27 Jan 2021 10:42:38 -0800 (PST) Received: from [192.168.1.9] (cpe-23-243-218-95.socal.res.rr.com [23.243.218.95]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E9FBD1600FA; Wed, 27 Jan 2021 10:42:37 -0800 (PST) To: Lukasz Majewski , Joseph Myers , Adhemerval Zanella , Florian Weimer Cc: Alistair Francis , Arnd Bergmann , Alistair Francis , GNU C Library , Carlos O'Donell , Florian Weimer , Zack Weinberg References: <20210127124234.19540-1-lukma@denx.de> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: [PATCH v2] tst: Provide test for difftime Message-ID: <82dc5aa1-f358-abf0-b69d-79ace62772fa@cs.ucla.edu> Date: Wed, 27 Jan 2021 10:42:37 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210127124234.19540-1-lukma@denx.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jan 2021 18:42:40 -0000 On 1/27/21 4:42 AM, Lukasz Majewski wrote: > This change adds new test to assess difftime's functionality by > adding some arbitrary offsets to current time_t value (read via > time). That would make tests irreproducible. Why is that helpful for difftime?=20 I suggest using only reproducible tests; this should make the code=20 simpler anyway. > +static void > +test_difftime_helper (time_t start, time_t t1, time_t t0, double exp_v= al) The signature should be simpler: static void test_difftime_helper (long long t1, long long t0, double exp_val) And test_difftime_helper can test whether its arguments fit into time_t=20 with code like this: time_t u1; if (__builtin_add_overflow (t1, 0, &u1)) return; That way, you can omit the 'sizeof (time_t) > 4' test, which is a bit=20 dubious anyway as it wouldn't work on hypothetical hosts where char is=20 wider than 8 bits. You can do this sort of thing in all the time_t=20 tests, to omit all uses of sizeof (time_t).