From nobody Fri Apr 29 14:01:22 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AEC2E1AB6F96; Fri, 29 Apr 2022 14:01:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KqZ0L4Kdwz3mLH; Fri, 29 Apr 2022 14:01:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651240882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=udyCq7YYakGmqPEVdIqhKzNSKPiFsy3xF7WXv6tyq7A=; b=APiwvWkgYBtCr2wG/ajnJ/Cz+1wsIgynQTCfP552evwCwJ1IfUYVbItzy6Aa3jzdIdn5UU 6FklQCD7RHW2edLxyPbiF9OUZC1JTaBF3mV678RPLpW1R5T7GaO5GFSpA6m52lCM3wIWZI D0gNigTQX8QuEnaB2DWbT4oS8Akn0ZUTgJks//jmTToE5V00Krfgv521Da7rbIWztocKMY QvP5iT/ezAqFQRQi4BXkBG1mIjt4ckvY+fp7qvtTV6YNzCpNcLokz/Nx6xAk/pu8Lg4pu3 unmYZ9gPm3B3EVfhYm85DewvIazxaJB4smuYETSR8GA0YhGhBiCFynEeGetEIg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7498D6506; Fri, 29 Apr 2022 14:01:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23TE1Mh4098152; Fri, 29 Apr 2022 14:01:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23TE1M52098151; Fri, 29 Apr 2022 14:01:22 GMT (envelope-from git) Date: Fri, 29 Apr 2022 14:01:22 GMT Message-Id: <202204291401.23TE1M52098151@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: 616eaa66aa49 - main - fusefs: add a test for the subtype= option List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 616eaa66aa4955f182eb0117e17e07da76fcf696 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651240882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=udyCq7YYakGmqPEVdIqhKzNSKPiFsy3xF7WXv6tyq7A=; b=j6r53nZ6zF5i2tXmk7HOfOmpuBNwb7QAi47b7Iz7akbNE78pOW4UaUicX82AKH/QDTRUas 2NprN/Jdsfzl66X51oeYw8Rt9hiNyx4zI0WbYvSwEbQrTIMhCudQBYuBv7ApG4Gll0vlOm MXVWq42PpRa31IvH7/CULNdHLkL9IlhpxWqpuhetrSFrNCG+xq+T1DeLPI6VkIkeMlB/lf 4vAywVHq1p/3VtF7XSze65JGxVT1h0j3lSxmimerPbitnKl3JHTqjxk2WAPtdGp+MzhSwu NefVWZGPF0IbiBi0dQ2GWhb+VjLgQDkTOW5K0iwpi5LtCJKe0P0jBjmvGgf0gw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651240882; a=rsa-sha256; cv=none; b=gWkBgFTkDUSTwOHnKLIcmWPBlwN3FRKFkG+ET7bJupGkRYt+WJ4G7cHloNiE0BMApy7RZm vvxYPi6skiGsFKYE8ZLKi1d8RJG/ar7SJcjl2H0wIQwV5bkgzNPS3fSGdUlJwB/o8rnRS3 3WPkty7+M+3AjIqGmztBOr8tQeVI+cUVsAHqRpj+76oyRzwCqHT5xoUAAiYE3VWRFJGorw Fy1u8HxiE3rLDV/D3PX9Z3Xo6OQrQwGpbCJBBwyhFGfPSVlQLeeJBShJUkVE8gUVNcJfQE +9i7o2/2DuZqaI0VANWs4QjF70JbR4zvezNKaX7NqwLLIdWBLXVclRCkcv8cIw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=616eaa66aa4955f182eb0117e17e07da76fcf696 commit 616eaa66aa4955f182eb0117e17e07da76fcf696 Author: Alan Somers AuthorDate: 2022-04-29 13:59:29 +0000 Commit: Alan Somers CommitDate: 2022-04-29 13:59:29 +0000 fusefs: add a test for the subtype= option At mount time server can set, for example, "subtype=xfs", so that mount(8) will later show the mountpoint's file system as "fusefs.xfs". fusefs has had this feature ever since the original GSoC commit in 2012, but there's never been a test for it. MFC after: 2 weeks --- tests/sys/fs/fusefs/mockfs.cc | 7 ++++++- tests/sys/fs/fusefs/mockfs.hh | 2 +- tests/sys/fs/fusefs/mount.cc | 34 ++++++++++++++++++++++++++++++++-- tests/sys/fs/fusefs/utils.cc | 2 +- tests/sys/fs/fusefs/utils.hh | 2 ++ 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/tests/sys/fs/fusefs/mockfs.cc b/tests/sys/fs/fusefs/mockfs.cc index ddfb5527ef13..4eebbc2200b0 100644 --- a/tests/sys/fs/fusefs/mockfs.cc +++ b/tests/sys/fs/fusefs/mockfs.cc @@ -409,7 +409,8 @@ void MockFS::debug_response(const mockfs_buf_out &out) { MockFS::MockFS(int max_readahead, bool allow_other, bool default_permissions, bool push_symlinks_in, bool ro, enum poll_method pm, uint32_t flags, uint32_t kernel_minor_version, uint32_t max_write, bool async, - bool noclusterr, unsigned time_gran, bool nointr, bool noatime) + bool noclusterr, unsigned time_gran, bool nointr, bool noatime, + const char *subtype) { struct sigaction sa; struct iovec *iov = NULL; @@ -500,6 +501,10 @@ MockFS::MockFS(int max_readahead, bool allow_other, bool default_permissions, build_iovec(&iov, &iovlen, "intr", __DECONST(void*, &trueval), sizeof(bool)); } + if (*subtype) { + build_iovec(&iov, &iovlen, "subtype=", + __DECONST(void*, subtype), -1); + } if (nmount(iov, iovlen, 0)) throw(std::system_error(errno, std::system_category(), "Couldn't mount filesystem")); diff --git a/tests/sys/fs/fusefs/mockfs.hh b/tests/sys/fs/fusefs/mockfs.hh index d471491ea455..3c8a78e85072 100644 --- a/tests/sys/fs/fusefs/mockfs.hh +++ b/tests/sys/fs/fusefs/mockfs.hh @@ -361,7 +361,7 @@ class MockFS { enum poll_method pm, uint32_t flags, uint32_t kernel_minor_version, uint32_t max_write, bool async, bool no_clusterr, unsigned time_gran, bool nointr, - bool noatime); + bool noatime, const char *subtype); virtual ~MockFS(); diff --git a/tests/sys/fs/fusefs/mount.cc b/tests/sys/fs/fusefs/mount.cc index 217fd1d554e8..d736377536cb 100644 --- a/tests/sys/fs/fusefs/mount.cc +++ b/tests/sys/fs/fusefs/mount.cc @@ -43,8 +43,28 @@ extern "C" { using namespace testing; -class UpdateOk: public FuseTest, public WithParamInterface {}; -class UpdateErr: public FuseTest, public WithParamInterface {}; +class Mount: public FuseTest { +public: +void expect_statfs() { + EXPECT_CALL(*m_mock, process( + ResultOf([](auto in) { + return (in.header.opcode == FUSE_STATFS); + }, Eq(true)), + _) + ).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) { + SET_OUT_HEADER_LEN(out, statfs); + }))); +} +}; +class Subtype: public Mount { + void SetUp() { + m_subtype = "myfs"; + Mount::SetUp(); + } +}; + +class UpdateOk: public Mount, public WithParamInterface {}; +class UpdateErr: public Mount, public WithParamInterface {}; int mntflag_from_string(const char *s) { @@ -64,6 +84,16 @@ int mntflag_from_string(const char *s) return 0; } +TEST_F(Subtype, subtype) +{ + struct statfs statbuf; + + expect_statfs(); + + ASSERT_EQ(0, statfs("mountpoint", &statbuf)) << strerror(errno); + ASSERT_EQ(0, strcmp("fusefs.myfs", statbuf.f_fstypename)); +} + /* Some mount options can be changed by mount -u */ TEST_P(UpdateOk, update) { diff --git a/tests/sys/fs/fusefs/utils.cc b/tests/sys/fs/fusefs/utils.cc index 65738f4b19a4..0d42f418c369 100644 --- a/tests/sys/fs/fusefs/utils.cc +++ b/tests/sys/fs/fusefs/utils.cc @@ -161,7 +161,7 @@ void FuseTest::SetUp() { m_default_permissions, m_push_symlinks_in, m_ro, m_pm, m_init_flags, m_kernel_minor_version, m_maxwrite, m_async, m_noclusterr, m_time_gran, - m_nointr, m_noatime); + m_nointr, m_noatime, m_subtype); /* * FUSE_ACCESS is called almost universally. Expecting it in * each test case would be super-annoying. Instead, set a diff --git a/tests/sys/fs/fusefs/utils.hh b/tests/sys/fs/fusefs/utils.hh index 1cd7bad97998..7d30f2b233ab 100644 --- a/tests/sys/fs/fusefs/utils.hh +++ b/tests/sys/fs/fusefs/utils.hh @@ -74,6 +74,7 @@ class FuseTest : public ::testing::Test { MockFS *m_mock = NULL; const static uint64_t FH = 0xdeadbeef1a7ebabe; const char *reclaim_mib = "debug.try_reclaim_vnode"; + const char *m_subtype; public: int m_maxbcachebuf; @@ -94,6 +95,7 @@ class FuseTest : public ::testing::Test { m_noclusterr(false), m_nointr(false), m_time_gran(1), + m_subtype(""), m_maxbcachebuf(0), m_maxphys(0) {}