From patchwork Fri Jan 29 13:36:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 41871 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7F0F839DC4B6; Fri, 29 Jan 2021 13:36:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F0F839DC4B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611927391; bh=T5rbJqy5p3tnH8gDS3H1LcKc31ke1e9oGlMZVPE5pZU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=QPSMj1BuuntE3SlLFSf5DZA0vUUmx+eOA1fXIUwXX2OjoZCH5lAP+PrwhqnWh+0W6 d5ukhRRF3nlC9fqHyuRyPrToiXdx9S2EcJZLaWlLlqLSzajxMewBs7nyOpCYZJ/SSb r3444rAl7jDeqx7ubkob1DEucFC/UVr5uDeJEIwo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by sourceware.org (Postfix) with ESMTPS id 84767387087A for ; Fri, 29 Jan 2021 13:36:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 84767387087A Received: by mail-qt1-x82a.google.com with SMTP id z9so6618687qtv.6 for ; Fri, 29 Jan 2021 05:36:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=T5rbJqy5p3tnH8gDS3H1LcKc31ke1e9oGlMZVPE5pZU=; b=p6JucXhuuUgbY2QDyrdVJBRbn6uXT5e98vx1T5RxcXTTam2OxdwiU8glxP4NzwD7Al zA6AyF+XnyfUVEnI8VRcdcOnn6ZfUVb4baUjelUx9DnxXs0S4RXJkYzwynU8FtRTA0Lg EQ6ubgcb+jxPsViUdCd1zA3YZM6bSohpVOCV7I7Z14nF77H95oCT41ROkav7xYR2kD36 e6+50QnFseD1d8FjNpeS9IvKuXhFlJS+5RmsSxdqmNSWVfUnADktCjs8DVzliUZFyYzz LesnVDakRk8WaAR/tDxA2su8wpxx1BwtjPaQ9PotbI3fmj4XyS7CLwInRQhqJoVRZWkW 0cJQ== X-Gm-Message-State: AOAM532o5rV2VLgvZBbXXUCqgJKoJEMyebQ0OjYAiMRBijKN4KxLzaGZ 3L2k5wvhdHEBOvi4o/dUEdvTldQPdhBMbQ== X-Google-Smtp-Source: ABdhPJwjX09yXnLXwEWR5namal0OH1iLUq01vLYHLyA8bXO5h3nW3T5HywCPDnCjGl55dcJExpJa4w== X-Received: by 2002:ac8:6999:: with SMTP id o25mr4105922qtq.373.1611927387521; Fri, 29 Jan 2021 05:36:27 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id o15sm5540861qtp.51.2021.01.29.05.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 05:36:26 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH] elf: Fix tests that rely on ld.so.cache for cross-compiling Date: Fri, 29 Jan 2021 10:36:21 -0300 Message-Id: <20210129133621.3729816-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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.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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Cc: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" For configurations with cross-compiling equal to 'maybe' or 'no', ldconfig will not run and thus the ld.so.cache will not be created on the container testroot.pristine. This lead to failures on both tst-glibc-hwcaps-prepend-cache and tst-ldconfig-ld_so_conf-update on environments where the same compiler can be used to build different ABIs (powerpc and x86 for instance). This patch addas a new test-container hook, ldconfig.run, that triggers a ldconfig execution prior the test execution. Checked on x86_64-linux-gnu and i686-linux-gnu. --- .../ldconfig.run | 0 .../ldconfig.run | 0 support/test-container.c | 26 +++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 elf/tst-glibc-hwcaps-prepend-cache.root/ldconfig.run create mode 100644 elf/tst-ldconfig-ld_so_conf-update.root/ldconfig.run diff --git a/elf/tst-glibc-hwcaps-prepend-cache.root/ldconfig.run b/elf/tst-glibc-hwcaps-prepend-cache.root/ldconfig.run new file mode 100644 index 0000000000..e69de29bb2 diff --git a/elf/tst-ldconfig-ld_so_conf-update.root/ldconfig.run b/elf/tst-ldconfig-ld_so_conf-update.root/ldconfig.run new file mode 100644 index 0000000000..e69de29bb2 diff --git a/support/test-container.c b/support/test-container.c index 8b6ce86da9..28cc44d9f1 100644 --- a/support/test-container.c +++ b/support/test-container.c @@ -45,6 +45,7 @@ #include #include +#include #include "check.h" #include "test-driver.h" @@ -83,6 +84,7 @@ int verbose = 0; * copy support files and test binary * chroot/unshare * set up any mounts (like /proc) + * run ldconfig Magic files: @@ -131,6 +133,9 @@ int verbose = 0; * mytest.root/postclean.req causes fresh rsync (with delete) after test if present + * mytest.root/ldconfig.run causes ldconfig to be issued prior + test execution (to setup the initial ld.so.cache). + Note that $srcdir/foo/mytest.script may be used instead of a $srcdir/foo/mytest.root/mytest.script in the sysroot template, if there is no other reason for a sysroot. @@ -684,6 +689,16 @@ check_for_unshare_hints (void) } } +static void +run_ldconfig (void *x __attribute__((unused))) +{ + char *prog = xasprintf ("%s/ldconfig", support_install_rootsbindir); + char *args[] = { prog, NULL }; + + execv (args[0], args); + FAIL_EXIT1 ("execv: %m"); +} + int main (int argc, char **argv) { @@ -700,6 +715,7 @@ main (int argc, char **argv) char *command_basename; char *so_base; int do_postclean = 0; + bool do_ldconfig = false; char *change_cwd = NULL; int pipes[2]; @@ -826,6 +842,9 @@ main (int argc, char **argv) if (file_exists (concat (command_root, "/postclean.req", NULL))) do_postclean = 1; + if (file_exists (concat (command_root, "/ldconfig.run", NULL))) + do_ldconfig = true; + rsync (pristine_root_path, new_root_path, file_exists (concat (command_root, "/preclean.req", NULL))); @@ -1126,6 +1145,13 @@ main (int argc, char **argv) /* The rest is the child process, which is now PID 1 and "in" the new root. */ + if (do_ldconfig) + { + struct support_capture_subprocess result = + support_capture_subprocess (run_ldconfig, NULL); + support_capture_subprocess_check (&result, "execv", 0, sc_allow_none); + } + /* Get our "outside" pid from our parent. We use this to help with debugging from outside the container. */ read (pipes[0], &child, sizeof(child));