From nobody Sat Jun 18 14:16:47 2022 X-Original-To: dev-commits-src-all@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 AD1DD86A8CD; Sat, 18 Jun 2022 14:16:47 +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 4LQHz34TfKz3rMy; Sat, 18 Jun 2022 14:16:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655561807; 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=Oiu+2LhYPUIpV0/6vq5Kt5H5vOHTQ1DeToGzu+qlF00=; b=BXmEc2oV/ReX9iMExix/W/Zg+svtyanBZw9q7mbGvxHmW2fR72FdyhsiEKh/a3YcGL80yp kj/oa215Lr2DrAKc3sqWuFaHnCvdBkH93281yqYoM0ruZUTkirsX4TOxNqvU1TIoHyORxU f4qYRFCmueKMZd4eOhweabDFvrM7HNSv4JV0AUxPqoqYuiYFbmrPuBqEmbYZOwP1hxnj2U AFF43o8ywGK5zbzfs9Mu+uH3Q0XAlFzPYBbWACUzvAT62P5zTDSes/tyLTJUzJivn2wZov KEFK5BNIuqmf3rlEPm+sYiUNXj2y7pr3Hr9MF2p2aPlqfGLJaxHNCTmX9hUjFg== 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 79B8F15CD7; Sat, 18 Jun 2022 14:16:47 +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 25IEGlLM034858; Sat, 18 Jun 2022 14:16:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25IEGlJH034857; Sat, 18 Jun 2022 14:16:47 GMT (envelope-from git) Date: Sat, 18 Jun 2022 14:16:47 GMT Message-Id: <202206181416.25IEGlJH034857@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 14cd9da9db03 - stable/13 - fusefs: make the mknod.cc tests a bit more general. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 14cd9da9db03d98c1581489f2e8766925bc2a17d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655561807; 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=Oiu+2LhYPUIpV0/6vq5Kt5H5vOHTQ1DeToGzu+qlF00=; b=S/nK6kp76+lcQEdc959CMOIDDDz02e1clm1OliwWMGlUr7kgNqVfdi07uzC6k9DTzkrn5m 6v+GTY4NATznKVB+TIU2c8/QCNuiMWmMDB0UO6xYpQvyvH/SrlxZrmbkYvg8vugpcaNwPO vF7ClGbTrLJxcO//HkJDBAoEMTm49Fmy5LmfrEIMTT1V0VT8QnNX2FMh/qdqxlNTJ2xoBX aUeFijSLWXPqEcGGxK7LFJUXrQPKNfuaquodr9i7owzWX53Ms4ld55skgtE/c+01HB295P JtkkmzEU364GALZH5p71C0suHBZ7k5/tZXw9YkoAoYZF2kmmmzAYjKr0pSG4DQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655561807; a=rsa-sha256; cv=none; b=eWe/eDRcALk6p4WbiXsYKd+YzVL/l0AWm7lSo1lXYFkZoJbP67uxGQ2nyWswKPhCbzZSf7 BZuwb/bQ3nWC1Rhl6DN9GTJN/9spRuizrfRsa5HCfD2TL90I6bhvwNE1ZAXn4we4l6sVQZ 8/FQeTOudgdnq27w0tNz9tbJ+rTHBy+ITI2I+1ghMEfdATIMwW0H+cDXeBqWLVVvEac1B6 B3l4zqBgN+gEJ9tucUttVcKcmoZpt1c4MfczTfFmOjUJ83d3DuqOz3iE3blx9CfwSu7SOb QYnRB0hlhXSLXgyGjhBvzD068oSInCS8ZNktvyHMFJ+tVtqihXyC0mEE1R9JQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=14cd9da9db03d98c1581489f2e8766925bc2a17d commit 14cd9da9db03d98c1581489f2e8766925bc2a17d Author: Alan Somers AuthorDate: 2022-05-03 22:53:20 +0000 Commit: Alan Somers CommitDate: 2022-06-18 14:16:06 +0000 fusefs: make the mknod.cc tests a bit more general. Reviewed by: pfg (cherry picked from commit 8b582b16402102df10a715c626e212bbbc8e9d7c) --- tests/sys/fs/fusefs/mknod.cc | 85 +++++++++++++++++++++++++++++++------------- 1 file changed, 60 insertions(+), 25 deletions(-) diff --git a/tests/sys/fs/fusefs/mknod.cc b/tests/sys/fs/fusefs/mknod.cc index 5e16472cbe90..7bb8e116c3f8 100644 --- a/tests/sys/fs/fusefs/mknod.cc +++ b/tests/sys/fs/fusefs/mknod.cc @@ -45,9 +45,6 @@ using namespace testing; #define VNOVAL (-1) /* Defined in sys/vnode.h */ #endif -const char FULLPATH[] = "mountpoint/some_file.txt"; -const char RELPATH[] = "some_file.txt"; - class Mknod: public FuseTest { mode_t m_oldmask; @@ -72,21 +69,19 @@ virtual void TearDown() { } /* Test an OK creation of a file with the given mode and device number */ -void expect_mknod(mode_t mode, dev_t dev) { - uint64_t ino = 42; - - EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH) - .WillOnce(Invoke(ReturnErrno(ENOENT))); - +void expect_mknod(uint64_t parent_ino, const char* relpath, uint64_t ino, + mode_t mode, dev_t dev) +{ EXPECT_CALL(*m_mock, process( ResultOf([=](auto in) { const char *name = (const char*)in.body.bytes + sizeof(fuse_mknod_in); - return (in.header.opcode == FUSE_MKNOD && + return (in.header.nodeid == parent_ino && + in.header.opcode == FUSE_MKNOD && in.body.mknod.mode == mode && in.body.mknod.rdev == (uint32_t)dev && in.body.mknod.umask == c_umask && - (0 == strcmp(RELPATH, name))); + (0 == strcmp(relpath, name))); }, Eq(true)), _) ).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) { @@ -117,20 +112,18 @@ void expect_lookup(const char *relpath, uint64_t ino, uint64_t size) } /* Test an OK creation of a file with the given mode and device number */ -void expect_mknod(mode_t mode, dev_t dev) { - uint64_t ino = 42; - - EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH) - .WillOnce(Invoke(ReturnErrno(ENOENT))); - +void expect_mknod(uint64_t parent_ino, const char* relpath, uint64_t ino, + mode_t mode, dev_t dev) +{ EXPECT_CALL(*m_mock, process( ResultOf([=](auto in) { const char *name = (const char*)in.body.bytes + FUSE_COMPAT_MKNOD_IN_SIZE; - return (in.header.opcode == FUSE_MKNOD && + return (in.header.nodeid == parent_ino && + in.header.opcode == FUSE_MKNOD && in.body.mknod.mode == mode && in.body.mknod.rdev == (uint32_t)dev && - (0 == strcmp(RELPATH, name))); + (0 == strcmp(relpath, name))); }, Eq(true)), _) ).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) { @@ -152,17 +145,31 @@ void expect_mknod(mode_t mode, dev_t dev) { */ TEST_F(Mknod, blk) { + const char FULLPATH[] = "mountpoint/some_node"; + const char RELPATH[] = "some_node"; mode_t mode = S_IFBLK | 0755; dev_t rdev = 0xfe00; /* /dev/vda's device number on Linux */ - expect_mknod(mode, rdev); + uint64_t ino = 42; + + EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH) + .WillOnce(Invoke(ReturnErrno(ENOENT))); + expect_mknod(FUSE_ROOT_ID, RELPATH, ino, mode, rdev); + EXPECT_EQ(0, mknod(FULLPATH, mode, rdev)) << strerror(errno); } TEST_F(Mknod, chr) { + const char FULLPATH[] = "mountpoint/some_node"; + const char RELPATH[] = "some_node"; mode_t mode = S_IFCHR | 0755; dev_t rdev = 54; /* /dev/fuse's device number */ - expect_mknod(mode, rdev); + uint64_t ino = 42; + + EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH) + .WillOnce(Invoke(ReturnErrno(ENOENT))); + expect_mknod(FUSE_ROOT_ID, RELPATH, ino, mode, rdev); + EXPECT_EQ(0, mknod(FULLPATH, mode, rdev)) << strerror(errno); } @@ -172,6 +179,8 @@ TEST_F(Mknod, chr) */ TEST_F(Mknod, eperm) { + const char FULLPATH[] = "mountpoint/some_node"; + const char RELPATH[] = "some_node"; mode_t mode = S_IFIFO | 0755; EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH) @@ -193,9 +202,16 @@ TEST_F(Mknod, eperm) TEST_F(Mknod, fifo) { + const char FULLPATH[] = "mountpoint/some_node"; + const char RELPATH[] = "some_node"; mode_t mode = S_IFIFO | 0755; dev_t rdev = VNOVAL; /* Fifos don't have device numbers */ - expect_mknod(mode, rdev); + uint64_t ino = 42; + + EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH) + .WillOnce(Invoke(ReturnErrno(ENOENT))); + expect_mknod(FUSE_ROOT_ID, RELPATH, ino, mode, rdev); + EXPECT_EQ(0, mkfifo(FULLPATH, mode)) << strerror(errno); } @@ -206,12 +222,17 @@ TEST_F(Mknod, fifo) */ TEST_F(Mknod, socket) { + const char FULLPATH[] = "mountpoint/some_node"; + const char RELPATH[] = "some_node"; mode_t mode = S_IFSOCK | 0755; struct sockaddr_un sa; int fd; dev_t rdev = -1; /* Really it's a don't care */ + uint64_t ino = 42; - expect_mknod(mode, rdev); + EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH) + .WillOnce(Invoke(ReturnErrno(ENOENT))); + expect_mknod(FUSE_ROOT_ID, RELPATH, ino, mode, rdev); fd = socket(AF_UNIX, SOCK_STREAM, 0); ASSERT_LE(0, fd) << strerror(errno); @@ -230,17 +251,31 @@ TEST_F(Mknod, socket) */ TEST_F(Mknod, DISABLED_whiteout) { + const char FULLPATH[] = "mountpoint/some_node"; + const char RELPATH[] = "some_node"; mode_t mode = S_IFWHT | 0755; dev_t rdev = VNOVAL; /* whiteouts don't have device numbers */ - expect_mknod(mode, rdev); + uint64_t ino = 42; + + EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH) + .WillOnce(Invoke(ReturnErrno(ENOENT))); + expect_mknod(FUSE_ROOT_ID, RELPATH, ino, mode, rdev); + EXPECT_EQ(0, mknod(FULLPATH, mode, 0)) << strerror(errno); } /* A server built at protocol version 7.11 or earlier can still use mknod */ TEST_F(Mknod_7_11, fifo) { + const char FULLPATH[] = "mountpoint/some_node"; + const char RELPATH[] = "some_node"; mode_t mode = S_IFIFO | 0755; dev_t rdev = VNOVAL; - expect_mknod(mode, rdev); + uint64_t ino = 42; + + EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH) + .WillOnce(Invoke(ReturnErrno(ENOENT))); + expect_mknod(FUSE_ROOT_ID, RELPATH, ino, mode, rdev); + EXPECT_EQ(0, mkfifo(FULLPATH, mode)) << strerror(errno); }