Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Oct 2023 21:40:39 GMT
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: bc417deae52a - releng/14.0 - Fix intermittency in the sys.fs.fusefs.mknod.main test
Message-ID:  <202310212140.39LLed88095792@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/14.0 has been updated by asomers:

URL: https://cgit.FreeBSD.org/src/commit/?id=bc417deae52aa6a75003687d4f78cff89a3e569e

commit bc417deae52aa6a75003687d4f78cff89a3e569e
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2023-10-06 19:46:42 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2023-10-21 21:40:11 +0000

    Fix intermittency in the sys.fs.fusefs.mknod.main test
    
    In the Mknod.parent_inode test case, the kernel sends an extra
    FUSE_FORGET message.  But because it gets sent asynchronously with the
    failing syscall, it doesn't always get received before the test ends.
    So we never setup an expectation for it.  And 90+% of the time the test
    would exit successfully.
    
    Fix the intermittency by always waiting to receive the FUSE_FORGET
    message.
    
    Sponsored by:   Axcient
    
    (cherry picked from commit 86885b18689889e9b9142fd31d8c67f21334ba32)
    
    Fix intermittency in the sys.fs.fusefs.symlink.main test
    
    This change is identical to 86885b18689 but for symlink instead of
    mknod.  The kernel sends a FUSE_FORGET asynchronously with the final
    syscall.  The lack of an expectation caused this test to occasionally
    fail.
    
    Also, remove a sleep that accidentally snuck into a different test.
    
    Sponsored by:   Axcient
    
    (cherry picked from commit 8399d764c929a4b2fa98dbfae0ca7359810e4668)
    (cherry picked from commit af20b2201669ea493de58ba7a5e5ff1138b80cd7)
    
    Approved by:    cperciva (re)
---
 tests/sys/fs/fusefs/mkdir.cc   | 1 -
 tests/sys/fs/fusefs/mknod.cc   | 7 +++++++
 tests/sys/fs/fusefs/symlink.cc | 8 ++++++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/tests/sys/fs/fusefs/mkdir.cc b/tests/sys/fs/fusefs/mkdir.cc
index 48453ff8bb8a..f020feb94ed8 100644
--- a/tests/sys/fs/fusefs/mkdir.cc
+++ b/tests/sys/fs/fusefs/mkdir.cc
@@ -241,7 +241,6 @@ TEST_F(Mkdir, parent_inode)
 
 	ASSERT_EQ(-1, mkdir(FULLPATH, mode));
 	ASSERT_EQ(EIO, errno);
-	usleep(100000);
 }
 
 TEST_F(Mkdir_7_8, ok)
diff --git a/tests/sys/fs/fusefs/mknod.cc b/tests/sys/fs/fusefs/mknod.cc
index 223d38f8acb1..1fb855f44f29 100644
--- a/tests/sys/fs/fusefs/mknod.cc
+++ b/tests/sys/fs/fusefs/mknod.cc
@@ -32,6 +32,7 @@ extern "C" {
 #include <fcntl.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <semaphore.h>
 }
 
 #include "mockfs.hh"
@@ -255,14 +256,18 @@ TEST_F(Mknod, parent_inode)
 	const char RELPATH[] = "some_node";
 	mode_t mode = S_IFSOCK | 0755;
 	struct sockaddr_un sa;
+	sem_t sem;
 	int fd;
 	dev_t rdev = -1;	/* Really it's a don't care */
 	uint64_t ino = 42;
 
+	ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno);
+
 	expect_lookup(PPATH, ino, S_IFDIR | 0755, 0, 1);
 	EXPECT_LOOKUP(ino, RELPATH)
 	.WillOnce(Invoke(ReturnErrno(ENOENT)));
 	expect_mknod(ino, RELPATH, ino, mode, rdev);
+	expect_forget(ino, 1, &sem);
 
 	fd = socket(AF_UNIX, SOCK_STREAM, 0);
 	ASSERT_LE(0, fd) << strerror(errno);
@@ -273,6 +278,8 @@ TEST_F(Mknod, parent_inode)
 	ASSERT_EQ(EIO, errno);
 
 	leak(fd);
+	sem_wait(&sem);
+	sem_destroy(&sem);
 }
 
 /* 
diff --git a/tests/sys/fs/fusefs/symlink.cc b/tests/sys/fs/fusefs/symlink.cc
index 19286a446fc3..bd355497a8bd 100644
--- a/tests/sys/fs/fusefs/symlink.cc
+++ b/tests/sys/fs/fusefs/symlink.cc
@@ -29,6 +29,7 @@
  */
 
 extern "C" {
+#include <semaphore.h>
 #include <unistd.h>
 }
 
@@ -174,15 +175,22 @@ TEST_F(Symlink, parent_ino)
 	const char PPATH[] = "parent";
 	const char RELPATH[] = "src";
 	const char dst[] = "dst";
+	sem_t sem;
 	const uint64_t ino = 42;
 
+	ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno);
+
 	expect_lookup(PPATH, ino, S_IFDIR | 0755, 0, 1);
 	EXPECT_LOOKUP(ino, RELPATH)
 	.WillOnce(Invoke(ReturnErrno(ENOENT)));
 	expect_symlink(ino, dst, RELPATH);
+	expect_forget(ino, 1, &sem);
 
 	EXPECT_EQ(-1, symlink(dst, FULLPATH));
 	EXPECT_EQ(EIO, errno);
+
+	sem_wait(&sem);
+	sem_destroy(&sem);
 }
 
 TEST_F(Symlink_7_8, ok)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202310212140.39LLed88095792>