Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/fs/fusefs/read.cc
Show First 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | TEST_F(AsyncRead, async_read) | ||||
m_mock->kill_daemon(); | m_mock->kill_daemon(); | ||||
/* Wait for AIO activity to complete, but ignore errors */ | /* Wait for AIO activity to complete, but ignore errors */ | ||||
(void)aio_waitcomplete(NULL, NULL); | (void)aio_waitcomplete(NULL, NULL); | ||||
leak(fd); | leak(fd); | ||||
} | } | ||||
/* | |||||
* Regression test for a VFS locking bug: as of | |||||
* b3c6fe663bb90240f8bda6b5ba9c6a761f09f078 (8-February-2021), fusefs did not | |||||
cem: I'm not seeing this hash; is it in the canonical freebsd git tree? | |||||
* obtain an exclusive vnode lock before attempting to clear the attr cache | |||||
* after an unexpected eof. The vnode lock would already be exclusive except | |||||
* when FUSE_ASYNC_READ is set. | |||||
*/ | |||||
TEST_F(AsyncRead, eof) | |||||
{ | |||||
const char FULLPATH[] = "mountpoint/some_file.txt"; | |||||
const char RELPATH[] = "some_file.txt"; | |||||
const char *CONTENTS = "abcdefghijklmnop"; | |||||
uint64_t ino = 42; | |||||
int fd; | |||||
uint64_t offset = 100; | |||||
ssize_t bufsize = strlen(CONTENTS); | |||||
ssize_t partbufsize = 3 * bufsize / 4; | |||||
ssize_t r; | |||||
uint8_t buf[bufsize]; | |||||
struct stat sb; | |||||
expect_lookup(RELPATH, ino, offset + bufsize); | |||||
expect_open(ino, 0, 1); | |||||
expect_read(ino, 0, offset + bufsize, offset + partbufsize, CONTENTS); | |||||
expect_getattr(ino, offset + partbufsize); | |||||
fd = open(FULLPATH, O_RDONLY); | |||||
ASSERT_LE(0, fd) << strerror(errno); | |||||
r = pread(fd, buf, bufsize, offset); | |||||
ASSERT_LE(0, r) << strerror(errno); | |||||
EXPECT_EQ(partbufsize, r) << strerror(errno); | |||||
ASSERT_EQ(0, fstat(fd, &sb)); | |||||
EXPECT_EQ((off_t)(offset + partbufsize), sb.st_size); | |||||
leak(fd); | |||||
} | |||||
/* 0-length reads shouldn't cause any confusion */ | /* 0-length reads shouldn't cause any confusion */ | ||||
TEST_F(Read, direct_io_read_nothing) | TEST_F(Read, direct_io_read_nothing) | ||||
{ | { | ||||
const char FULLPATH[] = "mountpoint/some_file.txt"; | const char FULLPATH[] = "mountpoint/some_file.txt"; | ||||
const char RELPATH[] = "some_file.txt"; | const char RELPATH[] = "some_file.txt"; | ||||
uint64_t ino = 42; | uint64_t ino = 42; | ||||
int fd; | int fd; | ||||
uint64_t offset = 100; | uint64_t offset = 100; | ||||
▲ Show 20 Lines • Show All 610 Lines • Show Last 20 Lines |
I'm not seeing this hash; is it in the canonical freebsd git tree?