From patchwork Fri Jul 9 13:04:08 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: 44296 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 D81683988030 for ; Fri, 9 Jul 2021 13:04:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D81683988030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625835883; bh=0wXSVAZ3UdrMAVaVv5fUOFLyyRtTy9imME2qah+53eY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xkH3rw6fZGF2qNu9sDA4B3fSqPyP0faFpKOu41HQ+CT2dvTFOcYRdqk2v8nmnvgNz ZqEcczW/mcDu3h+x+3Wo1XdsniChfIVeUo46bfPNw0ofFG0p0l4fTU0GZaZHi81wCO MJI+LwHCo7fIYbCJrC8kUElM37SQAHiu4PZv1IDk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 X-Spam-Status: No, score=-3032.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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" Errors-To: libc-alpha-bounces+patchwork=sourceware.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. 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]; + initial_argv[i++] = (char *) "--direct"; + initial_argv[i++] = (char *) "--restart"; + + initial_argv_count = i; do_test_closefrom ();