Files
metal2vulkan/crates/metal2vulkan-validation/src/worker.rs
T
Anees Iqbal 61a2efc7d3 Fix the GPU test failures seen on the 3090, 5080, XTX, 780M and M3
What and why, per failure (all release, --cfg m2v_gpu):

AMD RADV, Ubuntu Mesa 26.0.8 (RX 7900 XTX, Radeon 780M):
- generated_executions faulted the GPU (amdgpu gfxhub page fault, ring
  reset): RADV before 26.2 skips re-emitting a compute pipeline it thinks
  is bound, so the second execution's implicit preprocess ran our kernel.
  New RuntimeDriverDefect::ImplicitPreprocessAfterExecutionSet (RADV at
  every identity but the measured clean 780M at 26.2.4): the runtime
  preprocesses every execution of a range explicitly, then a barrier, then
  runs them preprocessed. RUNTIME_VERSION 1183.
- The validation executor's generated-commands replay had the same fault;
  it now preprocesses apart on the same defect (runtime's
  generated_commands::preprocess_apart, now public).
- float_denormals under fast math: the test checked a / b, smoothstep and
  (a / b) * c bit for bit, but without VK_KHR_shader_fma (26.0.8) the fast
  reciprocal is the device's OpFDiv(1, y), within 2.5 ulp. Those words are
  now checked at Metal's edges there, in full elsewhere.

NVIDIA 615.71.09 (RTX 3090, RTX 5080 Laptop):
- render_commands_and_render_states_run_as_the_executor_compiles_them: the
  executor used Vulkan device addresses as Metal addresses, and NVIDIA's lie
  below 2^32, where a record's address names no buffer. An addressed
  allocation's guest address is now its device address read signed (RADV's
  are sign-extended) plus 2^47 + 2^32, one translation for every allocation.
- the_runtime_probe_measures_the_test_device_consistently: two driver
  answers Vulkan does not allow (3090: a buffer read after a linear-image
  copy over the same memory in one submission reads stale bytes; both: an
  explicit linear pitch the driver does not lay out is moved, not refused)
  are listed with their evidence in the test; the runtime records neither.
- exits (5 tests): vkDestroyDevice takes ~55 ms alone and up to 2 s beside
  other processes' GPU work on the 3090, so the exit-timing tests run alone
  (.config/nextest.toml); the 1.5 s limit is unchanged.
- pipeline_records (5080): the test assumed the driver finds a pipeline only
  in byte-identical records, but NVIDIA's bytes vary per compile and the two
  formats share entry keys. It now copies a compute pipeline's record over
  the render state's records, which no driver can hit.
- compile_worker (5080, under load): a worker faster than the 1 ms sampler
  left no peak RSS. Each worker now reports its own peak (VmHWM on Linux,
  ru_maxrss on macOS) and the parent takes the larger.
- tests::completion (both, under load): slow rounds were the GPU starting
  late behind another process's ~200 ms busy kernel, or NVIDIA's
  vkQueueSubmit returning up to 64 ms late; the completion was seen within
  1 ms of the moment it could be. A command buffer is now judged from the
  later of its GPU end and its submission's return where the device
  calibrates timestamps (from the commit elsewhere, as before).
- first_use::new_resources_wait_for_no_gpu_work (both, under load): the
  busy kernel's rate came from one wall-clock run, which collapsed under
  load (3 of 28 calibrations), so the busy work lasted milliseconds. The
  rate is now the fastest of every run at every size by GPU time, for all
  four lanes that share it (gpu_times::read_kinds predicts the notice a GPU
  time read emits, for the neutrals test).

Apple M3 Max, MoltenVK 1.4.1:
- heap_textures allows the shadowed-texture route for depth on drivers that
  lay heap depth textures apart.
- The argument-buffer intersection-table test states Metal's own metadata.
- The indirect lane classifies the deferred pipeline-making failure as
  compile-failed alike and keeps only the failed pipeline's error; Apple's
  33-bit closed-form compiler crash is a known gap in docs/FAST-PATHS.md.

Docs: CONTRIBUTING.md and docs/VALIDATION.md say the golden tables and the
compile census are re-blessed on development.

ENGINE_EXECUTOR_ABI is vulkan-engine-v181 (the RADV replay and the Metal
addresses change what the executor submits): every recorded candidate row
and the authored compile census go stale and need re-recording
(scripts/rerecord-venue per venue, rerecord-commit, corpus-status --c3,
corpus-triage --audit authored-compile --bless).

