From patchwork Wed Sep 27 19:20:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 726711 Delivered-To: patch@linaro.org Received: by 2002:adf:ea87:0:b0:31d:da82:a3b4 with SMTP id s7csp3703451wrm; Wed, 27 Sep 2023 12:20:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFf0oES2GiZr0vVBRDDv7hvMf2TGz8CJ8By/KQm4taCngZ48iROuaTZmH8tmHU1JQanNAms X-Received: by 2002:a17:906:8441:b0:9ae:5fe1:ef03 with SMTP id e1-20020a170906844100b009ae5fe1ef03mr2486841ejy.67.1695842427911; Wed, 27 Sep 2023 12:20:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695842427; cv=none; d=google.com; s=arc-20160816; b=ezLy93g2aWHrs+v+CWObMH1zQ7Y0v0YylVmtQ7RCENtZk/Wu20hrGNasbZkBqhZk6Y NlH7onFdgECiG1rXVeeyxLicQ92Yox+YKDocUe8IkCwQP6foYqWhzppKCSf/4tIc75ca QIpU0tUvGpFzZPdOMjeORNxAuwZm1YXHa6bY+rzUhhvqvi7GwktzsbK4A4qsKuK7/tXx ymcsJweV2uwc7GdMu6OvyY6+4prwJFwdcHklnwzKVIJPtm7oe84vffTfQgnRtUwAozeV uocgv7XWSyjYf9z8ojwS1lKbvAU2Ru8Lt+KKKZswP0Jj0dkmxso7bgr1P7OMuswTsaOh ioIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :dmarc-filter:delivered-to; bh=894z+Dl1Hf854xBwuLknTFLA3TI283fAgAFIlysXXk4=; fh=JNN3k7BRNI1OnWdIBK9jlpNeitGd8uBm02dHI75AGcg=; b=EuvPund/B6pXzIuqFpbXusz6vm0pGPh+e1v+w6GDG+3rO8cSCC1zSRYVq3NkSYKFYk Y0B+PJB+s/aJRuRCv/VjQhL0IRUZb3mrNq87U7aR0FZ6a55bgo8+gf08r84xYmfXTmJO nvJt1lpT63vO1wrIJLcxYATVkTG04yAZ8uIbtRONQXHWJPDd5b9FmaRWGI2hGwmI0rFI aVOU54SuToPOwFlghGbPRg92aymUFdHzNND6xgbeJBJiTtpK+3ZzPlHAiMbrPOtIr/W9 qpyKUYVP2xm8Obf4Om2RZsjs2G0zCW/8M/XuCdFDlaclYLDgSryEQIr820hfM8VXnyrz VdzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GCxDLLmR; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ay20-20020a170906d29400b009ad80078e76si12979151ejb.793.2023.09.27.12.20.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:20:27 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GCxDLLmR; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D597D3857726 for ; Wed, 27 Sep 2023 19:20:26 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 55E383858C41 for ; Wed, 27 Sep 2023 19:20:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55E383858C41 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-693375d2028so1855630b3a.2 for ; Wed, 27 Sep 2023 12:20:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695842418; x=1696447218; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=894z+Dl1Hf854xBwuLknTFLA3TI283fAgAFIlysXXk4=; b=GCxDLLmRNAZF2aCuuOp5zAq/sxufZxipEnQQ8LQzgewP6Ay6Gdf37cx/kXbu2XPv0E 7bz0CgaseFCwmVAstoVhZl2GScu1pGRvNFfhigdeVZZRn/cq+cuT47Efy3F3XbeJCA+g X8FiwqHKcCv0XDOr4KK4aqbK1uJV6TX1ppxJaJw84heShdXYYXGr5ArwoNJHJEfXKZRo sFSF5a1JkHPAMPeUAcTJoFkYCMptsGwHNyplyxsrUw4IIKKWcOe+3pP+wDkytLmaizl7 7GTsZiCbi48obDIu6f64RuIrZxYd3TWLBZHSSLQFjelrBbfK4yE0Ld80nGAP58U3GJWO ftcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695842418; x=1696447218; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=894z+Dl1Hf854xBwuLknTFLA3TI283fAgAFIlysXXk4=; b=DrOpuLzTbL3LRnwz2lux6rMMkl/sTpWcO5OdsFVp8FXBjLe2ndCBtqyniqaYSh/rk6 LPfBTU1PlsDyQNbWjczmDk3/meWCBph0IoNlxfDYxJWSGXIzq8FjGqFEPmXCEbna9tF6 db6HG/VIbAuGmMVVcpTBi1ngI9dCBuBtyQMp83rdSbovwMdwFvWkAIJnzmqH5HZASm/a UsBRzlX1SjIHb8Ws0qaqAVuTkP35YocA1mx6IwB9hGudFCSsMXSlMLwKuxY3hCZBLHO0 O/S41Vt3HErD6+Dp4XFx0T4nCdyKUe33M4NA0Ha/gsc1Ud+OWx/LjmKSNZRPRYzm0tMk cpyw== X-Gm-Message-State: AOJu0Yz6J4dHfTOSPq+LnCFxPUetoTp7iK5Ix3OOmLJyPY+6uddazgiE lZLb8w9279celPYzs9Vt7z1e0BnpzWcGs5ExHYZcCw== X-Received: by 2002:a05:6a20:9699:b0:14d:7511:1c2 with SMTP id hp25-20020a056a20969900b0014d751101c2mr2550569pzc.55.1695842417600; Wed, 27 Sep 2023 12:20:17 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:6eb0:7f09:2e60:f05d:65ef]) by smtp.gmail.com with ESMTPSA id h16-20020aa786d0000000b0068fb8080939sm1600888pfo.65.2023.09.27.12.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:20:17 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Siddhesh Poyarekar Subject: [PATCH] test-container: Use nftw instead of rm -rf Date: Wed, 27 Sep 2023 16:20:13 -0300 Message-Id: <20230927192013.2071605-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org 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 Reviewed-by: Stefan Liebler --- 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. */