diff --git a/codex-rs/linux-sandbox/tests/landlock.rs b/codex-rs/linux-sandbox/tests/landlock.rs index 95ca11a29c..5af822b25a 100644 --- a/codex-rs/linux-sandbox/tests/landlock.rs +++ b/codex-rs/linux-sandbox/tests/landlock.rs @@ -15,6 +15,23 @@ use std::sync::Arc; use tempfile::NamedTempFile; use tokio::sync::Notify; +// At least on GitHub CI, the arm64 tests appear to need longer timeouts. + +#[cfg(not(all(target_arch = "aarch64", target_env = "musl")))] +const SHORT_TIMEOUT_MS: u64 = 200; +#[cfg(all(target_arch = "aarch64", target_env = "musl"))] +const SHORT_TIMEOUT_MS: u64 = 5_000; + +#[cfg(not(all(target_arch = "aarch64", target_env = "musl")))] +const LONG_TIMEOUT_MS: u64 = 1_000; +#[cfg(all(target_arch = "aarch64", target_env = "musl"))] +const LONG_TIMEOUT_MS: u64 = 5_000; + +#[cfg(not(all(target_arch = "aarch64", target_env = "musl")))] +const NETWORK_TIMEOUT_MS: u64 = 2_000; +#[cfg(all(target_arch = "aarch64", target_env = "musl"))] +const NETWORK_TIMEOUT_MS: u64 = 10_000; + fn create_env_from_core_vars() -> HashMap { let policy = ShellEnvironmentPolicy::default(); create_env(&policy) @@ -52,7 +69,7 @@ async fn run_cmd(cmd: &[&str], writable_roots: &[PathBuf], timeout_ms: u64) { #[tokio::test] async fn test_root_read() { - run_cmd(&["ls", "-l", "/bin"], &[], 200).await; + run_cmd(&["ls", "-l", "/bin"], &[], SHORT_TIMEOUT_MS).await; } #[tokio::test] @@ -63,7 +80,7 @@ async fn test_root_write() { run_cmd( &["bash", "-lc", &format!("echo blah > {}", tmpfile_path)], &[], - 200, + SHORT_TIMEOUT_MS, ) .await; } @@ -75,7 +92,7 @@ async fn test_dev_null_write() { &[], // We have seen timeouts when running this test in CI on GitHub, // so we are using a generous timeout until we can diagnose further. - 1_000, + LONG_TIMEOUT_MS, ) .await; } @@ -93,7 +110,7 @@ async fn test_writable_root() { &[tmpdir.path().to_path_buf()], // We have seen timeouts when running this test in CI on GitHub, // so we are using a generous timeout until we can diagnose further. - 1_000, + LONG_TIMEOUT_MS, ) .await; } @@ -115,7 +132,7 @@ async fn assert_network_blocked(cmd: &[&str]) { cwd, // Give the tool a generous 2-second timeout so even slow DNS timeouts // do not stall the suite. - timeout_ms: Some(2_000), + timeout_ms: Some(NETWORK_TIMEOUT_MS), env: create_env_from_core_vars(), };