mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 22:10:44 +00:00
Stop d3dmetal-harness runner tests racing probe start-up
kills_a_probe_that_exceeds_the_timeout and a_descendant_holding_the_pipes_cannot_outlast_the_deadline gave a freshly written script 300 ms and 500 ms to start and print, and the first failed intermittently with empty stdout (#479). Both now use a 2 s deadline. The kill test also checks that the probe ran until the deadline and that its process is gone afterwards. Test-only change. Signed-off-by: sahib453 <sahibsingh4533@gmail.com>
This commit is contained in:
1 parent
f7fb52bc56
commit
2cc44b8318
2 files changed
+42
-5
No files matched your search
@@ -94,6 +94,7 @@ remains unsupported.
|
||||
- Extended the read-only RDNA2 planning CLI (`python3 -m qa rdna2`) with family/status filters, compact summaries, Codex-ready manifests under `artifacts/`, active-claim exclusion (family claims exclude those families; path-only claims block overlapping permitted files), coverage reconcile against `semantic_coverage` without inflating counts, and inventory diffs. Covered by `tests/qa/test_rdna2_plan.py`; planning only, no GPU production edits.
|
||||
|
||||
### Fixed
|
||||
- `d3dmetal-harness` runner tests no longer fail intermittently (#479). `kills_a_probe_that_exceeds_the_timeout` and `a_descendant_holding_the_pipes_cannot_outlast_the_deadline` gave a freshly written script 300 ms and 500 ms to start and print; both now use a 2 s deadline. The first also checks that the probe ran until the deadline and that its process is gone afterwards, which the old test did not (it passed with the kill removed). Test-only change; `run_probe` is untouched. On one Apple M5 Pro the old first test failed 3 times in about 330 runs with empty stdout; the new tests passed 200 back-to-back runs in four parallel loops, and three deliberate breakages of `run_probe` each failed a test. That the failures came from slow script start-up is inferred from the empty output, not measured. A second race surfaced while testing and is only avoided, not fixed: with tests running in parallel, a child spawned by another test can inherit a probe's pipe, so `output_complete` is not asserted for the killed probe.
|
||||
- Fixed `bx-cli run --bottle` losing the shim DLL overrides: CrossOver's `bin/wine` discards `WINEDLLOVERRIDES`, so they are now passed with `--dll` (found by jelly013) (#408).
|
||||
- `test_integration_boot.exe` now creates a real texture address computer, checks a two-mip layout against hand-computed values and requires the final `Release` to return 0, instead of reporting that stage as pending after a null-descriptor probe (#446).
|
||||
- `bx-cli trace` reports the highest sampled CLWB total as a lower bound, labels counterless CLWB records as samples, and lists unhandled exceptions with their code, module base, RVA, and RIP (#438).
|
||||
|
||||
@@ -186,22 +186,58 @@ mod tests {
|
||||
assert!(run.output_complete);
|
||||
}
|
||||
|
||||
/// Timeout for the tests below whose stand-in probe has to start and print before the
|
||||
/// deadline. Starting a freshly written script costs tens of milliseconds here and
|
||||
/// occasionally far more, so a few hundred milliseconds made these tests fail now and then
|
||||
/// (#479). They check what happens at the deadline, not how fast a script starts.
|
||||
const START_MARGIN: Duration = Duration::from_secs(2);
|
||||
|
||||
#[test]
|
||||
fn kills_a_probe_that_exceeds_the_timeout() {
|
||||
let script = Script::new("hang", "echo started; exec sleep 30");
|
||||
let pid_file =
|
||||
std::env::temp_dir().join(format!("bx-harness-hang-{}.pid", std::process::id()));
|
||||
let _ = std::fs::remove_file(&pid_file);
|
||||
// `exec` keeps the pid, so the recorded pid is the process that has to be killed.
|
||||
let script = Script::new(
|
||||
"hang",
|
||||
&format!(
|
||||
"echo $$ > '{}'; echo started; exec sleep 30",
|
||||
pid_file.display()
|
||||
),
|
||||
);
|
||||
let started = Instant::now();
|
||||
let run = run_probe(&script.0, Path::new("/fw"), Duration::from_millis(300)).unwrap();
|
||||
let run = run_probe(&script.0, Path::new("/fw"), START_MARGIN).unwrap();
|
||||
let elapsed = started.elapsed();
|
||||
assert!(run.status.is_none());
|
||||
// Output written before the kill is kept.
|
||||
assert_eq!(run.stdout, "started\n");
|
||||
assert!(started.elapsed() < Duration::from_secs(10));
|
||||
// The probe ran until the deadline and no longer: it was killed, not waited for.
|
||||
assert!(elapsed >= START_MARGIN, "returned early after {elapsed:?}");
|
||||
assert!(
|
||||
elapsed < START_MARGIN + DRAIN_GRACE + Duration::from_secs(5),
|
||||
"returned after {elapsed:?}"
|
||||
);
|
||||
// The process is gone. `output_complete` is deliberately not asserted: tests run in
|
||||
// parallel, and a child spawned by another test at the wrong moment can inherit this
|
||||
// probe's pipe and hold it open (seen in 2 of 200 runs).
|
||||
let pid = std::fs::read_to_string(&pid_file).unwrap();
|
||||
let alive = Command::new("/bin/kill")
|
||||
.args(["-0", pid.trim()])
|
||||
.stderr(Stdio::null())
|
||||
.status()
|
||||
.unwrap()
|
||||
.success();
|
||||
assert!(!alive, "probe {} survived the timeout", pid.trim());
|
||||
let _ = std::fs::remove_file(&pid_file);
|
||||
}
|
||||
|
||||
/// The probe exits at once, but a background descendant inherits stdout and
|
||||
/// keeps it open well past the timeout.
|
||||
#[test]
|
||||
fn a_descendant_holding_the_pipes_cannot_outlast_the_deadline() {
|
||||
let script = Script::new("orphan", "sleep 5 & echo started");
|
||||
let timeout = Duration::from_millis(500);
|
||||
// The descendant has to outlive the bound asserted below by a wide margin.
|
||||
let script = Script::new("orphan", "sleep 6 & echo started");
|
||||
let timeout = START_MARGIN;
|
||||
let started = Instant::now();
|
||||
let run = run_probe(&script.0, Path::new("/fw"), timeout).unwrap();
|
||||
let elapsed = started.elapsed();
|
||||
|
||||
Reference in new issue
Block a user