Skip to content

Commit

Permalink
Fix intermittency in the sys.fs.fusefs.mknod.main test
Browse files Browse the repository at this point in the history
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.

MFC after:	2 weeks
Sponsored by:	Axcient
  • Loading branch information
asomers committed Oct 6, 2023
1 parent 03205a8 commit 86885b1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/sys/fs/fusefs/mknod.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extern "C" {
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <semaphore.h>
}

#include "mockfs.hh"
Expand Down Expand Up @@ -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);
Expand All @@ -273,6 +278,8 @@ TEST_F(Mknod, parent_inode)
ASSERT_EQ(EIO, errno);

leak(fd);
sem_wait(&sem);
sem_destroy(&sem);
}

/*
Expand Down

0 comments on commit 86885b1

Please sign in to comment.