mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
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)
This commit is contained in:
parent
032a0b4454
commit
af20b22016
3 changed files with 15 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue