From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by sourceware.org (Postfix) with ESMTPS id ED9FB384B13C for ; Wed, 17 Mar 2021 16:04:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ED9FB384B13C 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 4F0w2t13Nlz1rxwn; Wed, 17 Mar 2021 17:04:38 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4F0w2t0f6Zz1r1MR; Wed, 17 Mar 2021 17:04:38 +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 a-eiD-RNT00C; Wed, 17 Mar 2021 17:04:36 +0100 (CET) X-Auth-Info: OrCmMN+29dT4PHLZz1TqxEyTEng5wLhJWkLTNCZF+t4= 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; Wed, 17 Mar 2021 17:04:36 +0100 (CET) Date: Wed, 17 Mar 2021 17:04:29 +0100 From: Lukasz Majewski To: Andreas Schwab Cc: Florian Weimer , GNU C Library , Joseph Myers Subject: Re: [PATCH] tst: Provide test for getrusage Message-ID: <20210317170429.2dd9fc6f@jawa> In-Reply-To: <20210315145609.443f55ec@jawa> References: <20210315104223.32542-1-lukma@denx.de> <87wnu83cun.fsf@igel.home> <20210315145609.443f55ec@jawa> 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_/ZqcRaax85wSPx_SdfGBuA5u"; protocol="application/pgp-signature" X-Spam-Status: No, score=-14.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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, 17 Mar 2021 16:04:40 -0000 --Sig_/ZqcRaax85wSPx_SdfGBuA5u Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Andreas, > Hi Andreas, >=20 > > On M=C3=A4r 15 2021, Lukasz Majewski wrote: > > =20 > > > diff --git a/sysdeps/unix/sysv/linux/tst-getrusage.c > > > b/sysdeps/unix/sysv/linux/tst-getrusage.c new file mode 100644 > > > index 0000000000..068becdadb > > > --- /dev/null > > > +++ b/sysdeps/unix/sysv/linux/tst-getrusage.c > > > @@ -0,0 +1,55 @@ > > > +/* Test for getrusage > > > + Copyright (C) 2021 Free Software Foundation, Inc. > > > + This file is part of the GNU C Library. > > > + > > > + The GNU C Library is free software; you can redistribute it > > > and/or > > > + modify it under the terms of the GNU Lesser General Public > > > + License as published by the Free Software Foundation; either > > > + version 2.1 of the License, or (at your option) any later > > > version. + > > > + The GNU C Library is distributed in the hope that it will be > > > useful, > > > + but WITHOUT ANY WARRANTY; without even the implied warranty of > > > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > > GNU > > > + Lesser General Public License for more details. > > > + > > > + You should have received a copy of the GNU Lesser General > > > Public > > > + License along with the GNU C Library; if not, see > > > + . */ > > > + > > > +#include > > > +#include > > > +#include > > > +#include > > > + > > > +#define TST_GETRUSAGE_TIMEOUT 1 > > > + > > > +static int > > > +do_test (void) > > > +{ > > > + struct timespec tv_then, tv_now, gru_u, gru_s, s, r; > > > + struct rusage ru; > > > + int ret; > > > + > > > + tv_then =3D xclock_now (CLOCK_REALTIME); > > > + /* Busy wait for 1 second. */ > > > + do > > > + { > > > + tv_now =3D xclock_now (CLOCK_REALTIME); > > > + r =3D timespec_sub (tv_now, tv_then); > > > + } while ( r.tv_sec !=3D TST_GETRUSAGE_TIMEOUT ); =20 > >=20 > > What happens if the process stalls for a second? =20 >=20 > I think that the glibc's test infrastructure will kill it - the > default timeout is 2 seconds. >=20 > As a result the test will fail. On the other hand - the proposed approach with busy waiting was the natural one to check if accounting from getrusage is correct. Maybe you (or anybody else from the community) have a better idea on how to force the process to be "running" (active) for some time? Maybe I could modify the C test code to perform following bash operation: cat /dev/urandom | gzip -9 > /dev/null and replace /dev/urandom with some large (generated in place) file? However, this would pose additional dependencies (gzip) on glibc test suite. >=20 > >=20 > > Andreas. > > =20 >=20 >=20 >=20 >=20 > Best regards, >=20 > Lukasz Majewski >=20 > -- >=20 > 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 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_/ZqcRaax85wSPx_SdfGBuA5u Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAmBSKI0ACgkQAR8vZIA0 zr0xHQf9FshOp/ZAhLu6gP5ArJqEPO2sdc5JSYfdIR5MctDTfckM/eAoLHSOR+BY DlUn/DldZIVCJSGKeaZhxvNCI0oZDB5OjhbHQlyy4AFuDpMU0012OTJPdTfgm/yc 0OkThZ5XavxxEYCo9gEXJW23Pfq4LpGA/9bA8lPVteJP2gSaEy7Ofvn46GFMBDXM wYkKuODmFsU0DE7OMF8E/NkkdicCMBfk7KHE8Lg3bjfkycRAtBoBGW5qoMws8o4y uvygWnB8bRJXLkC28j2fevVH5Y5tbgVK5gatiwgCL1BSH3Gm8WCs4ncovsMPPtf9 RaPdJMw033QIx0eMsY7BpEXdhBR4uw== =Q72n -----END PGP SIGNATURE----- --Sig_/ZqcRaax85wSPx_SdfGBuA5u--