Bind cold start to production authorities
This commit is contained in:
parent
a9c9cf7ab3
commit
b2f178d25e
1 changed files with 816 additions and 30 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use std::ffi::OsString;
|
||||
use std::fs::File;
|
||||
use std::io::{Seek, Write};
|
||||
use std::io::{Read, Seek, Write};
|
||||
use std::os::fd::AsFd;
|
||||
use std::process::{ExitCode, Stdio};
|
||||
use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
|
||||
|
|
@ -45,6 +45,7 @@ fn exit(result: std::io::Result<()>) -> ExitCode {
|
|||
|
||||
fn run_all() -> std::io::Result<()> {
|
||||
successful_acquisition()?;
|
||||
transient_captured_child_preserves_streams_and_exit()?;
|
||||
acknowledged_transition_precedes_exact_wrapper_release()?;
|
||||
failed_acknowledged_transition_refuses_exact_wrapper_release()?;
|
||||
lifetime_pipe_descriptor_contract()?;
|
||||
|
|
@ -56,6 +57,47 @@ fn run_all() -> std::io::Result<()> {
|
|||
concurrent_acquisitions_serialize()
|
||||
}
|
||||
|
||||
fn transient_captured_child_preserves_streams_and_exit() -> std::io::Result<()> {
|
||||
let target = TargetCommand::new("/bin/sh")
|
||||
.argument("-c")
|
||||
.argument("printf transient-out; printf transient-err >&2; exit 7");
|
||||
let mut child = child_broker().run_transient_captured(&target)?;
|
||||
let mut stdout = Vec::new();
|
||||
let mut stderr = Vec::new();
|
||||
loop {
|
||||
let (out, err) = child.streams();
|
||||
let out_done = read_available(out, &mut stdout)?;
|
||||
let err_done = read_available(err, &mut stderr)?;
|
||||
if out_done && err_done && child.process().has_exited()? {
|
||||
break;
|
||||
}
|
||||
std::thread::yield_now();
|
||||
}
|
||||
let exit = child_broker().reap_status(child.into_process())?;
|
||||
if stdout != b"transient-out"
|
||||
|| stderr != b"transient-err"
|
||||
|| exit.exit_code != Some(7)
|
||||
|| exit.terminating_signal.is_some()
|
||||
{
|
||||
return Err(std::io::Error::other(
|
||||
"transient captured child changed streams or exit",
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn read_available(file: &mut File, output: &mut Vec<u8>) -> std::io::Result<bool> {
|
||||
let mut buffer = [0; 4096];
|
||||
loop {
|
||||
match file.read(&mut buffer) {
|
||||
Ok(0) => return Ok(true),
|
||||
Ok(length) => output.extend_from_slice(&buffer[..length]),
|
||||
Err(error) if error.kind() == std::io::ErrorKind::WouldBlock => return Ok(false),
|
||||
Err(error) => return Err(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::disallowed_methods, clippy::disallowed_types)]
|
||||
fn failed_acknowledged_transition_refuses_exact_wrapper_release() -> std::io::Result<()> {
|
||||
let target_marker = marker("failed-transition-target");
|
||||
|
|
|
|||
Loading…
Reference in a new issue