From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 7A8CC1F8C6 for ; Fri, 9 Jul 2021 13:04:42 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B09503987004 for ; Fri, 9 Jul 2021 13:04:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B09503987004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625835881; bh=0wXSVAZ3UdrMAVaVv5fUOFLyyRtTy9imME2qah+53eY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=nD32y2r1JP81r47veuq6NRiyd6k0Rxa9+B4AKXo8C70KYW8jHsZRY26gaW45v1VDa fZ+jeRiJaYHQZay9JQ0KAYm1Cixr+AuSNGXYvRzwzLwc61mbjyxY7AYmFYJyceACwa Jt46qUJUltyyQfUdoLaJObXbTWBdqutpXOrged5w= Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by sourceware.org (Postfix) with ESMTPS id 8E027384BC11 for ; Fri, 9 Jul 2021 13:04:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8E027384BC11 Received: by mail-pj1-x102b.google.com with SMTP id b14-20020a17090a7aceb029017261c7d206so8185680pjl.5 for ; Fri, 09 Jul 2021 06:04:22 -0700 (PDT) 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=0wXSVAZ3UdrMAVaVv5fUOFLyyRtTy9imME2qah+53eY=; b=HLjuiE3mIF5/SGl40ivq5Pb4WYFjG6T9rcZaxot6zsn8wRbBC52qvs2ZiuolgHja3+ LU9PN+DCnzkXLroLohtrj9tQ1MDekW1bWruI/tCluO3aHCtFDh9y370hpKAB/qdFcHzX OSZeDC83l/o26ontjTAXRBJFhbZUc4eO4kXdWkUqSgzMvJNDV75CvEK9xqusOIl6Ygv0 NlLvpKLkUu8kYWUv9gLB6OJ4ZREIVeAQoumL1wqHQBFzkRE7KeYTbINmUwrrJXAozJi3 VO7Imd53MoESSsuShFt1URJDhJjJcuQQtl3rRRbOY5IPjgxuFLFw+ZPW6x03hquYl5RW vsrQ== X-Gm-Message-State: AOAM533IXKGdCtV+sx6kQckbvWvi14CRNhchSvWikAOA4Gy+vvpLh6A0 U8/ObeYOJS0zvH3N6yQqrVlPML8FI/c= X-Google-Smtp-Source: ABdhPJysQkmab9sSlowUiNcG6L4yOeWq2abzDs7m258Yt+8m8E1WsvX6T12RgPBMj8KdJVu6sGaOaQ== X-Received: by 2002:a17:902:860b:b029:129:6edf:7703 with SMTP id f11-20020a170902860bb02901296edf7703mr27711965plo.50.1625835861738; Fri, 09 Jul 2021 06:04:21 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.56.39.115]) by smtp.gmail.com with ESMTPSA id t6sm12722754pjo.4.2021.07.09.06.04.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 06:04:21 -0700 (PDT) Received: from gnu-tgl-2.localdomain (gnu-tgl-2 [192.168.1.34]) by gnu-cfl-2.localdomain (Postfix) with ESMTPS id 31BF3C0048; Fri, 9 Jul 2021 06:04:19 -0700 (PDT) Received: from gnu-tgl-2.lan (localhost [IPv6:::1]) by gnu-tgl-2.localdomain (Postfix) with ESMTP id 0891E3002B1; Fri, 9 Jul 2021 06:04:09 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] Properly run tst-spawn5 directly [BZ #28067] Date: Fri, 9 Jul 2021 06:04:08 -0700 Message-Id: <20210709130408.1620161-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , From: "H.J. Lu via Libc-alpha" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" Change tst-spawn5.c to handle tst-spawn5 without optional path to ld.so, --library-path nor the library path when glibc is configured with --enable-hardcoded-path-in-tests. This fixes BZ #28067. --- posix/tst-spawn5.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/posix/tst-spawn5.c b/posix/tst-spawn5.c index 277b848794..8649bb5094 100644 --- a/posix/tst-spawn5.c +++ b/posix/tst-spawn5.c @@ -40,6 +40,7 @@ static int restart; /* Hold the four initial argument used to respawn the process, plus the extra '--direct' and '--restart', and a final NULL. */ static char *initial_argv[7]; +static int initial_argv_count; #define CMDLINE_OPTIONS \ { "restart", no_argument, &restart, 1 }, @@ -133,11 +134,16 @@ static void spawn_closefrom_test (posix_spawn_file_actions_t *fa, int lowfd, int highfd, int *extrafds, size_t nextrafds) { - /* 6 elements from initial_argv (path to ld.so, '--library-path', the - path', application name', '--direct', and '--restart'), up to - 2 * maximum_fd arguments (the expected open file descriptors), plus - NULL. */ - enum { argv_size = array_length (initial_argv) + 2 * NFDS + 1 }; + /* 3 or 6 elements from initial_argv: + + path to ld.so optional + + --library-path optional + + the library path optional + + application name + + --direct + + --restart + up to 2 * maximum_fd arguments (the expected open file descriptors), + plus NULL. */ + int argv_size = initial_argv_count + 2 * NFDS + 1; char *args[argv_size]; int argc = 0; @@ -268,12 +274,14 @@ do_test (int argc, char *argv[]) if (restart) handle_restart (argc, argv); - initial_argv[0] = argv[1]; /* path for ld.so */ - initial_argv[1] = argv[2]; /* "--library-path" */ - initial_argv[2] = argv[3]; /* the library path */ - initial_argv[3] = argv[4]; /* the application name */ - initial_argv[4] = (char *) "--direct"; - initial_argv[5] = (char *) "--restart"; + int i; + + for (i = 0; i < (argc == 5 ? 4 : 1); i++) + initial_argv[i] = argv[i + 1]; + initial_argv[i++] = (char *) "--direct"; + initial_argv[i++] = (char *) "--restart"; + + initial_argv_count = i; do_test_closefrom (); -- 2.31.1