Dispatch linux sandbox integration tests by arg0

This commit is contained in:
pakrym-oai
2026-03-23 09:17:58 -07:00
parent 6182298401
commit 1b5636e0fb
4 changed files with 50 additions and 0 deletions
+2
View File
@@ -2168,9 +2168,11 @@ version = "0.0.0"
dependencies = [
"cc",
"clap",
"codex-arg0",
"codex-core",
"codex-protocol",
"codex-utils-absolute-path",
"ctor 0.6.3",
"landlock",
"libc",
"pkg-config",
+2
View File
@@ -28,6 +28,8 @@ serde_json = { workspace = true }
url = { workspace = true }
[target.'cfg(target_os = "linux")'.dev-dependencies]
codex-arg0 = { workspace = true }
ctor = { workspace = true }
pretty_assertions = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true, features = [
+2
View File
@@ -1,3 +1,5 @@
#![cfg(target_os = "linux")]
// Single integration test binary that aggregates all test modules.
// The submodules live in `tests/suite/`.
mod suite;
+44
View File
@@ -1,3 +1,47 @@
// Aggregates all former standalone integration tests as modules.
use codex_arg0::Arg0PathEntryGuard;
use codex_arg0::arg0_dispatch;
use ctor::ctor;
use tempfile::TempDir;
struct TestCodexAliasesGuard {
_codex_home: TempDir,
_arg0: Arg0PathEntryGuard,
}
const CODEX_HOME_ENV_VAR: &str = "CODEX_HOME";
// This code runs before any other tests are run.
// It allows the test binary to behave like codex-linux-sandbox based on arg0.
#[ctor]
pub static CODEX_ALIASES_TEMP_DIR: TestCodexAliasesGuard = unsafe {
#[allow(clippy::unwrap_used)]
let codex_home = tempfile::Builder::new()
.prefix("codex-linux-sandbox-tests")
.tempdir()
.unwrap();
let previous_codex_home = std::env::var_os(CODEX_HOME_ENV_VAR);
// Safety: #[ctor] runs before test threads start.
unsafe {
std::env::set_var(CODEX_HOME_ENV_VAR, codex_home.path());
}
#[allow(clippy::unwrap_used)]
let arg0 = arg0_dispatch().unwrap();
match previous_codex_home.as_ref() {
Some(value) => unsafe {
std::env::set_var(CODEX_HOME_ENV_VAR, value);
},
None => unsafe {
std::env::remove_var(CODEX_HOME_ENV_VAR);
},
}
TestCodexAliasesGuard {
_codex_home: codex_home,
_arg0: arg0,
}
};
mod landlock;
mod managed_proxy;