fusefs: fix intermittency in the Destroy.ok test

The handler for FUSE_DESTROY must shut down the daemon.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Alan Somers 2019-05-10 16:58:05 +00:00
parent 7e0aac2408
commit 81a619c4e1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/fuse2/; revision=347444
3 changed files with 15 additions and 9 deletions

View File

@ -42,8 +42,12 @@ void expect_destroy(int error)
return (in->header.opcode == FUSE_DESTROY);
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnErrno(error)));
}
).WillOnce(Invoke( ReturnImmediate([&](auto in, auto out) {
m_mock->m_quit = true;
out->header.len = sizeof(out->header);
out->header.unique = in->header.unique;
out->header.error = -error;
})));}
};

View File

@ -53,7 +53,6 @@ extern "C" {
using namespace testing;
int verbosity = 0;
static sig_atomic_t quit = 0;
const char* opcode2opname(uint32_t opcode)
{
@ -288,7 +287,7 @@ MockFS::MockFS(int max_readahead, bool allow_other, bool default_permissions,
m_daemon_id = NULL;
m_maxreadahead = max_readahead;
quit = 0;
m_quit = false;
/*
* Kyua sets pwd to a testcase-unique tempdir; no need to use
@ -399,7 +398,7 @@ void MockFS::init(uint32_t flags) {
}
void MockFS::kill_daemon() {
quit = 1;
m_quit = true;
if (m_daemon_id != NULL)
pthread_kill(m_daemon_id, SIGUSR1);
// Closing the /dev/fuse file descriptor first allows unmount to
@ -415,10 +414,10 @@ void MockFS::loop() {
in = (mockfs_buf_in*) malloc(sizeof(*in));
ASSERT_TRUE(in != NULL);
while (!quit) {
while (!m_quit) {
bzero(in, sizeof(*in));
read_request(in);
if (quit)
if (m_quit)
break;
if (verbosity > 0)
debug_fuseop(in);
@ -483,9 +482,9 @@ void MockFS::read_request(mockfs_buf_in *in) {
ssize_t res;
res = read(m_fuse_fd, in, sizeof(*in));
if (res < 0 && !quit)
if (res < 0 && !m_quit)
perror("read");
ASSERT_TRUE(res >= (ssize_t)sizeof(in->header) || quit);
ASSERT_TRUE(res >= (ssize_t)sizeof(in->header) || m_quit);
}
void* MockFS::service(void *pthr_data) {

View File

@ -212,6 +212,9 @@ class MockFS {
/* Maximum size of a FUSE_WRITE write */
uint32_t m_max_write;
/* Tell the daemon to shut down ASAP */
bool m_quit;
/* Create a new mockfs and mount it to a tempdir */
MockFS(int max_readahead, bool allow_other,
bool default_permissions, bool push_symlinks_in, bool ro,