From patchwork Fri Jul 7 18:40:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 117273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3499984vqx; Fri, 7 Jul 2023 12:43:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlGpvS4xsNmMZqSnCLm+NNL6YYVRY8VfchzMec2/feDAOD/LUStTwymc+hg105c7M89qv6Jo X-Received: by 2002:a17:907:9109:b0:992:1b2:4090 with SMTP id p9-20020a170907910900b0099201b24090mr4309870ejq.64.1688759002287; Fri, 07 Jul 2023 12:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688759002; cv=none; d=google.com; s=arc-20160816; b=uz2M3jfZx9A6zLNMsjyQf4zeGXWl/fvF2DtPF+ay6NxOz0NhjpmpvlL2mRFRMg0y1B MgjM4R5RC4+fHAWaPjRbEBlIG2UPFySJx5JK22lwtYZXF6vnhT3SqbMo8+49qU1jOHP7 /JOzhPJCSf4K+43/jg4hcI0+y2xEPq77p+adHLsXwzlx7bJ/T745tIPhxOcCVwXcIJsS UP3Q4241q8APoqAwVWZyVE008giOtNW7/gjeXYZah55ke7Z8Hj6Q1ffTxYfEPNld8CVC MTa0RbHoJbw7v/4ynnEN9P9Yf6kHmotOOoQcXR+hCOSqpZBvRPR8oMO0N2HMHdbeDtwy b67Q== 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=sbiCJ0l8kj/DMG70L3NfLPl2cO+XV33d5dqZCfvaZPY=; fh=+UJGAEU2Zd20Ffzlyw2DOtwfBiThnaWweXJeIpZW2cQ=; b=J9V8CYLnnMvN05rnm2fTczaDID/WStuH1WnnDcO1g8SAbZQuMDNrrPmVxgEDCEYw7k ymcmiwZbBzlIor/AfIIHOSmXFG1GRuVT7bQxvNmZpUGjU109eRNZpoi/cT9cuLpZhFb5 v/bxIqeZUBcA3A5v1iNfQPQrgqChoRUPuFSrPljUggyPyWSfodgc1cRfnNpqmnDbn1C1 0zMPf4CoqcnodM0lwZlKrdcBtXwmZlnD2PcLtbHKlT0wDrjRobhxxF8OEBrehHrI4mFs E+/y7iZ4umwkRz/vUtylB7bK3IIfqs81LwhPEuTTOyr4Q4Xw7kIiRzMzc2mYMkPlriTJ U62g== 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 t10-20020a1709060c4a00b00992b168204fsi2022812ejf.891.2023.07.07.12.42.58; Fri, 07 Jul 2023 12:43:22 -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 S232700AbjGGSlL (ORCPT + 99 others); Fri, 7 Jul 2023 14:41:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbjGGSlJ (ORCPT ); Fri, 7 Jul 2023 14:41:09 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB2292686; Fri, 7 Jul 2023 11:41:06 -0700 (PDT) X-QQ-mid: bizesmtp89t1688755258tl15jmsd Received: from linux-lab-host.localdomain ( [116.30.131.119]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 08 Jul 2023 02:40:56 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: pMHwdq3i9JMdscoC4rTMu/NiAUoIRiiFj3qeqqHtFAEulmGT9cGyKGZzstgvB EuvAHvEWur986HyyMuCngFP7Y9/35QpomwUGhdan4ddVmrh4/z3FyI1kAT+wbbhQqj1wNmY lyFDJoSZrwQdG+YhAVAC/1IhLwK2D7jlHutttbAKCXDDU2q6TUCFm3U2bppd+h5FKYR9H0w Zm0ga1G4kQSD8wwF57ei8KmUCLA1jiQTrPCoaQMzWqbKo5CtGWWmUYV3RQCPEvixPWIpfks VvW3wrSGK6TShyAzvTg2GVs0EowUSjJxDeYvxeN+801tpi3D3QCQ29gHA3DMHlC1tfeOkXG fR0VzH8ZEJaQpOBCcABNTa4fjjUvaZ/U54BV4N16uvPkMMTcrQ2XZH4HmN02JVUA9LCDb2p VcOV2RIPInI= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 6393069016375536476 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, thomas@t-8ch.de, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= Subject: [PATCH v4 14/18] selftests/nolibc: vfprintf: remove MEMFD_CREATE dependency Date: Sat, 8 Jul 2023 02:40:08 +0800 Message-Id: <94bdca8d8610e85bb1683bf10a5005ca92c3cb57.1688750763.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_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?1770792159876542940?= X-GMAIL-MSGID: =?utf-8?q?1770792159876542940?= The vfprintf test case require to open a temporary file to write, the old memfd_create() method is perfect but has strong dependency on MEMFD_CREATE and also TMPFS or HUGETLBFS (see fs/Kconfig): config MEMFD_CREATE def_bool TMPFS || HUGETLBFS And from v6.2, MFD_NOEXEC_SEAL must be passed for the non-executable memfd, otherwise, The kernel warning will be output to the test result like this: Running test 'vfprintf' 0 emptymemfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid=1 'init' "" = "" [OK] To avoid such warning and also to remove the MEMFD_CREATE dependency, let's open a file from tmpfs directly. The /tmp directory is used to detect the existing of tmpfs, if not there, skip instead of fail. And further, for pid == 1, the initramfs is loaded as ramfs, which can be used as tmpfs, so, it is able to further remove TMPFS dependency too. Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/lkml/9ad51430-b7c0-47dc-80af-20c86539498d@t-8ch.de Reviewed-by: Thomas Weißschuh Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 6b863f7b677c..494195890e4b 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -875,10 +875,10 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char FILE *memfile; va_list args; - fd = memfd_create("vfprintf", 0); + fd = open("/tmp", O_TMPFILE | O_EXCL | O_RDWR, 0600); if (fd == -1) { - pad_spc(llen, 64, "[FAIL]\n"); - return 1; + pad_spc(llen, 64, "[SKIPPED]\n"); + return 0; } memfile = fdopen(fd, "w+");