From patchwork Fri Jul 9 13:36:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 44298 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 117A7398A4A5 for ; Fri, 9 Jul 2021 13:37:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 117A7398A4A5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625837857; bh=xMU9UN61r+hi3aQCORP+T017oyVxRA4H0GhHVQ9vHjo=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=eLbBeQHFclvjhyX3a7Dngt447x7QRIcfgWdBjJHpf3ZihyYvtuPdF8ZI9Vvsjn/QD GahCKDmHJ5nsVCDTP0n45+LGrG2DXC/64OeBVFY2GPzMgHfGoZfrvkn9IVSAeaTMbo u4n69XcUG5bz1AJT2ZSNIa75o3o1EnCJNAfk0WRA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 2E501385043E for ; Fri, 9 Jul 2021 13:37:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E501385043E Received: by mail-pf1-x431.google.com with SMTP id b12so8730385pfv.6 for ; Fri, 09 Jul 2021 06:37:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xMU9UN61r+hi3aQCORP+T017oyVxRA4H0GhHVQ9vHjo=; b=TwLowRbUw8rCWyUAmd9Nc+hw0RII+uPaUhPwTgxT7WZTzLIZEwkWuerQlWltPViLiC CXLvZnsg3LI6xTo3N94+A658olCohdnQIhnArlQge2qI8uAh8XZMMlJQEJvp+/b78Py8 lqEgjkf0YCzoYnVJFBzFtGAyXnMsNTGAi1UROCTlkWJKPCsHomPbyrMKnsMfQhFlmnh9 sFkmvoU+D6VEhEtPwrERYAJpwdlN6ecJGL5geDog4Wt/GFpNOt+nlBHGWCuDVMBZ5DhF Xe8ZTpAd9YBZGHunRoDwN4bVc+UgcqxNpzIjzBWcnzjnrwsdL4m0Oj56WZ8Q7846gLKb OTpg== X-Gm-Message-State: AOAM530ucHlqZ0d+Gtpq4YTSDiesYX6Nc/pYUXPKmVcATf8aJu0G2DQv 4QOTaJ1WKcNp9QbRl+s7mlAQTkDulMctZqySzeY= X-Google-Smtp-Source: ABdhPJzpfeG4vpXHbH/q7EhyeM42Ig6rD0rdNP6yTdwpjqXusHKRyo0HEMBI+E5lJH8HhEMxppp61ArcGyoumCZQjQc= X-Received: by 2002:a63:5f11:: with SMTP id t17mr9196578pgb.37.1625837832957; Fri, 09 Jul 2021 06:37:12 -0700 (PDT) MIME-Version: 1.0 References: <20210709130408.1620161-1-hjl.tools@gmail.com> <101ef60c-0d86-e756-5413-dcec94b0b6d8@linaro.org> In-Reply-To: <101ef60c-0d86-e756-5413-dcec94b0b6d8@linaro.org> Date: Fri, 9 Jul 2021 06:36:37 -0700 Message-ID: Subject: [PATCH v2] Properly run tst-spawn5 directly [BZ #28067] To: Adhemerval Zanella X-Spam-Status: No, score=-3031.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: GNU C Library Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" On Fri, Jul 9, 2021 at 6:13 AM Adhemerval Zanella wrote: > > > > On 09/07/2021 10:04, H.J. Lu wrote: > > 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. > > I was about to push a fix for this change, but your were faster. > > LGTM, one suggestion below. > > Reviewed-by: Adhemerval Zanella > > > --- > > 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]; > > I used: > > TEST_VERIFY_EXIT (argc == 2 || argc == 5); > int i; > for (i = 0; i < argc - 1; i++) > initial_argv[i] = argv[i + 1]; Done. > > + initial_argv[i++] = (char *) "--direct"; > > + initial_argv[i++] = (char *) "--restart"; > > + > > + initial_argv_count = i; > > > > do_test_closefrom (); > > > > Here is the v3 patch I am checking in. Thanks. From b00d8fd645679b3899104f2b7f002a9258559c28 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 9 Jul 2021 05:57:51 -0700 Subject: [PATCH v2] Properly run tst-spawn5 directly [BZ #28067] 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. Reviewed-by: Adhemerval Zanella --- posix/tst-spawn5.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/posix/tst-spawn5.c b/posix/tst-spawn5.c index 277b848794..88d8c94c78 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,16 @@ 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"; + TEST_VERIFY_EXIT (argc == 2 || argc == 5); + + int i; + + for (i = 0; i < argc - 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