From patchwork Wed Jun 21 13:18:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13287286 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 DC66BEB64D7 for ; Wed, 21 Jun 2023 13:20:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230214AbjFUNUY (ORCPT ); Wed, 21 Jun 2023 09:20:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230448AbjFUNUW (ORCPT ); Wed, 21 Jun 2023 09:20:22 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBAE71994; Wed, 21 Jun 2023 06:20:18 -0700 (PDT) X-QQ-mid: bizesmtp78t1687353609twv2x5yr Received: from linux-lab-host.localdomain ( [116.30.126.60]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 21 Jun 2023 21:20:07 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: LE7C6P2vL8QaLL7JPV1s2XMq3xaIhLPj7Fcy7ZasiRCLssjSUm9F+DbEx0p4g 0gPy5kD2TqEixqQZRzFnulPS2AtCpo9yKg2a53LxzOZDf426H2hSW7q9zCjMScUmvL+Gc96 wv3NqZLpC0DEYO20NTyPnywckAS2JgJxhTLDwxla2AKv3sOWObrXEz+Anb8OCHv0wvNFSH9 7zk5zv2vqy36LnH1ewGptn5XZsPVIbcdMlgh4vFMn9w7sIKp+1dkXXbUd75tS/Epfv1rx7x stmMDbj9VDf/181dzxopn0yu4htPyqic7qpxpWmxC4MeYq6/yhx946EDrciP0a1aNvmVlK6 YdFyPLWkPAsOpp9lPx9Jbw3ghg8k90cjaPuFvuU002KpY1c0D0= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 11267784333303017325 From: Zhangjin Wu To: w@1wt.eu Cc: thomas@t-8ch.de, arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 16/17] selftests/nolibc: vfprintf: skip if neither tmpfs nor hugetlbfs Date: Wed, 21 Jun 2023 21:18:53 +0800 Message-Id: <55a01001987f2795a982755ed2ca8e27efe49249.1687344643.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:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org As fs/Kconfig shows, MEMFD_CREATE depends on TMPFS or HUGETLBFS: config MEMFD_CREATE def_bool TMPFS || HUGETLBFS Let's skip vfprintf test if they are not there. The /tmp and /hugetlb directories have been created to mount tmpfs and hugetlbfs respectively, if they are not enabled in kernel configuration, neither /tmp nor /hugetlb will be created. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 8b1ce9911c5c..85fa64746cde 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -769,11 +769,22 @@ int run_stdlib(int min, int max) static int expect_vfprintf(int llen, size_t c, const char *expected, const char *fmt, ...) { + struct stat stat_buf; int ret, fd, w, r; + int tmpfs = 0, hugetlbfs = 0; char buf[100]; FILE *memfile; va_list args; + /* memfd_create depends on tmpfs or hugetlbfs */ + tmpfs = stat("/tmp/.", &stat_buf) == 0; + hugetlbfs = stat("/hugetlb/.", &stat_buf) == 0; + + if (!tmpfs && !hugetlbfs) { + pad_spc(llen, 64, "[SKIPPED]\n"); + return 0; + } + /* silence warning for kernel >= v6.2: * * "memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid="