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.
62 lines
2.6 KiB
Rust
62 lines
2.6 KiB
Rust
//! Checks of the test trees that read the checkout through this crate's directory helpers.
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
/// The trees, relative to the workspace, whose tests run from nextest archives carried to other
|
|
/// machines (`cargo nextest run --archive-file ... --workspace-remap <checkout>`): all of the
|
|
/// validation crate (its lib test binary holds the runtime lanes and the library code they call,
|
|
/// its integration tests and binaries ride a full archive), and the runtime's lib tests
|
|
/// (`src/tests/` and the test modules beside its sources).
|
|
const CARRIED: [&str; 3] = [
|
|
"crates/metal2vulkan-validation/src",
|
|
"crates/metal2vulkan-validation/tests",
|
|
"crates/metal2vulkan-runtime/src",
|
|
];
|
|
|
|
/// The `.rs` files at or below `path`.
|
|
fn sources(path: &Path, out: &mut Vec<PathBuf>) {
|
|
if path.is_dir() {
|
|
for entry in std::fs::read_dir(path).unwrap() {
|
|
sources(&entry.unwrap().path(), out);
|
|
}
|
|
} else if path.extension().is_some_and(|extension| extension == "rs") {
|
|
out.push(path.to_path_buf());
|
|
}
|
|
}
|
|
|
|
/// `env!("CARGO_MANIFEST_DIR")` is the directory the test binary was built in. A carried archive
|
|
/// runs where that directory does not exist, so a test that reads a fixture, a committed case, a
|
|
/// profile or a source file by it fails there ("No such file or directory"), or finds nothing to
|
|
/// read. The carried trees read the checkout through [`crate::workspace_dir`] and the helpers on it,
|
|
/// which take the directory the test runner names as the test runs; this lists every baked site
|
|
/// left, as `file:line`.
|
|
#[test]
|
|
fn the_carried_tests_read_the_checkout_where_the_runner_names_it() {
|
|
let root = crate::workspace_dir();
|
|
let mut files = Vec::new();
|
|
for tree in CARRIED {
|
|
let path = root.join(tree);
|
|
assert!(path.exists(), "{} is missing", path.display());
|
|
sources(&path, &mut files);
|
|
}
|
|
files.sort();
|
|
assert!(files.len() > 500, "{} sources read", files.len());
|
|
let mut baked = Vec::new();
|
|
for file in &files {
|
|
let text = std::fs::read_to_string(file).unwrap();
|
|
let relative = file.strip_prefix(&root).unwrap().display().to_string();
|
|
for (at, line) in text.lines().enumerate() {
|
|
if line.contains("env!(\"CARGO_MANIFEST_DIR\")") {
|
|
baked.push(format!("{relative}:{}", at + 1));
|
|
}
|
|
}
|
|
}
|
|
assert!(
|
|
baked.is_empty(),
|
|
"{} reads of the build's directory in the carried tests (read through \
|
|
metal2vulkan_devtools::{{workspace_dir, validation_dir, fixtures_dir, engine_dir}}):\n{}",
|
|
baked.len(),
|
|
baked.join("\n")
|
|
);
|
|
}
|