Date: Fri, 10 May 2019 16:58:05 +0000 (UTC) From: Alan Somers <asomers@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r347444 - projects/fuse2/tests/sys/fs/fusefs Message-ID: <201905101658.x4AGw58p093305@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: asomers Date: Fri May 10 16:58:05 2019 New Revision: 347444 URL: https://svnweb.freebsd.org/changeset/base/347444 Log: fusefs: fix intermittency in the Destroy.ok test The handler for FUSE_DESTROY must shut down the daemon. Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/tests/sys/fs/fusefs/destroy.cc projects/fuse2/tests/sys/fs/fusefs/mockfs.cc projects/fuse2/tests/sys/fs/fusefs/mockfs.hh Modified: projects/fuse2/tests/sys/fs/fusefs/destroy.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/destroy.cc Fri May 10 16:51:36 2019 (r347443) +++ projects/fuse2/tests/sys/fs/fusefs/destroy.cc Fri May 10 16:58:05 2019 (r347444) @@ -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; + })));} }; Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Fri May 10 16:51:36 2019 (r347443) +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Fri May 10 16:58:05 2019 (r347444) @@ -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, bo 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) { Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.hh ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/mockfs.hh Fri May 10 16:51:36 2019 (r347443) +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.hh Fri May 10 16:58:05 2019 (r347444) @@ -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,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905101658.x4AGw58p093305>