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: 13298299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 686BCEB64DC for ; Fri, 30 Jun 2023 14:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232068AbjF3O5L (ORCPT ); Fri, 30 Jun 2023 10:57:11 -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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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;