Validation reads the checkout where the test runner names it, everywhere
A lib-only archive of the validation crate, built on msi and run from another root with
--workspace-remap and the build tree's sources moved away (lavapipe, job m3-max-34590), failed
runtime_lane::tests::a_kernel_runs_the_functions_its_descriptor_links (NotFound at tests.rs:697:
crate::engine::profiles_dir() is env!("CARGO_MANIFEST_DIR")/profiles) and
candidate::engine::graphics::tests::public_render_cases_plan_or_refuse_typed ("0 public render
cases planned": a baked corpus root). Both pass when the build tree is present. The scan
39bff0de2a added covered only runtime_lane/, not the library code the lanes call, nor the rest of
the crate a carried archive holds.
Every env!("CARGO_MANIFEST_DIR") read left in the validation crate moves onto
metal2vulkan-devtools' resolvers, mechanically: the crate's own files onto validation_dir(), the
public fixtures onto fixtures_dir()/engine_dir(), the workspace and crates/ onto workspace_dir().
That is 73 sites in src/ (library ones included: engine::profiles_dir, source::corpus_root,
cutover::list_path, library_module's linked fixtures, mesh_cases, corpus-harvest's default
corpus) and 15 in tests/. The runtime pin's include_str! takes a path relative to its file. A
binary run outside cargo names no manifest directory, so workspace_dir() falls back to the checkout
the dev-tools crate was built in: the same directory as before.
The devtools scan (tests::the_carried_tests_read_the_checkout_where_the_runner_names_it) now
covers all of crates/metal2vulkan-validation/src and tests beside the runtime's src; at the base
it lists the 88 sites.
Test harness and validation tooling only; no product file.
The lib's device tests compile through their own test binary
A lib-only archive of the validation crate (cargo nextest archive -p metal2vulkan-validation --lib,
lavapipe, job m3-max-34590) failed 20 runtime-lane tests whether or not it ran beside its build tree:
the 16 kernels_with_textures_and_samplers_match_metal shards, the two argument-buffer censuses,
sparse_cases_match_metal and public_render_cases_match_metal. All panicked at candidate/tests.rs:63:
compile_worker() looked for the corpus-pipeline binary above the test binary, and Cargo builds a
package's binaries only for a selection that holds an integration test, so a --lib build or archive
never has one.
compile_worker() now names this test binary (CompileWorker::lib_tests), which already installs the
counting allocator (alloc::tests) and already served the compile path's limit probes. A
CompileWorker carries the arguments and variables before the worker argument: none for a binary;
for the lib test binary, `--exact worker::compile::tests::compile_worker_fixture --nocapture
--quiet --` and M2V_TEST_COMPILE_WORKER, so the worker argument run_json's caller appends is a
filter after `--`. The fixture serves a compile, or the probe the variable names, through
worker::serve_process as a binary does, on an 8 MiB thread (a binary serves on its main thread;
the harness runs a test on a 2 MiB one), and exits. It refuses any worker argument but the compile
worker's. run_json decodes the last non-blank line of the worker's stdout as its report, so the
harness's "running 1 test" line before it is not read.
The worker keeps every limit of the boundary: its parent is the same compile() path, so it has
its own process group, the 20-s deadline, the process-group RSS kill, the 500-MiB allocator budget
and scratch removal. The limit probes now go through CompileWorker::lib_tests and compile(),
the exact path the device tests use: deadline (timeout), resident memory (oom), budget
(worker_exit) and the uncounted refusal. New tests:
worker::compile::tests::the_lib_tests_worker_returns_the_pipeline_the_public_api_compiles (the same
comparison tests/integration/compile_worker.rs makes through the real corpus-pipeline,
corpus-vulkan and corpus-moltenvk, which stays) and
worker::tests::a_worker_s_report_is_the_last_line_of_its_stdout.
Test harness only; no product file.
mesh_cases borrows its label for the fixture path; run_json's doc rewrapped
The unbake rewrite moved the row's label into the path join (E0382 in the cpu_icd lib test build,
msi job m3-max-34650); it joins a borrow. Compile fix and doc wrap only.
Why: a lib-only nextest archive of the validation crate (as lanes build) failed 22 tests when run off
its build tree, 20 when run on it (m3-max-34590, lavapipe): the compile worker binary is built only
for selections that include an integration test, and 88 env!("CARGO_MANIFEST_DIR") reads lay
outside the tree the 39bff0de2a scan checks.
Verified (m3-max-34662, msi, at 97feb0e0dc): the lib-only cpu_icd archive, run on lavapipe remapped to
another root with the build tree's sources moved away: 426/426 (the commitwait set, every touched lib
test module and worker::), including the 22 that failed at the base; the four limit probes through
CompileWorker::lib_tests (timeout 20.06 s, RSS kill, allocator budget, uncounted refusal); the new
lib-tests worker equality test. Still running when landed: clippy x3 for validation and devtools, the
plain suites (the corpus-pipeline integration comparison), the widened scan's negative control, rustdoc.
105 lines
4.4 KiB
Rust
105 lines
4.4 KiB
Rust
//! The byte ledger accounts for what a compile allocates.
|
|
//!
|
|
//! Every owned engine fixture entry is compiled for every committed profile, and each compile
|
|
//! the allocator measured must have a ledger peak of at least 7/10 of its allocator peak: the L7
|
|
//! gate `corpus-triage --audit budgets` applies to the corpus, applied here to inputs the tests
|
|
//! own, so an uncharged growth site fails without the private corpus.
|
|
//!
|
|
//! The fixtures run in [`SHARDS`] shards, test binary `ledger_coverage_<k>` running the fixtures
|
|
//! whose index is `k` modulo [`SHARDS`], so nextest runs them side by side (as one test this was
|
|
//! the validation suite's longest by far: 684 s of a 709-s run in gate 9c95feea). Each binary
|
|
//! installs the worker's counting allocator and runs one test, so no other test thread allocates
|
|
//! while a compile is measured and the allocator peak is exactly the compile's.
|
|
|
|
use metal2vulkan::Budget;
|
|
use metal2vulkan_air::budget::Meter;
|
|
use metal2vulkan_devtools::{engine_dir, llvm_assemble, AssembleError};
|
|
use metal2vulkan_validation::budgets::ledger_covers;
|
|
use metal2vulkan_validation::engine::{committed_profiles, load_profile, translate_new};
|
|
|
|
/// The number of shards: binaries `tests/ledger_coverage_0.rs` to `ledger_coverage_5.rs`.
|
|
pub const SHARDS: usize = 6;
|
|
|
|
/// Shard `shard` of the check: the sorted owned fixtures whose index is `shard` modulo
|
|
/// [`SHARDS`]. Every shard's binary must exist, so no fixture goes unchecked.
|
|
pub fn ledger_covers_the_allocator_peak_of_every_owned_fixture_compile(shard: usize) {
|
|
let tests = metal2vulkan_devtools::validation_dir().join("tests");
|
|
for k in 0..=SHARDS {
|
|
let binary = tests.join(format!("ledger_coverage_{k}.rs"));
|
|
assert_eq!(
|
|
binary.is_file(),
|
|
k < SHARDS,
|
|
"{}: shards are binaries 0 to {}",
|
|
binary.display(),
|
|
SHARDS - 1
|
|
);
|
|
}
|
|
let mut fixtures = std::fs::read_dir(engine_dir())
|
|
.unwrap()
|
|
.map(|entry| entry.unwrap().path())
|
|
.filter(|path| {
|
|
path.extension().is_some_and(|ext| ext == "ll")
|
|
&& !path.to_string_lossy().ends_with(".air.ll")
|
|
})
|
|
.collect::<Vec<_>>();
|
|
fixtures.sort();
|
|
let profiles = committed_profiles()
|
|
.unwrap()
|
|
.into_iter()
|
|
.map(|stem| {
|
|
let profile = load_profile(&stem).unwrap();
|
|
(stem, profile)
|
|
})
|
|
.collect::<Vec<_>>();
|
|
let (mut measured, mut shortfalls) = (0usize, Vec::new());
|
|
for path in fixtures.iter().skip(shard).step_by(SHARDS) {
|
|
let bitcode = match llvm_assemble(path) {
|
|
Ok(bytes) => bytes,
|
|
Err(AssembleError::Missing(why)) => {
|
|
eprintln!("SKIPPED: {why}");
|
|
return;
|
|
}
|
|
// Owned fixtures llvm-as rejects are the inventory test's to report.
|
|
Err(AssembleError::Rejected(why)) => {
|
|
eprintln!("SKIPPED {}: {why}", path.display());
|
|
continue;
|
|
}
|
|
};
|
|
let entries = match metal2vulkan_air::decode(&bitcode, &mut Meter::new(&Budget::default()))
|
|
{
|
|
Ok(decoded) => decoded
|
|
.abi
|
|
.entries
|
|
.iter()
|
|
.map(|entry| entry.name.to_string())
|
|
.collect::<Vec<_>>(),
|
|
Err(_) => continue,
|
|
};
|
|
for entry in &entries {
|
|
for (stem, profile) in &profiles {
|
|
let attempt = translate_new(&bitcode, entry, profile, None);
|
|
let Some(cost) = attempt.cost else { continue };
|
|
let Some(allocator) = cost.allocator_peak.filter(|peak| *peak > 0) else {
|
|
continue;
|
|
};
|
|
measured += 1;
|
|
if !ledger_covers(cost.ledger_peak, allocator) {
|
|
shortfalls.push(format!(
|
|
"{} {entry} on {stem}: ledger {} < 7/10 of allocator {allocator} ({})",
|
|
path.file_name().unwrap().to_string_lossy(),
|
|
cost.ledger_peak,
|
|
attempt.outcome.label(),
|
|
));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
assert!(measured > 0, "shard {shard}: no compile was measured");
|
|
assert!(
|
|
shortfalls.is_empty(),
|
|
"shard {shard}: {} of {measured} compiles:\n{}",
|
|
shortfalls.len(),
|
|
shortfalls.join("\n")
|
|
);
|
|
}
|