From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id AC8E4383F85C for ; Tue, 16 Feb 2021 20:11:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AC8E4383F85C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4DgBvd4pL1z1qs3v; Tue, 16 Feb 2021 21:11:57 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4DgBvd4cB0z1qqkj; Tue, 16 Feb 2021 21:11:57 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id mwJKGDG0Eg-V; Tue, 16 Feb 2021 21:11:56 +0100 (CET) X-Auth-Info: fF6heyy7qsxULoJFtQ6vDS8oJjLz3vVy2U2rkqzY+A0= Received: from jawa (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 16 Feb 2021 21:11:56 +0100 (CET) Date: Tue, 16 Feb 2021 21:11:55 +0100 From: Lukasz Majewski To: DJ Delorie Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v3 3/3] tst: Add test for clock_settime Message-ID: <20210216211155.4e691ad6@jawa> In-Reply-To: References: <20210210103710.1325-3-lukma@denx.de> Organization: denx.de X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/R9QtLq5KpcmqJ9f6TJNEEAQ"; protocol="application/pgp-signature" X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00, BIGNUM_EMAILS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no 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: Tue, 16 Feb 2021 20:12:01 -0000 --Sig_/R9QtLq5KpcmqJ9f6TJNEEAQ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi DJ, > Lukasz Majewski writes: > > - tst-clock2-y2038 tst-cpuclock1-y2038 > > tst-clock_nanosleep-y2038 > > + tst-clock2-y2038 tst-cpuclock1-y2038 > > tst-clock_nanosleep-y2038 \ > > + tst-clock_settime =20 >=20 > Ok. >=20 > > +/* Test for clock_settime (in VM) =20 >=20 > Perhaps "in VM" should be "if supported" as VMs aren't the only > supported case, and "in VM" doesn't really say *why* "in VM" is > important? >=20 > And we likely don't have to mention "if supported" at all; other tests > don't. *Any* test could be unsupported, for a variety of reasons > unrelated to the test. >=20 > > +#include > > +#include > > +#include > > + > > +#define TIMESPEC_SEC_Y2038_OV 0x7FFFFFFF =20 >=20 > This test will, of course, fail after 2038. >=20 > > +#define FUTURE_TIME (TIMESPEC_SEC_Y2038_OV - 10) =20 >=20 > Assuming the test takes less than 10 seconds, which is probably OK. >=20 > > +static int > > +do_test (void) > > +{ > > + const struct timespec tv =3D { FUTURE_TIME, 0}; > > + struct timespec tv_future, tv_now; > > + > > + tv_now =3D xclock_now(CLOCK_REALTIME); =20 >=20 > Current time (before 2038 we hope)... >=20 > > + xclock_settime(CLOCK_REALTIME, &tv); =20 >=20 > Set to 2038... >=20 > > + tv_future =3D xclock_now(CLOCK_REALTIME); =20 >=20 > Check "2038" time... >=20 > > + /* Restore old time value on target machine. */ > > + xclock_settime(CLOCK_REALTIME, (const struct timespec*) > > &tv_now); =20 >=20 > The cast should not be needed. Sometimes GCC complains about casting > structs to different types (although this shouldn't do that) so I tend > to avoid it when it's not needed. As fair as I remember, GCC was complaining loudly (and the test was failed as we compile with -Werror) as clock_settime expects const struct timespec* pointer argument. The tv_now cannot be defined as const and hence the required cast. >=20 > > + if (tv_future.tv_sec < tv.tv_sec) > > + FAIL_EXIT1 ("clock_settime set wrong time!\n"); =20 >=20 > If the "2038" time is "before" the "now (hopefully before 2038)" time, > we failed to set the time to the future... ok. This is a very simple test indeed. >=20 > > + return 0; > > +} > > + > > +#include =20 >=20 > LGTM aside from those nits. >=20 > Reviewed-by: DJ Delorie >=20 Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de --Sig_/R9QtLq5KpcmqJ9f6TJNEEAQ Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAmAsJwsACgkQAR8vZIA0 zr0HMQgAzd915IgOMMQnO3yD7f3V9UUBTP7rtUdyNUhu2mtGhCXv4mTUoQa2KT0S 4vg8HFwdw6q8/0kjyB7mlrCljPsTyrd6LJ45KKt/qDtyCMoq4GQWYtE77qHhFWpO VhpSTzFJ4Oy/EFx3aa+k2c5t31Xl2YX5nuCjWq2xIcPh7lv0fjxKyzgZYBLAZ/9q VJgSudCEt5VsOPWHyF/MT0Z5R1/KdkQiCA1JVauF1VJd6dbf7UZ4DYCPWfQKAfld MQ+tsbWk4U8dcDE2RC4PlWBAKqleB+IwRIRQNceeic4aL2sSJwZnJA3v06Evjj3d 2/RAmy5IuGeG0RkIXPKs0R+/X9JiTg== =8AHp -----END PGP SIGNATURE----- --Sig_/R9QtLq5KpcmqJ9f6TJNEEAQ--