Still open: M3 frees_in_flight, XTX bfloat clears, 780M half NaN blur and
the 5080's one 2 s rebind_bytes_no_copy did not reproduce; the wall-clock
busy calibrations of framebuffer_fetch/storage_forms.rs and queue_storms
remain.

Verified:
- um780 full suites at the AMD fixes (before the executor and NVIDIA
  commits): XTX 3535/3535, 780M 3535/3535, no amdgpu kernel lines.
- Each fix's focused tests before and after on its GPUs (in the agents'
  commits: e.g. generated/indirect 178/178 on XTX and 780M at 26.0.8 and
  26.2.4; candidate 229/229 on 3090, 780M and Iris Xe; the worker peak 0
  of 1440 under 24-way load on the 5080).
- The combined tip: fmt, clippy (with and without --cfg m2v_gpu) and
  rustdoc on ms01; clippy of the validation crate on macOS; a focused run
  on the 3090 was stopped at 333 of 334 passed, none failed. No full suite
  ran on the combined tip.
- The completion and first_use fixes: 3090 load set 1 of 4 runs failed
  before, 4 of 4 passed after (completion) and 12 runs with no first_use
  failure (84 calibrations, 10.19M-11.24M loads); 5080 6 of 6 and 12 of
  12. fmt and clippy (no cfg, m2v_gpu, m2v_cpu_icd) on ms01.
2026-10-13 01:15:18 +03:00

502 lines
21 KiB
Rust

