From patchwork Fri Jun 30 14:56:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114762 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10447361vqr; Fri, 30 Jun 2023 08:17:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7KmtVcM2OKOzJPz62BvwXpWLCLY5qXf1H8E2orkcifDLpVnuWIeVRSzZuA6rJI4m/Xxzr6 X-Received: by 2002:a05:6a21:9989:b0:12c:ba45:12db with SMTP id ve9-20020a056a21998900b0012cba4512dbmr3211591pzb.24.1688138263178; Fri, 30 Jun 2023 08:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688138263; cv=none; d=google.com; s=arc-20160816; b=p1Lha0hGqZg4QEl2ei+QwgRRp4v7BNvJHImfTafc4Mt74jFBD7hmvCMBK8LKWjhVqO jqk+6FZAG0L7c2957R56HdBycuBimdPUecaleaOuilZ9YpL+UXUMjQKiqGhyQa7TM8Kn dTAtrjIUax4Bu3igV/8E4qe03asSvLrUUDeXrZ1CJfNrlafQklVXwhQeG6mh5RO0AEUk 0pMxRaeCxa9aPvlFF3v7b7GixDClf+xgTYMnQBXadZWxR1C2PTAJtvu9rvSdcoZdBvKM Skr5RLl+gBe4LfL8gq5K6po9y2bGxzX5DNiYx2kc+NRByGz+l3AaLpB3/7wbgDNeXsY3 dD3w== 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=WJHzMh54C97p18U55lQ+wmj2SBaV5mqrRt7u/6KEm84=; fh=49fx4+cYYT2jkB1G9v6CSOY1nO+RV0JwAuF3mNCzENI=; b=H1Co/zS9y8rfCvobmmMw6kY510L+7rl8o9gXsbUCeuq5qWGu7Y4uW24HC3So+jq0FC pws4MkZ+d6jYBvTkYRMbKJxKB6UqYylPhDqhfy2YvufwFsFzTktlvpi6SAb7/6Qyr7fy AyulnXAD+TcmbooGqEvQM7Y7/zAbq7DlMkxcKImp9g1rWcxKe/QbqkCXuDNt2RASWnMB 6oUamg5awuYz55GK5AUqFaSJ/qV9Od/h0aXHMEMBehBQ0xWxLUKHiaqKhG4xioJD+8qZ gXfOPQRmYNcGLtEtOVuCV3FBaBxzURlzL/T6q71yamPVKMpdZ2tuG8Qtku/g62/DhYaI 5FdQ== 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 w17-20020a170903311100b001b812e46da9si7828397plc.436.2023.06.30.08.17.29; Fri, 30 Jun 2023 08:17:43 -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 S232809AbjF3O5M (ORCPT + 99 others); Fri, 30 Jun 2023 10:57:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231849AbjF3O5K (ORCPT ); Fri, 30 Jun 2023 10:57:10 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90D75171E; Fri, 30 Jun 2023 07:57:08 -0700 (PDT) X-QQ-mid: bizesmtp82t1688137018tsiqwx7a Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 22:56:57 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: +ynUkgUhZJmKaF5lx43msVOqUOEusgk0PNkqlU5Je21DA28KFEa/NSf3ei5GC 8ujOyUUh0oJCOeE0bIFeiDv23kIV2OyzhEBlyx6kIfnhlhooHbcSy/KieZ7PlYewN310ono eeacy8IX7WzDhYNygHg2pO8NrYhe+qtZ7Be2Maskig39IMsqf7Ggr8eTwX++W402Iv8ztEe RyMXx6V38NGtfViJgAGOMrD2l2eKcMLlZRte11ElHDkHXRufUT1IvNk4aMIKMaxkLdhvuko 9hFzgHQsZTjVVud17s0AueJ7Dss7dKpnbgc2NpObJW3bWFc2K/9zzAJcjIpc+1lMM8Sy7uu pUKmL2hKpFuKLE1GrBM5hALFm4CzcgAUraZSdCjO0nzQQDPWrwU2m7OV3iIoOhSZdOhS29e X-QQ-GoodBg: 0 X-BIZMAIL-ID: 7295049176166171116 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Subject: [PATCH v3 11/14] selftests/nolibc: fix up failures when CONFIG_PROC_FS=n Date: Fri, 30 Jun 2023 22:56:46 +0800 Message-Id: <023e07a05e3af211da893e76ae4328983b19882c.1688134400.git.falcon@tinylab.org> 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?1770141267723766595?= X-GMAIL-MSGID: =?utf-8?q?1770141267723766595?= For CONFIG_PROC_FS=n, the /proc is not mountable, but the /proc directory has been created in the prepare() stage whenever /proc is there or not. so, the checking of /proc in the run_syscall() stage will be always true and at last it will fail all of the procfs dependent test cases, which deviates from the 'cond' check design of the EXPECT_xx macros, without procfs, these test cases should be skipped instead of failed. To solve this issue, one method is checking /proc/self instead of /proc, another method is removing the /proc directory completely for CONFIG_PROC_FS=n, we apply the second method to avoid misleading the users. Reviewed-by: Thomas Weißschuh Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 34a47c512b97..b7ea95dad0fb 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1046,8 +1046,11 @@ int prepare(void) /* try to mount /proc if not mounted. Silently fail otherwise */ if (stat("/proc/.", &stat_buf) == 0 || mkdir("/proc", 0755) == 0) { - if (stat("/proc/self", &stat_buf) != 0) - mount("/proc", "/proc", "proc", 0, 0); + if (stat("/proc/self", &stat_buf) != 0) { + /* If not mountable, remove /proc completely to avoid misuse */ + if (mount("none", "/proc", "proc", 0, 0) != 0) + rmdir("/proc"); + } } return 0;