libfuse_fs/lib.rs
1// #[macro_use]
2// extern crate log;
3
4pub mod context;
5pub mod overlayfs;
6pub mod passthrough;
7mod server;
8pub mod unionfs;
9pub mod util;
10
11// Test utilities (only compiled during tests)
12#[cfg(test)]
13pub mod test_utils {
14 /// Macro: unwrap result or skip test when encountering EPERM (Permission denied).
15 ///
16 /// Behavior:
17 /// - On Ok(v): returns v
18 /// - On Err(e) where e -> io::Error has raw_os_error()==EPERM (or PermissionDenied):
19 /// * If env RUN_PRIVILEGED_TESTS=1 -> panic (treat as hard failure)
20 /// * Else: print a line indicating skip and `return` from test (so test counted as ignored when used with #[ignore]).
21 /// - On Err(e) other than EPERM -> panic with diagnostic.
22 ///
23 /// Usage examples:
24 /// let handle = unwrap_or_skip_eperm!(some_async_call.await, "mount session");
25 #[macro_export]
26 macro_rules! unwrap_or_skip_eperm {
27 ($expr:expr, $ctx:expr) => {{
28 match $expr {
29 Ok(v) => v,
30 Err(e) => {
31 let ioerr: std::io::Error = e.into();
32 let is_eperm = ioerr.raw_os_error() == Some(libc::EPERM)
33 || ioerr.kind() == std::io::ErrorKind::PermissionDenied;
34 if is_eperm {
35 if std::env::var("RUN_PRIVILEGED_TESTS").ok().as_deref() == Some("1") {
36 panic!(
37 "{} failed with EPERM while RUN_PRIVILEGED_TESTS=1: {:?}",
38 $ctx, ioerr
39 );
40 } else {
41 eprintln!("skip (EPERM) {}: {:?}", $ctx, ioerr);
42 return;
43 }
44 }
45 panic!("{} unexpected error: {:?}", $ctx, ioerr);
46 }
47 }
48 }};
49 }
50}