//! The killable worker boundary of validation sweeps.
//!
//! The engine is in-process only: it enforces its budgets deterministically (work units, the
//! byte ledger, the pre-emission size estimate, a transient wall deadline). The validation worker
//! is the backstop around it: one attempt per child process, supervised as a process group under
//! the 20-second and 500-MiB ceilings ([`process`]), with a counting global allocator ([`alloc`])
//! that both enforces the byte budget inside the child and measures the peak attributable bytes
//! that the ledger must account for.
//!
//! [`run_json`] is the one parent-side exchange: the input goes to the child's stdin from a
//! scratch file (no feeder thread per row), the child writes one JSON report to stdout
//! ([`report`]: its result, its counting allocator's process peak and its resident high water),
//! and every scratch file is removed before the call returns. The parent samples the group's RSS
//! every 10 ms, which can miss a short peak or a whole worker that runs between two samples: the
//! result's peak also takes the high water the worker states, and the allocator's peak, counted
//! exactly in the child, is recorded beside it in every result ([`Measured`]). Each member is
//! charged only memory of its own, never its parent's while it still runs in it ([`process`]),
//! and a supervising process gives its large freed buffers back to the system
//! ([`alloc::release_large_frees`]), so its own RSS does not grow from sweep to sweep.
//! [`compile`] runs every engine pipeline compile of a device-holding tool (L4 acceptance, the
//! engine candidate, the device tests) through it, and [`audit`] every attempt of the canon and
//! bitcode-reader audit lanes. [`device`] is the other boundary: the
//! engine candidate's device work runs in a child that the parent waits for without a deadline
//! or a ceiling (the child bounds its own device waits), so a driver fault ends the child, not the
//! tool. A translation worker whose attempt linked a module runs `spirv-val` in a fresh image of
//! itself ([`l3`]), so the attempt's peak is the larger of its translation's and its validation's,
//! never their sum.
pub mod alloc;
pub mod audit;
pub mod compile;
pub mod device;
pub mod l3;
pub mod process;
pub use process::{MonitoredChild, ProcessControl, ProcessExit, ProcessFailure, ProcessStop};
use crate::engine::{FailureKind, Outcome};
use crate::ScratchDir;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use std::fs;
use std::io::{Read as _, Write as _};
use std::process::{Command, Stdio};
use std::time::{Duration, Instant};
/// The per-attempt wall ceiling, from handing the input to the worker through its report.
pub const DEADLINE: Duration = Duration::from_secs(20);
/// The per-attempt memory ceiling: the worker's process-group RSS (sampled by the parent) and
/// the live heap bytes its counting allocator admits above its startup state.
pub const MEMORY_LIMIT_BYTES: u64 = 500 * 1024 * 1024;
/// What the parent measured around a worker that ran, whether or not it reported a result.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct Measured {
/// From preparing the input through the result or the stop.
pub elapsed: Duration,
/// The peak resident size up to the result or the stop: for a worker that exited, the larger
/// of the sampled process-group RSS and the kernel's peak for the worker at its reap
/// ([`ProcessExit::peak_resident_bytes`]), and for one that reported, of its own resident
/// high water as its report states it ([`report`]), so known for every worker that reported
/// on Linux and macOS; for a stopped one, the sampled peak alone.
pub peak_resident_bytes: Option<u64>,
/// The worker's counting-allocator peak ([`alloc::peak_bytes`]): the most live heap bytes it
/// held at once, which the RSS sampler can miss. `None` when the worker reported no result
/// (a stop, an exit, an unreadable report) or counts no allocations.
pub allocator_peak_bytes: Option<u64>,
}
impl Measured {
/// The larger of the sampled RSS and the allocator peak, whichever are known: the measure
/// the 500-MiB ceiling ([`MEMORY_LIMIT_BYTES`]) is checked against.
pub fn peak_bytes(&self) -> Option<u64> {
self.peak_resident_bytes.max(self.allocator_peak_bytes)
}
}
/// What a worker writes to stdout ([`report`]): its result, its counting allocator's process
/// peak, and its own resident high water.
#[derive(Serialize)]
struct Report<'a, R> {
allocator_peak_bytes: Option<u64>,
resident_peak_bytes: Option<u64>,
result: &'a R,
}
/// [`Report`] as the parent decodes it.
#[derive(Deserialize)]
struct Reported<R> {
allocator_peak_bytes: Option<u64>,
resident_peak_bytes: Option<u64>,
result: R,
}
/// What a worker states of its own memory in its report: its counting allocator's process peak
/// ([`alloc::peak_bytes`]) and its resident high water ([`process::own_peak_resident_bytes`]).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
struct Peaks {
allocator_peak_bytes: Option<u64>,
resident_peak_bytes: Option<u64>,
}
impl Peaks {
/// This process's, now.
fn now() -> Peaks {
Peaks {
allocator_peak_bytes: alloc::peak_bytes(),
resident_peak_bytes: process::own_peak_resident_bytes(),
}
}
/// The larger of each of `self`'s and `other`'s.
fn max(self, other: Peaks) -> Peaks {
Peaks {
allocator_peak_bytes: self.allocator_peak_bytes.max(other.allocator_peak_bytes),
resident_peak_bytes: self.resident_peak_bytes.max(other.resident_peak_bytes),
}
}
}
/// Write `result` to stdout as this worker's one report, with its counting allocator's process
/// peak ([`alloc::peak_bytes`]) and its own resident high water
/// ([`process::own_peak_resident_bytes`]), for [`run_json`] to decode. Every worker child reports
/// through this, as its last act.
pub fn report<R: Serialize>(result: &R) -> Result<(), String> {
report_with_peaks(result, Peaks::now())
}
/// [`report`] with the peaks `peaks`: the L3 stage's, which states the larger of the
/// translation's and its own ([`l3::serve`]).
fn report_with_peaks<R: Serialize>(result: &R, peaks: Peaks) -> Result<(), String> {
let mut stdout = std::io::stdout().lock();
serde_json::to_writer(
&mut stdout,
&Report {
allocator_peak_bytes: peaks.allocator_peak_bytes,
resident_peak_bytes: peaks.resident_peak_bytes,
result,
},
)
.map_err(|error| format!("encode the worker's report: {error}"))?;
stdout
.flush()
.map_err(|error| format!("flush the worker's report: {error}"))
}
/// A worker child's process once its arguments selected it (each worker's `serve_if_requested`):
/// refuse to serve unless `counting` (the process counts its allocations, [`alloc::installed`]),
/// set the 500-MiB allocator budget, read the input from stdin, `serve` it under the deadline from
/// then, and [`report`] its result; an error is written to stderr after `worker`'s name. Returns
/// the exit status: 0 when a result was written, 1 otherwise.
pub(crate) fn serve_process<R: Serialize>(
worker: &str,
counting: bool,
serve: impl FnOnce(&[u8], Instant) -> Result<R, String>,
) -> i32 {
let served = (|| {
// The worker recipe's step 2: the in-child budget is the allocator's, set once at startup.
if !counting {
return Err("this binary does not install the counting allocator".to_string());
}
crate::source::adopt_parent_private_corpus()?;
alloc::enable_budget(MEMORY_LIMIT_BYTES);
let started = Instant::now();
let mut input = Vec::new();
std::io::stdin()
.lock()
.read_to_end(&mut input)
.map_err(|error| format!("read the worker's input: {error}"))?;
let output = serve(&input, started)?;
drop(input);
report(&output)
})();
match served {
Ok(()) => 0,
Err(error) => {
eprintln!("{worker}: {error}");
1
}
}
}
/// Why a killable worker produced no result. Every stop after the worker was spawned carries what
/// the parent measured up to it, so a row the boundary stopped at the deadline or the memory
/// ceiling is as measured as a finished one.
#[derive(Debug)]
pub enum WorkerFailure {
/// The parent could not prepare or start the worker (scratch, I/O, spawn).
Setup(String),
/// The watchdog stopped the worker (deadline, memory, cancellation, monitoring), with its
/// bounded stderr when the stop happened after spawning.
Process(ProcessFailure, Option<String>, Measured),
/// The worker exited unsuccessfully (including an allocator-budget abort), with its stderr.
Exit(String, Measured),
/// The worker exited successfully but its result could not be read.
Output(String, Measured),
}
impl WorkerFailure {
/// The failure text. The old engine's census keys failure shapes on it, so it is stable.
pub fn message(&self) -> String {
match self {
WorkerFailure::Setup(error) | WorkerFailure::Output(error, _) => error.clone(),
WorkerFailure::Process(failure, None, _) => failure.to_string(),
WorkerFailure::Process(failure, Some(stderr), _) => format!("{failure}: {stderr}"),
WorkerFailure::Exit(stderr, _) => format!(
"translation worker failed under {} MiB memory limit: {stderr}",
MEMORY_LIMIT_BYTES / (1024 * 1024),
),
}
}
/// The typed outcome class of an engine attempt the worker boundary stopped.
pub fn outcome(&self) -> Outcome {
let failure = match self {
WorkerFailure::Setup(_) => FailureKind::Tooling,
WorkerFailure::Process(ProcessFailure::DeadlineExceeded, ..) => FailureKind::Timeout,
WorkerFailure::Process(ProcessFailure::Cancelled, ..) => FailureKind::Cancelled,
WorkerFailure::Process(ProcessFailure::MemoryLimitExceeded { .. }, ..) => {
FailureKind::Oom
}
WorkerFailure::Process(ProcessFailure::Monitoring(_), ..) => FailureKind::Tooling,
WorkerFailure::Exit(..) | WorkerFailure::Output(..) => FailureKind::WorkerExit,
};
Outcome::Failed { failure }
}
/// What the parent measured before the stop; `None` when no worker was spawned.
pub fn measured(&self) -> Option<Measured> {
match self {
WorkerFailure::Setup(_) => None,
WorkerFailure::Process(_, _, measured)
| WorkerFailure::Exit(_, measured)
| WorkerFailure::Output(_, measured) => Some(*measured),
}
}
}
/// A worker's decoded result and what the parent measured around it.
#[derive(Debug)]
pub struct WorkerRun<R> {
pub result: R,
/// The larger of the peak sampled process-group RSS (the worker and every descendant, e.g.
/// `spirv-val`, summed), the kernel's peak for the worker alone at its reap
/// ([`ProcessExit::peak_resident_bytes`]), and the worker's own resident high water as its
/// report states it ([`report`]).
pub peak_resident_bytes: Option<u64>,
/// The worker's counting-allocator peak, as its report states it ([`report`]).
pub allocator_peak_bytes: Option<u64>,
/// Wall time from preparing the input through decoding the result.
pub elapsed: Duration,
}
impl<R> WorkerRun<R> {
/// What the parent measured around this run.
pub fn measured(&self) -> Measured {
Measured {
elapsed: self.elapsed,
peak_resident_bytes: self.peak_resident_bytes,
allocator_peak_bytes: self.allocator_peak_bytes,
}
}
}
/// The supervising process's allocator policy, set before its first worker: a large buffer it
/// frees goes back to the system ([`alloc::release_large_frees`]).
static SUPERVISOR_HEAP: std::sync::Once = std::sync::Once::new();
/// Run `command` as a killable worker under [`DEADLINE`] and [`MEMORY_LIMIT_BYTES`]:
/// `write_input` fills the file that becomes the child's stdin, and the child's stdout is decoded
/// as its one [`report`] of an `R`. The deadline covers input preparation, the child, and result decoding; the
/// process group is killed on every exit path and the scratch directory is removed.
pub fn run_json<R: DeserializeOwned>(
command: Command,
purpose: &str,
write_input: impl FnOnce(fs::File) -> Result<(), String>,
) -> Result<WorkerRun<R>, WorkerFailure> {
run_json_within(command, purpose, DEADLINE, write_input)
}
/// [`run_json`] under the wall ceiling `deadline` in place of [`DEADLINE`], the memory ceiling
/// unchanged: for a worker that runs a bounded number of attempts, each in its own worker under
/// the per-attempt ceilings (the authored compile census's case worker).
pub fn run_json_within<R: DeserializeOwned>(
mut command: Command,
purpose: &str,
deadline: Duration,
write_input: impl FnOnce(fs::File) -> Result<(), String>,
) -> Result<WorkerRun<R>, WorkerFailure> {
SUPERVISOR_HEAP.call_once(alloc::release_large_frees);
let started = Instant::now();
let setup = WorkerFailure::Setup;
let scratch = ScratchDir::new(purpose).map_err(setup)?;
let stdin_path = scratch.path().join("stdin.json");
let stdout_path = scratch.path().join("stdout.json");
let stderr_path = scratch.path().join("stderr.txt");
let stdin_file = fs::File::create(&stdin_path)
.map_err(|error| setup(format!("create {}: {error}", stdin_path.display())))?;
write_input(stdin_file).map_err(setup)?;
command
// A regular file lets the child decode arbitrarily large inputs under the watchdog
// without one short-lived parent feeder thread per row, so thread count stays bounded by
// the sweep's jobs over a full census.
.stdin(Stdio::from(fs::File::open(&stdin_path).map_err(
|error| setup(format!("open {}: {error}", stdin_path.display())),
)?))
.stdout(Stdio::from(fs::File::create(&stdout_path).map_err(
|error| setup(format!("create {}: {error}", stdout_path.display())),
)?))
.stderr(Stdio::from(fs::File::create(&stderr_path).map_err(
|error| setup(format!("create {}: {error}", stderr_path.display())),
)?));
let control = ProcessControl {
deadline: Some(started + deadline),
memory_limit_bytes: Some(MEMORY_LIMIT_BYTES),
cancelled: None,
};
let child = MonitoredChild::spawn(&mut command)
.map_err(|error| setup(format!("spawn translation worker: {error}")))?;
let exit = child.wait(&control);
let stderr = || fs::read_to_string(&stderr_path).unwrap_or_default();
let measured = |peak_resident_bytes| Measured {
elapsed: started.elapsed(),
peak_resident_bytes,
allocator_peak_bytes: None,
};
let exit = exit.map_err(|stop| {
WorkerFailure::Process(
stop.failure,
Some(bounded(&stderr())),
measured(stop.peak_resident_bytes),
)
})?;
let exited = exit.peak_resident_bytes;
if !exit.status.success() {
return Err(WorkerFailure::Exit(
single_line(&stderr()),
measured(exited),
));
}
let output = fs::read(&stdout_path).map_err(|error| {
WorkerFailure::Output(
format!("read {}: {error}", stdout_path.display()),
measured(exited),
)
})?;
let Reported {
allocator_peak_bytes,
resident_peak_bytes,
result,
} = serde_json::from_slice(&output).map_err(|error| {
WorkerFailure::Output(
format!("decode translation worker result: {error}"),
measured(exited),
)
})?;
// `None` orders below every `Some`.
let peak = exited.max(resident_peak_bytes);
drop(scratch);
control.check().map_err(|error| {
WorkerFailure::Process(
error,
None,
Measured {
allocator_peak_bytes,
..measured(peak)
},
)
})?;
Ok(WorkerRun {
result,
peak_resident_bytes: peak,
allocator_peak_bytes,
elapsed: started.elapsed(),
})
}
fn single_line(value: &str) -> String {
value.split_whitespace().collect::<Vec<_>>().join(" ")
}
fn bounded(value: &str) -> String {
single_line(value).chars().take(4096).collect()
}
#[cfg(test)]
mod tests {
use super::*;
fn shell(script: &str) -> Command {
let mut command = Command::new("sh");
command.args(["-c", script]);
command
}
#[cfg(unix)]
#[test]
fn a_worker_reads_its_input_file_and_reports_json() {
let run: WorkerRun<Vec<u32>> = run_json(
shell(
"read line; echo \"{\\\"allocator_peak_bytes\\\": 4096, \\\"result\\\": [$line, 2]}\"",
),
"worker-test",
|mut file| {
use std::io::Write as _;
writeln!(file, "1").map_err(|error| error.to_string())
},
)
.unwrap();
assert_eq!(run.result, vec![1, 2]);
assert!(run.elapsed < DEADLINE);
// The allocator's peak is recorded beside the sampled RSS.
assert_eq!(run.allocator_peak_bytes, Some(4096));
let measured = run.measured();
assert_eq!(measured.allocator_peak_bytes, Some(4096));
assert_eq!(measured.peak_resident_bytes, run.peak_resident_bytes);
}
/// A worker's report states its counting allocator's process peak and its resident high
/// water, which survive the round trip; a peak the sampler missed still sets the ceiling
/// measure.
#[test]
fn a_report_carries_the_allocator_peak_and_it_bounds_the_ceiling_measure() {
let peaks = Peaks::now();
let bytes = serde_json::to_vec(&Report {
allocator_peak_bytes: peaks.allocator_peak_bytes,
resident_peak_bytes: peaks.resident_peak_bytes,
result: &7u32,
})
.unwrap();
let reported: Reported<u32> = serde_json::from_slice(&bytes).unwrap();
assert_eq!(reported.result, 7);
// The lib's test binary installs the counting allocator (`alloc::tests`).
assert!(reported.allocator_peak_bytes.is_some_and(|peak| peak > 0));
if cfg!(any(target_os = "macos", target_os = "linux")) {
assert!(reported.resident_peak_bytes.is_some_and(|peak| peak > 0));
}
assert_eq!(reported.resident_peak_bytes, peaks.resident_peak_bytes);
let sampled_low = Measured {
elapsed: Duration::ZERO,
peak_resident_bytes: Some(1 << 20),
allocator_peak_bytes: Some(MEMORY_LIMIT_BYTES + 1),
};
assert_eq!(sampled_low.peak_bytes(), Some(MEMORY_LIMIT_BYTES + 1));
let unreported = Measured {
allocator_peak_bytes: None,
..sampled_low
};
assert_eq!(unreported.peak_bytes(), Some(1 << 20));
assert_eq!(Measured::default().peak_bytes(), None);
}
/// A worker that execs and exits between two of the sampler's ticks leaves no sample, and on
/// Linux the kernel's figure at its reap may be this supervisor's own high water, which is not
/// used (`process::own_kernel_peak`): the run's peak takes the high water the worker's report
/// states.
#[cfg(unix)]
#[test]
fn a_run_s_peak_takes_the_resident_high_water_its_report_states() {
// Far above anything `sh` holds and this process's own high water, so no sample and no
// kernel figure stands in for it.
let stated = 1u64 << 40;
let run: WorkerRun<u32> = run_json(
shell(&format!(
"echo '{{\"allocator_peak_bytes\": null, \"resident_peak_bytes\": {stated}, \
\"result\": 7}}'"
)),
"worker-test",
|_| Ok(()),
)
.unwrap();
assert_eq!(run.result, 7);
assert_eq!(run.peak_resident_bytes, Some(stated));
assert_eq!(run.measured().peak_bytes(), Some(stated));
}
#[cfg(unix)]
#[test]
fn worker_failures_are_typed() {
let exit =
run_json::<u32>(shell("echo nope >&2; exit 3"), "worker-test", |_| Ok(())).unwrap_err();
assert!(matches!(&exit, WorkerFailure::Exit(stderr, _) if stderr == "nope"));
assert_eq!(exit.outcome().key(), "worker_exit");
// A stop after spawning is measured like a result.
let measured = exit.measured().unwrap();
assert!(measured.elapsed > Duration::ZERO && measured.elapsed < DEADLINE);
let output =
run_json::<u32>(shell("echo not-json"), "worker-test", |_| Ok(())).unwrap_err();
assert!(matches!(output, WorkerFailure::Output(..)));
assert!(output.measured().is_some());
let setup =
run_json::<u32>(shell("true"), "worker-test", |_| Err("no input".into())).unwrap_err();
assert!(matches!(&setup, WorkerFailure::Setup(error) if error == "no input"));
assert!(setup.outcome().is_transient());
assert_eq!(setup.measured(), None);
}
}