Replace lexical Rust fragments with real modules

This commit is contained in:
ms2k 2026-07-19 05:12:57 +09:00
commit 247819250b

View file

@ -506,6 +506,7 @@ mod tests {
use std::collections::BTreeMap;
use std::fs;
use std::io::Read;
use std::os::fd::AsRawFd;
use std::os::unix::ffi::OsStringExt;
use std::os::unix::fs::PermissionsExt;
use std::os::unix::net::{UnixListener, UnixStream};
@ -517,11 +518,18 @@ mod tests {
};
use lazaret_core::records::{GenerationIdentity, ProtocolPublicationIdentity, ProtocolVersion};
fn test_artifact_root() -> std::path::PathBuf {
let root =
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../target/t/client");
fs::create_dir_all(&root).unwrap();
root.canonicalize().unwrap()
}
#[test]
fn replaced_domain_roots_cannot_redirect_client_lock_or_control_authority() {
let persistent_tree = tempfile::Builder::new()
.prefix("lz-")
.tempdir_in("/tmp")
.tempdir_in(test_artifact_root())
.unwrap();
let persistent_configuration = configuration(persistent_tree.path());
let persistent_path = path(
@ -543,7 +551,7 @@ mod tests {
let runtime_tree = tempfile::Builder::new()
.prefix("lz-")
.tempdir_in("/tmp")
.tempdir_in(test_artifact_root())
.unwrap();
let runtime_configuration = configuration(runtime_tree.path());
let runtime_path = path(
@ -568,7 +576,7 @@ mod tests {
fn confined_control_discovery_connects_through_the_retained_root() {
let tree = tempfile::Builder::new()
.prefix("lz-")
.tempdir_in("/tmp")
.tempdir_in(test_artifact_root())
.unwrap();
let configuration = configuration(tree.path());
let runtime_path = path(
@ -577,7 +585,9 @@ mod tests {
.canonical_label()
.as_bytes(),
);
let listener = UnixListener::bind(runtime_path.join("c.sock")).unwrap();
let runtime = fs::File::open(&runtime_path).unwrap();
let socket_path = PathBuf::from(format!("/proc/self/fd/{}/c.sock", runtime.as_raw_fd()));
let listener = UnixListener::bind(&socket_path).unwrap();
fs::set_permissions(
runtime_path.join("c.sock"),
fs::Permissions::from_mode(0o600),
@ -622,10 +632,10 @@ mod tests {
let (server, _) = listener.accept().unwrap();
assert_eq!(observed, publication);
assert!(control_socket_is_live(&runtime_path.join("c.sock")));
assert!(control_socket_is_live(&socket_path));
let (probe, _) = listener.accept().unwrap();
drop((authority, client, server, probe, listener));
assert!(!control_socket_is_live(&runtime_path.join("c.sock")));
assert!(!control_socket_is_live(&socket_path));
}
#[test]