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