From fcf817fbddcbf5cecb40fcec9293fbcfe0ec30b8 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sun, 14 Feb 2016 01:18:19 +0100 Subject: [PATCH] Work around timing bug in OS X test cases --- src/fspp/fuse/Fuse.cpp | 6 +++--- test/fspp/testutils/FuseThread.cpp | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/fspp/fuse/Fuse.cpp b/src/fspp/fuse/Fuse.cpp index 2cd1f748..2343fa4b 100644 --- a/src/fspp/fuse/Fuse.cpp +++ b/src/fspp/fuse/Fuse.cpp @@ -777,18 +777,18 @@ int Fuse::fsyncdir(const bf::path &path, int datasync, fuse_file_info *fileinfo) void Fuse::init(fuse_conn_info *conn) { UNUSED(conn); + LOG(INFO) << "Filesystem started."; + _running = true; #ifdef FSPP_LOG cpputils::logging::setLevel(DEBUG); #endif - - LOG(INFO) << "Filesystem started."; } void Fuse::destroy() { - _running = false; LOG(INFO) << "Filesystem stopped."; + _running = false; } int Fuse::access(const bf::path &path, int mask) { diff --git a/test/fspp/testutils/FuseThread.cpp b/test/fspp/testutils/FuseThread.cpp index 4c6e95f2..21fab489 100644 --- a/test/fspp/testutils/FuseThread.cpp +++ b/test/fspp/testutils/FuseThread.cpp @@ -22,6 +22,10 @@ void FuseThread::start(int argc, char *argv[]) { }); //Wait until it is running (busy waiting is simple and doesn't hurt much here) while(!_fuse->running()) {} +#ifdef __APPLE__ + // On Mac OS X, _fuse->running() returns true too early, because osxfuse calls init() when it's not ready yet. Give it a bit time. + std::this_thread::sleep_for(std::chrono::milliseconds(200)); +#endif } void FuseThread::stop() {