Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9374524rwd; Wed, 21 Jun 2023 06:44:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4QJS7GhUPpJSb6YGvBnD4wAnjsmgh0cTOGYwQtJt3pLMUkS7Rh06qeSDQK/xmT0i80fz9B X-Received: by 2002:a05:6a21:33a5:b0:11f:6d7b:ef1e with SMTP id yy37-20020a056a2133a500b0011f6d7bef1emr6292084pzb.12.1687355096364; Wed, 21 Jun 2023 06:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687355096; cv=none; d=google.com; s=arc-20160816; b=sHC79AF0n/nVL5AGRyKqBptOOagJ0YplKFcDdOu8dQyorCjvSnIZwmbA9v2pl6EcLO h6G5yTbLhDVHE+KsHnUPIJqF5hHZO96YTKJUeO3k3XkXKNHMnGMweyaEWHbAcztNGqhO OP9LuOz33CAE2lQw4HzIir7D8ydAyhw+hZoUh9AyFviMuJtynR3iBxNQSDd1sv2aWIPL o8jc+alkiGSg8Ke4KSuBVLjkzS3FY57NxNG7kSRWEnQXQbefpwmX8w+nBG2cOoIxXoTO bpNk8YZUWMSpTlNBeYO07uVVM15NrPsQ4fWYb0d7iQyEOEElxXqRAffi/T6VMs+RJlYS 7aLw== 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=JTig7RpnfoCXmVgsDI1PHYZcLq62lzuxucvmTDfM6Tk=; b=qgJUQar4yb4zeWOWHX8mpqf1AggbrmEXsIHyKeESp+Uc+7Fe/QsTLvUjdtlQnmigfU j4U1YAKJeUj5o/fgzS9ayTFLkbI4Kn8ptaIhSc1SdoPUI8wDEepuYnE45kVGF2X6NVX3 a/2/J232x+7kfNmF9za15FjHmVI2LjNYoDtQAbHE/zqwou8BA4eCPRUvlk8Ho22HddbH 74Ztmmu03ZqTAOjYdSdQGsJRZYla6AT/eWmDfCSn81fQMqTPsJxIAdelhBJ2iDCj//8D 4ExS6fhWi3iOUzSOzZpIgUvVKmWQg8IX+ozTxhBB/N3OBPutJYmq9rhfh39ZjoAs9UFp HHYA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q6-20020aa79826000000b0066215192dd4si503596pfl.295.2023.06.21.06.44.43; Wed, 21 Jun 2023 06:44:56 -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 S229898AbjFUNVj (ORCPT + 99 others); Wed, 21 Jun 2023 09:21:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232502AbjFUNVd (ORCPT ); Wed, 21 Jun 2023 09:21:33 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66201199E; Wed, 21 Jun 2023 06:21:31 -0700 (PDT) X-QQ-mid: bizesmtp72t1687353681to56kz9l Received: from linux-lab-host.localdomain ( [116.30.126.60]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 21 Jun 2023 21:21:20 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: ILHsT53NKPhKWXRwYjRELOGgofPHYFIsOJGyCC7jLdNWG8dBIPF0UkZrO+pho y+HMLxii13FZiV+9X21Fdhh+KT4s0/ce1scZiy+KV70BQAabF9976m1RObkMDf9DE2uvNIl 7XHKvmnhWhYEWRSY22upbytj1jvM7YY1f/eEIFiZv06k2uEdef6sjG/rQEiUIxNnhX8IX23 tZPj0A0wFA2oQlkyc1atl/ZovWPVo0MumPMBUo/TS16LAWLKHj9X822dIaIVbKGn2EbjN1r LjFr86P/0O5r14qlme75d5HLcG0+QPEozUCVJ5/WIqAjh9juIjY88s6wF2HrGRGNqjcqXTw GZPeoCs+JpS869kMcHRiLSIH3/MAlym9gwmAgrFeTJxkSBhD7EWUc1bn2hiaw== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 3490715069797197203 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 17/17] selftests/nolibc: vfprintf: support tmpfs and hugetlbfs Date: Wed, 21 Jun 2023 21:21:12 +0800 Message-Id: <52c056a4d319070d2f36b59a8ef0b739ee84fdbc.1687344643.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, 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 When CONFIG_TMPFS not enabled, kernel will use the ramfs based tmpfs instead, but memfd_create doesn't work with such tmpfs, for this type of tmpfs, let's use it instead of memfd_create. At the same time, let's support hugetlbfs too if there is one. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 85fa64746cde..bff72365a158 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -796,6 +796,14 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char if (fd == -1) fd = memfd_create("vfprintf", 0); + /* memfd_create not work with ramfs based tmpfs, try tmpfs and hugetlbfs in order instead */ + if (fd == -1) { + if (tmpfs) + fd = open("/tmp/vfprintf", O_CREAT | O_TRUNC | O_RDWR); + else if (hugetlbfs) + fd = open("/hugetlb/vfprintf", O_CREAT | O_TRUNC | O_RDWR); + } + if (fd == -1) { pad_spc(llen, 64, "[FAIL]\n"); return 1; -- 2.25.1