From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from butterfly.birch.relay.mailchannels.net (butterfly.birch.relay.mailchannels.net [23.83.209.27]) by sourceware.org (Postfix) with ESMTPS id BA3663858D20 for ; Thu, 28 Sep 2023 11:30:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA3663858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 09863940D93; Thu, 28 Sep 2023 11:30:46 +0000 (UTC) Received: from pdx1-sub0-mail-a296.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 9CE38940DEE; Thu, 28 Sep 2023 11:30:45 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1695900645; a=rsa-sha256; cv=none; b=znhWxMWE+ptahic6Hv4ezujr0vrmv3gOSvcScZeMa28D/QceK1lVfwbTkFBZwT9jmSzEua x6z9IVeHXdk2UEt2VehRvTShN2K6mow/tRqa0TH52hY96Cwp2WTEakupFGB4gqgJrqIpgW GE6j+qw+SHgw10MZMbedJSfGFGqftAfH7jiM/HwrcJ2v/P8eALwK2Jn7a/xLDyH5nHepag tZZV35QMTmWO69y8CLcEJC0Qw2T7kOMdV3XjDbt/IU6m8LsIep/w3pcWXpBll18rYaNPSk BkU7a8yJJ0ZU+E1sBHA5BCax8EuOAL2JlO89CPLH5o5NxxGh6TgkLRwhyW2b8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1695900645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TERFQT11pM20O6MKvPgWUAHUdUQsLVvHMhzOQF7qyZU=; b=nGOi77WTTGTFLLxeaqFNAHAru1YDXTraw1RAjaOu4PEzWZilx+zDJw7SjI2BOZyiq80fFU vHhVcDByfReU4/n6JlkSNFozaFNR0+Z4pC8HF2Zhk7Kwncdgg/qAmT59R9+NGzic5bhptI tPnhuBcB0qqGq3/ENjN79H/Yg91QUrwiZPVRl/TTJF+MaoXFxnZYmX/b/85VTMwLls5Ge2 EQyn5iMoKMcvJiFRc6Ht1cG0+HWaTgTzoQ5oc4hN1hk8yq3CkOqGJs+kd1mgRgfF3y+9j/ IGM+11yHsAS1ldx5oWsGxqVSXJdV7dtr+9KM9Zm2Bzf1ZLTn9DhQ10XIgnbO8A== ARC-Authentication-Results: i=1; rspamd-7d5dc8fd68-jrs7f; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Sponge-Absorbed: 40b8b6e419362d29_1695900645867_4246822005 X-MC-Loop-Signature: 1695900645867:3573174287 X-MC-Ingress-Time: 1695900645866 Received: from pdx1-sub0-mail-a296.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.109.110.212 (trex/6.9.1); Thu, 28 Sep 2023 11:30:45 +0000 Received: from [192.168.0.182] (bras-vprn-toroon4834w-lp130-02-142-113-138-41.dsl.bell.ca [142.113.138.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a296.dreamhost.com (Postfix) with ESMTPSA id 4RxB9x1yglz6D; Thu, 28 Sep 2023 04:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1695900645; bh=TERFQT11pM20O6MKvPgWUAHUdUQsLVvHMhzOQF7qyZU=; h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding; b=WhGarMcHywDkXbltSWQF2NIzSubcXE+VsCFq97sWF/7a2KNraprJVrddzs9dD986+ myRs9Px/JlXyhao2GxdHf0mzgp3VkVV6k0bippLSPcUeDM2/63Iw8qMzqhcx9N5wBE n84xrnXS/fohPH7g/MijyNHrnTXnt/KS6T7DBthZSmTEegGKYaBVjbvmwQJY39Zyji 2HYIclnuxmpgX06O2EqgKX4Wo8uYdXQ7F7hZhaWcY2em1BpfGwsvSprUbNmteI8VYF CiS9WHzPoP/LstBWVFYkvMNfJ1wBn5IMQsDxPEr2tHxAxgllUNHHKVeYoAm/DkYdv7 XALJkGTFGfKXw== Message-ID: <4d49db04-327a-9182-a588-686bc2d0b375@gotplt.org> Date: Thu, 28 Sep 2023 07:30:44 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] test-container: Use nftw instead of rm -rf Content-Language: en-US To: Adhemerval Zanella , libc-alpha@sourceware.org References: <20230927192013.2071605-1-adhemerval.zanella@linaro.org> From: Siddhesh Poyarekar In-Reply-To: <20230927192013.2071605-1-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3037.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2023-09-27 20:20, Adhemerval Zanella wrote: > If the binary to run is 'env', test-containers skips it and adds > any required environment variable on the process envs variables. > This simplifies the required code to spawn new process (no need > to build an env-like program). > > However, this is an issue for recursive_remove if there is any > LD_PRELOAD, since test-container will not prepend the loader command > along with required paths. If the required preloaded library can > not be loaded by the system glibc, the 'post-clean rsync' will > eventually fail. > > One example is if system glibc does not support DT_RELR and the > built glibc does, the nss/tst-nss-gai-hv2-canonname test fails > with: > > ../scripts/evaluate-test.sh nss/tst-nss-gai-hv2-canonname $? false false > 86_64-linux-gnu/nss/tst-nss-gai-hv2-canonname.test-result > rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_ABI_DT_RELR' not > found (required by x86_64-linux-gnu/malloc/libc_malloc_debug.so) > > Instead trying to figure out the required loader arguments on how > to spawn the 'rm -rf', replace the command with a nftw call. > > Checked on x86_64-linux-gnu. > --- Reviewed-by: Siddhesh Poyarekar > support/test-container.c | 34 +++++++++++----------------------- > 1 file changed, 11 insertions(+), 23 deletions(-) > > diff --git a/support/test-container.c b/support/test-container.c > index 788b091ea0..95dfef1a99 100644 > --- a/support/test-container.c > +++ b/support/test-container.c > @@ -37,6 +37,7 @@ > #include > #include > #include > +#include > > #ifdef __linux__ > #include > @@ -405,32 +406,19 @@ file_exists (char *path) > return 0; > } > > +static int > +unlink_cb (const char *fpath, const struct stat *sb, int typeflag, > + struct FTW *ftwbuf) > +{ > + return remove (fpath); > +} > + > static void > recursive_remove (char *path) > { > - pid_t child; > - int status; > - > - child = fork (); > - > - switch (child) { > - case -1: > - perror("fork"); > - FAIL_EXIT1 ("Unable to fork"); > - case 0: > - /* Child. */ > - execlp ("rm", "rm", "-rf", path, NULL); > - FAIL_EXIT1 ("exec rm: %m"); > - default: > - /* Parent. */ > - waitpid (child, &status, 0); > - /* "rm" would have already printed a suitable error message. */ > - if (! WIFEXITED (status) > - || WEXITSTATUS (status) != 0) > - FAIL_EXIT1 ("exec child returned status: %d", status); > - > - break; > - } > + int r = nftw (path, unlink_cb, 1000, FTW_DEPTH | FTW_PHYS); > + if (r == -1) > + FAIL_EXIT1 ("recursive_remove failed"); > } > > /* Used for both rsync and the mytest.script "cp" command. */