From fc4c2470a190a828ff41162e5f98dc2aa83366e3 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Fri, 26 Sep 2025 01:00:53 +0700 Subject: [PATCH] Fix test --- src/unmount.rs | 2 +- tests/tests.rs | 31 ++++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/unmount.rs b/src/unmount.rs index 2b07d68f84..368fd5910f 100644 --- a/src/unmount.rs +++ b/src/unmount.rs @@ -33,7 +33,7 @@ fn unmount_linux_path(mount_path: &str) -> io::Result { pub fn unmount_path(mount_path: &str) -> Result<(), io::Error> { if cfg!(target_os = "redox") { - fs::remove_file(format!("{}", mount_path))? + fs::remove_file(format!(":{}", mount_path))? } else { let status_res = if cfg!(target_os = "linux") { unmount_linux_path(mount_path) diff --git a/tests/tests.rs b/tests/tests.rs index eac7879c13..3da2961b83 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -49,16 +49,37 @@ where } } else { //FIXME: cargo_bin is broken when cross compiling. This is redoxer specific workaround - env::set_var("CARGO_BIN_EXE_redoxfs", "/root/target/x86_64-unknown-redox/debug/redoxfs"); + env::set_var( + "CARGO_BIN_EXE_redoxfs", + "/root/target/x86_64-unknown-redox/debug/redoxfs", + ); } let mut mount_cmd = Command::cargo_bin("redoxfs").expect("unable to find mount bin"); mount_cmd.arg("-d").arg(dbg!(&fs)).arg(dbg!(&mount_path)); let mut child = mount_cmd.spawn().expect("mount failed to run"); - sleep(Duration::from_millis(200)); + let real_path = if cfg!(target_os = "redox") { + let real_path = dbg!(Path::new("/scheme").join(&mount_path)); + let mut tries = 0; + loop { + if real_path.exists() { + break; + } + tries += 1; + if tries == 10 { + panic!("Fail to wait for mount") + } + println!("{tries}"); + sleep(Duration::from_millis(500)); + } + real_path + } else { + sleep(Duration::from_millis(200)); + let r = Path::new(".").join(&mount_path); + r + }; - let real_path = Path::new(&mount_path); - let res = catch_unwind(AssertUnwindSafe(|| callback(real_path))); + let res = catch_unwind(AssertUnwindSafe(|| callback(&real_path))); sleep(Duration::from_millis(200)); @@ -126,7 +147,7 @@ fn create_and_remove_directory() { let dir_path = path.join(dir_name); // Create the directory - fs::create_dir(&dir_path).unwrap(); + fs::create_dir(&dir_path).expect(&format!("cannot create dir {}", &dir_path.display())); assert!(fs::exists(&dir_path).unwrap()); // Check that the directory is empty