From 8340b1290f35587eb9579e1980639bc6a660e3fc Mon Sep 17 00:00:00 2001 From: Firelight Flagboy Date: Wed, 29 May 2024 11:02:25 +0200 Subject: [PATCH 01/13] Add job to run tests on macOS --- .github/workflows/ci.yml | 14 ++++++++++++++ examples/simple.rs | 6 ++++++ tests/integration_tests.rs | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 629dce65..917f4703 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,3 +63,17 @@ jobs: - name: Run tests run: INTERACTIVE="" make ${{ matrix.test_group }} + + test-mac: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Install macfuse + run: brew install --cask macfuse + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Run tests + run: cargo test + timeout-minutes: 5 # The test `mnt::test::mount_unmount` don't seems to finish on macos diff --git a/examples/simple.rs b/examples/simple.rs index 12469f38..762bbc64 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1098,6 +1098,9 @@ impl Filesystem for SimpleFS { flags: u32, reply: ReplyEmpty, ) { + #[cfg(target_os = "macos")] + let _ = flags; + let mut inode_attrs = match self.lookup_name(parent, name) { Ok(attrs) => attrs, Err(error_code) => { @@ -1922,6 +1925,9 @@ fn as_file_kind(mut mode: u32) -> FileKind { } fn get_groups(pid: u32) -> Vec { + #[cfg(target_os = "macos")] + let _ = pid; + #[cfg(not(target_os = "macos"))] { let path = format!("/proc/{pid}/task/{pid}/status"); diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 0ed8c804..69fd8d33 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -5,7 +5,7 @@ use std::time::Duration; use tempfile::TempDir; #[test] -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "macos"))] fn unmount_no_send() { // Rc to make this !Send struct NoSendFS(Rc<()>); From 0ca793384aa51cc1ad79bf11aa90c8a1b087e632 Mon Sep 17 00:00:00 2001 From: FirelightFlagboy Date: Thu, 30 May 2024 16:21:43 +0200 Subject: [PATCH 02/13] Disable mount_unmount test for macos --- src/mnt/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mnt/mod.rs b/src/mnt/mod.rs index 79d283cc..5d210f44 100644 --- a/src/mnt/mod.rs +++ b/src/mnt/mod.rs @@ -155,7 +155,8 @@ mod test { .unwrap() .to_owned() } - + // Mountpoint are not directly visible on MacOS. + #[cfg(not(target_os = "macos"))] #[test] fn mount_unmount() { // We use ManuallyDrop here to leak the directory on test failure. We don't From 9d893f41aa71402a1e15fbdeda1c848704c0727d Mon Sep 17 00:00:00 2001 From: FirelightFlagboy Date: Thu, 30 May 2024 16:23:50 +0200 Subject: [PATCH 03/13] Execute osx mount test --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 917f4703..23231f89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,4 +76,8 @@ jobs: - name: Run tests run: cargo test - timeout-minutes: 5 # The test `mnt::test::mount_unmount` don't seems to finish on macos + timeout-minutes: 5 + + - name: Run mount test + run: ./osx_mount_test.sh + timeout-minutes: 5 From 50ddadab593fd2fce62cac3bd142774c8a482a73 Mon Sep 17 00:00:00 2001 From: Firelight Flagboy Date: Thu, 30 May 2024 16:28:32 +0200 Subject: [PATCH 04/13] Fix unused ManuallyDrop --- src/mnt/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mnt/mod.rs b/src/mnt/mod.rs index 5d210f44..d3b1cb87 100644 --- a/src/mnt/mod.rs +++ b/src/mnt/mod.rs @@ -121,7 +121,7 @@ fn is_mounted(fuse_device: &File) -> bool { #[cfg(test)] mod test { use super::*; - use std::{ffi::CStr, mem::ManuallyDrop}; + use std::ffi::CStr; #[test] fn fuse_args() { @@ -155,10 +155,12 @@ mod test { .unwrap() .to_owned() } - // Mountpoint are not directly visible on MacOS. + // Mountpoint are not directly available on MacOS. #[cfg(not(target_os = "macos"))] #[test] fn mount_unmount() { + use std::mem::ManuallyDrop; + // We use ManuallyDrop here to leak the directory on test failure. We don't // want to try and clean up the directory if it's a mountpoint otherwise we'll // deadlock. From aea5e5d04ad59e0559c5a122533581b3db3892dc Mon Sep 17 00:00:00 2001 From: Firelight Flagboy Date: Thu, 30 May 2024 16:28:47 +0200 Subject: [PATCH 05/13] Use libfuse features in CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23231f89..bef34b5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,7 +75,7 @@ jobs: - uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Run tests - run: cargo test + run: cargo test --features=libfuse timeout-minutes: 5 - name: Run mount test From 1ed6606c41d710470df691caf75f47c8defefe1f Mon Sep 17 00:00:00 2001 From: Firelight Flagboy Date: Thu, 30 May 2024 16:33:42 +0200 Subject: [PATCH 06/13] Fix unused variable warning on macOS --- src/mnt/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mnt/mod.rs b/src/mnt/mod.rs index d3b1cb87..b7ce0ce7 100644 --- a/src/mnt/mod.rs +++ b/src/mnt/mod.rs @@ -87,7 +87,7 @@ fn libc_umount(mnt: &CStr) -> io::Result<()> { /// Warning: This will return true if the filesystem has been detached (lazy unmounted), but not /// yet destroyed by the kernel. -#[cfg(any(test, not(feature = "libfuse")))] +#[cfg(any(all(test, not(target_os = "macos")), not(feature = "libfuse")))] fn is_mounted(fuse_device: &File) -> bool { use libc::{poll, pollfd}; use std::os::unix::prelude::AsRawFd; @@ -142,6 +142,8 @@ mod test { }, ); } + + #[cfg(not(target_os = "macos"))] fn cmd_mount() -> String { std::str::from_utf8( std::process::Command::new("sh") @@ -155,6 +157,7 @@ mod test { .unwrap() .to_owned() } + // Mountpoint are not directly available on MacOS. #[cfg(not(target_os = "macos"))] #[test] From 8f0057bc7445a46be0533247667118d09a77c6af Mon Sep 17 00:00:00 2001 From: Firelight Flagboy Date: Thu, 30 May 2024 16:35:54 +0200 Subject: [PATCH 07/13] Fix unused --- src/mnt/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mnt/mod.rs b/src/mnt/mod.rs index b7ce0ce7..73c5d1c2 100644 --- a/src/mnt/mod.rs +++ b/src/mnt/mod.rs @@ -17,7 +17,7 @@ pub mod mount_options; #[cfg(any(feature = "libfuse", test))] use fuse2_sys::fuse_args; -#[cfg(any(test, not(feature = "libfuse")))] +#[cfg(any(all(test, not(target_os = "macos")), not(feature = "libfuse")))] use std::fs::File; #[cfg(any(test, not(feature = "libfuse"), not(feature = "libfuse3")))] use std::io; From 4139d4f2d26129ec888d838334ec21a275908e6b Mon Sep 17 00:00:00 2001 From: Firelight Flagboy Date: Fri, 31 May 2024 09:51:34 +0200 Subject: [PATCH 08/13] Add debug log for integration tests --- .github/workflows/ci.yml | 2 ++ tests/integration_tests.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bef34b5f..5aaa880e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,6 +76,8 @@ jobs: - name: Run tests run: cargo test --features=libfuse + env: + RUST_LOG: DEBUG timeout-minutes: 5 - name: Run mount test diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 69fd8d33..1bbd1345 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -8,16 +8,22 @@ use tempfile::TempDir; #[cfg(any(target_os = "linux", target_os = "macos"))] fn unmount_no_send() { // Rc to make this !Send + env_logger::init(); struct NoSendFS(Rc<()>); impl Filesystem for NoSendFS {} let tmpdir: TempDir = tempfile::tempdir().unwrap(); let mut session = Session::new(NoSendFS(Rc::new(())), tmpdir.path(), &[]).unwrap(); + log::debug!("Session created"); let mut unmounter = session.unmount_callable(); thread::spawn(move || { thread::sleep(Duration::from_secs(1)); + log::debug!("unmounting"); unmounter.unmount().unwrap(); + log::debug!("unmounted"); }); + log::debug!("running session"); session.run().unwrap(); + log::debug!("session finished") } From 4f4962b1c0ac9845ebd0ce985317cd33e5884414 Mon Sep 17 00:00:00 2001 From: Firelight Flagboy Date: Fri, 31 May 2024 10:03:21 +0200 Subject: [PATCH 09/13] Install macfuse kernel extension --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5aaa880e..d2ec7b24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,7 +70,11 @@ jobs: - uses: actions/checkout@v4 - name: Install macfuse - run: brew install --cask macfuse + run: | + set -x + brew install --cask macfuse + LASTEST_EXTENSION_VERSION=$(ls /Library/Filesystems/macfuse.fs/Contents/Extensions/ | sort -n | tail -n 1) + sudo kextload /Library/Filesystems/macfuse.fs/Contents/Extensions/$LASTEST_EXTENSION_VERSION/macfuse.kext - uses: actions-rust-lang/setup-rust-toolchain@v1 From 499470ac393c3049d23a445354a91afc4e7fe807 Mon Sep 17 00:00:00 2001 From: Firelight Flagboy Date: Fri, 31 May 2024 10:05:39 +0200 Subject: [PATCH 10/13] Disable system integrity protection to install macfuse headless --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2ec7b24..f79fd240 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,7 @@ jobs: - name: Install macfuse run: | set -x + csrutil disable # Disable system integrity protection to install macfuse headless brew install --cask macfuse LASTEST_EXTENSION_VERSION=$(ls /Library/Filesystems/macfuse.fs/Contents/Extensions/ | sort -n | tail -n 1) sudo kextload /Library/Filesystems/macfuse.fs/Contents/Extensions/$LASTEST_EXTENSION_VERSION/macfuse.kext From 10be6bf118e3396be36555ba881a4548726e940b Mon Sep 17 00:00:00 2001 From: Firelight Flagboy Date: Fri, 31 May 2024 10:08:14 +0200 Subject: [PATCH 11/13] Revert to just brew install macfuse --- .github/workflows/ci.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f79fd240..5aaa880e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,12 +70,7 @@ jobs: - uses: actions/checkout@v4 - name: Install macfuse - run: | - set -x - csrutil disable # Disable system integrity protection to install macfuse headless - brew install --cask macfuse - LASTEST_EXTENSION_VERSION=$(ls /Library/Filesystems/macfuse.fs/Contents/Extensions/ | sort -n | tail -n 1) - sudo kextload /Library/Filesystems/macfuse.fs/Contents/Extensions/$LASTEST_EXTENSION_VERSION/macfuse.kext + run: brew install --cask macfuse - uses: actions-rust-lang/setup-rust-toolchain@v1 From 842c028c1ebf70288153843f62249510dee5170d Mon Sep 17 00:00:00 2001 From: Firelight Flagboy Date: Fri, 31 May 2024 10:08:31 +0200 Subject: [PATCH 12/13] Run osx-mount-test first --- .github/workflows/ci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5aaa880e..cd9f3133 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,12 +74,15 @@ jobs: - uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Run mount test + run: ./osx_mount_test.sh + env: + RUST_LOG: DEBUG + timeout-minutes: 5 + - name: Run tests run: cargo test --features=libfuse env: RUST_LOG: DEBUG timeout-minutes: 5 - - name: Run mount test - run: ./osx_mount_test.sh - timeout-minutes: 5 From 2d79641b4f0f6ee0c3418501d2380f610af0a225 Mon Sep 17 00:00:00 2001 From: Firelight Flagboy Date: Fri, 31 May 2024 10:10:42 +0200 Subject: [PATCH 13/13] fix typo in osx_mount_tests.sh --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd9f3133..89ad88ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,7 +75,7 @@ jobs: - uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Run mount test - run: ./osx_mount_test.sh + run: ./osx_mount_tests.sh env: RUST_LOG: DEBUG timeout-minutes: 5