Skip to content

Commit

Permalink
fix: test mount
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Oct 18, 2024
1 parent 208a8d6 commit 3828a13
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions remotefs-fuse/tests/fuse/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::path::Path;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::thread::JoinHandle;
use std::time::Duration;

Expand All @@ -9,15 +11,23 @@ use tempfile::TempDir;
/// The filesystem must be unmounted manually and then the thread must be joined.
fn mount(p: &Path) -> JoinHandle<()> {
let mountpoint = p.to_path_buf();
let error_flag = Arc::new(AtomicBool::new(false));
let error_flag_t = error_flag.clone();

let join = std::thread::spawn(move || {
let driver = crate::driver::setup_driver();
// this operation is blocking and will not return until the filesystem is unmounted
assert!(remotefs_fuse::mount(driver, &mountpoint, &[]).is_ok());

// set the error flag if the filesystem was unmounted
error_flag_t.store(true, std::sync::atomic::Ordering::Relaxed);
});

// wait for the filesystem to be mounted
std::thread::sleep(Duration::from_secs(1));
if error_flag.load(std::sync::atomic::Ordering::Relaxed) {
panic!("Failed to mount filesystem");
}

join
}
Expand Down

0 comments on commit 3828a13

Please sign in to comment.