From patchwork Fri Jul 7 15:01:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 117179 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3339098vqx; Fri, 7 Jul 2023 08:12:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlF3Kfcxe6dljEWa/LUZ9I/ZmUCLGfd/w9sVXfcs6D0qBbGDGD4bt3HM41CJNtAFVEtK9WT8 X-Received: by 2002:a17:902:c106:b0:1b8:81ec:7595 with SMTP id 6-20020a170902c10600b001b881ec7595mr4199881pli.58.1688742754321; Fri, 07 Jul 2023 08:12:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688742754; cv=none; d=google.com; s=arc-20160816; b=zpPtOd/gH9bCxOYLinyxafBbpMkxZouTrARbRePC6Ye37FFCnxQzAQZNnbw+qaqse9 olovssH2qv4NsiLo21avBlWqpFFFUknVHCDjN7Z7otHXwPsC8lkeE95AQcINxFOsj+59 6t95aziyGT25/tahWy7fMXP2yi0YQXov90dbNUpRvRtl2pALnkvw0nVdVJf79XuJqzeN 9Urgbk08PHsqJKqH5Ju9y/pqgEF4GryHekHPDmXdEuaW6ib1uBnFuTn8coznWiP60RmB npR7+dx4yiCxZcc8piA76r+67UN/zCUPNPXs+CKmKKhaiisiqBI24hV7fQZS06QDA9+5 ABew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=aBqSaNceE9XffKQbs74BWXqDKOQeSW3zv/AZDy11ze0=; fh=pYBoK8NKvGZirLsyIjvjlYHPy/fM5+u4iD3mF5vegBA=; b=i9CoNVRos9CvOjX9TUgYzdXKKANGUPdqjBQ6BLjUEUbEFLt8cX/MMYglsBngAYcFyO qP2i84CgfKqwXwebWx3yljabRYxsLxiSa20kHfkeB5wXO3LlMIpXUaefSN/2HLX+MNpe ArjTdK+MGQc3fsxMg+9QSqhaNv1lr5gINxctwI56HYp/36vWaPTkIe65O3mx1eQmErA0 8ZHFLyfesyV5B4QpHIReGwCSJbCiXC89f4mGBSmZIePPSa7uo6p1k6XJxh4KcySVb77k ZCWhp4PLhl98Rc9pTxE3JtFgf79t7GQVGjE5oPlxi2wMLDRQKFbMkV1qi5r/07CgBKaR NBxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o4-20020a170902d4c400b001b041591a5fsi4269714plg.459.2023.07.07.08.12.21; Fri, 07 Jul 2023 08:12:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233225AbjGGPBb (ORCPT + 99 others); Fri, 7 Jul 2023 11:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232974AbjGGPB3 (ORCPT ); Fri, 7 Jul 2023 11:01:29 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 726DA1FE2; Fri, 7 Jul 2023 08:01:28 -0700 (PDT) X-QQ-mid: bizesmtp74t1688742074tg81aioz Received: from linux-lab-host.localdomain ( [116.30.131.119]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 07 Jul 2023 23:01:12 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: +bXiSo2NuBc1Cd2zooPSXRsbPXASdUhmi+9wjNyy/hjCxNCxO5qngS1ViteCu ns6FJkzManwTtWB7dHIZA8wXwP40Yky4g0FuLECXFu2Ndeaooo69kfrJoOWpX45uzyTGpAJ nPnUC0t4URkUa8//XlfzX4YGN4v3zUMSi9ZV8m6LygSdBTdSgSSjIFILqo/I6i5Wms9ANVE aV6qpvXLwzFzaQXY6srvtV54bxf/VqOAHBH4yJvqFIe0HX42Oago3jrel90v8a8ausjvOEk FMSau3FWLFNI4aFaEsG+uRScy9Trs8rFpplBRLluEWFJhrWXhZQ+mxR1ecuQeGowyBt7WKS 7k2Ek8ShyF8kd1sCBdBFi6khn2PoKnT3U+WLKIUxsFoTpGVmTx0RBsy60RaMcVWc+wIOZ5x X-QQ-GoodBg: 0 X-BIZMAIL-ID: 11414460270218283821 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, david.laight@aculab.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v6 09/15] selftests/nolibc: export argv0 for some tests Date: Fri, 7 Jul 2023 23:01:09 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770775121894206547?= X-GMAIL-MSGID: =?utf-8?q?1770775121894206547?= argv0 is the path to nolibc-test program itself, which is a very good always existing readable file for some tests, let's export it. Note, the path may be absolute or relative, please make sure the tests work with both of them. If it is relative, we must make sure the current path is the one specified by the PWD environment variable. Suggested-by: Willy Tarreau Link: https://lore.kernel.org/lkml/ZKKbS3cwKcHgnGwu@1wt.eu/ Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 486334981e60..88b840f86f52 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -43,6 +43,9 @@ /* will be used by nolibc by getenv() */ char **environ; +/* will be used by some test cases as readable file, please don't write it */ +static const char *argv0; + /* definition of a series of tests */ struct test { const char *name; /* test name */ @@ -948,6 +951,7 @@ int main(int argc, char **argv, char **envp) int idx; char *test; + argv0 = argv[0]; environ = envp; /* when called as init, it's possible that no console was opened, for