diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 264a3c04a..9c359421c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -227,25 +227,41 @@ jobs: # nowhere else: Arch Linux's packages of one Arch Linux Archive date, which # scripts/lavapipe-image/pin pins with the bootstrap tarball's sha256, carrying the Mesa and # LLVM the conformance ledger's llvmpipe rows hold on (its `# llvmpipe:` line). The image's - # downloads are cached on the pin, so a run whose pin has not moved downloads nothing. - - name: Cache the lavapipe image's downloads (Linux) + # downloads are cached keyed on the pin (its tarball's sha256, its date and its packages' + # versions), and saved as soon as the build has them, so a run whose pin has not moved + # downloads nothing, whatever the later steps answer. + - name: Restore the lavapipe image's downloads (Linux) if: runner.os == 'Linux' - uses: actions/cache@v4 + id: lavapipe-downloads + uses: actions/cache/restore@v4 with: path: ~/.cache/m2v-lavapipe-image key: lavapipe-image-${{ hashFiles('scripts/lavapipe-image/pin') }} - # Prints the image's pin, its packages, and its device's name and driver, and fails where any - # differs from the pin or from the ledger's `# llvmpipe:` line. + # Prints the image's pin, its packages, its device's name and driver, and whether its + # containers get /dev/udmabuf, and fails where the image differs from the pin or from the + # ledger's `# llvmpipe:` line. A fetch that fails ends this step with the URL it failed on, + # before any test runs. The limit fits a cold fetch at the slowest rate measured from the + # archive, one connection at 57 KB/s: the 127 MB tarball and 135 MB of databases and + # packages, 262 MB, take 77 minutes there. - name: Build the lavapipe image (Linux) if: runner.os == 'Linux' + timeout-minutes: 90 run: scripts/lavapipe-image/lavapipe-image ensure + - name: Save the lavapipe image's downloads (Linux) + if: runner.os == 'Linux' && steps.lavapipe-downloads.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: ~/.cache/m2v-lavapipe-image + key: lavapipe-image-${{ hashFiles('scripts/lavapipe-image/pin') }} + # The device tests of validation and the runtime, and the runtime's floor check, on lavapipe. # They are the tests the `--cfg m2v_cpu_icd` build holds and the plain builds above do not: a # test that opens a device compiles only under that cfg. The plain builds' tests ran on this # host above, the `.ll` fixtures' test with Ubuntu's LLVM among them. The tests are built - # here, on the host, and only run in the image. `DeviceType::Cpu` matches only a CPU physical + # here, on the host, and only run in the image. Where its containers get no /dev/udmabuf, + # the tests scripts/lavapipe-image/needs-udmabuf names are skipped, each named in the log. `DeviceType::Cpu` matches only a CPU physical # device, and the runtime's device tests under `m2v_cpu_icd` check only CPU devices. macOS CI # runs no device tests. - name: Test validation suite and the runtime on the CPU Vulkan ICD (Linux) @@ -269,13 +285,14 @@ jobs: # the gaps crates/metal2vulkan-conformance/known-gaps-rt.tsv expects on this venue. A refusal # or a divergence that ledger does not list fails here, and so does a row it lists that the # run no longer holds, so closing a gap forces the ledger edit. A venue that lacks a feature - # a case needs does not spoil it. + # a case needs does not spoil it. Where the image's containers get no /dev/udmabuf, the + # cases scripts/lavapipe-image/needs-udmabuf names are left out, each named in the log. - name: Replay the conformance suite on the CPU Vulkan ICD (Linux) if: runner.os == 'Linux' run: | set -euo pipefail cargo build -p metal2vulkan-conformance --bin conformance - scripts/lavapipe-image/lavapipe-image run --env LP_NUM_THREADS=1 -- target/debug/conformance replay --cpu + scripts/lavapipe-image/lavapipe-image replay target/debug/conformance # Machine-specific semantic qualification remains explicit. On lavapipe in the image, it # executes the owned public cases with the engine, in both robustness legs, against their diff --git a/scripts/lavapipe-image/lavapipe-image b/scripts/lavapipe-image/lavapipe-image index acf4ab9ef..506ddd25b 100755 --- a/scripts/lavapipe-image/lavapipe-image +++ b/scripts/lavapipe-image/lavapipe-image @@ -17,6 +17,13 @@ # lavapipe-image nextest ARCHIVE FILTERS [ARG]... # Run the tests of the nextest archive ARCHIVE that FILTERS holds (a filterset a line, as # only_in.py prints them) in the image, with LP_NUM_THREADS=1 and nextest's ARGs. +# lavapipe-image udmabuf +# Say whether the containers get /dev/udmabuf, and exit 0 where they do. +# +# lavapipe exports a dma-buf through /dev/udmabuf, so the containers get the host's where it has +# one (LAVAPIPE_IMAGE_UDMABUF names another node; empty, none, as on a host without one). Where +# they get none, `nextest` skips the tests ./needs-udmabuf names, and `replay` the cases, each +# named in the log, since lavapipe there exports no dma-buf. # # Every download is `curl -A curl` of an exact URL on archive.archlinux.org: the tarball, and the # date's package databases and packages, which pacman fetches through the same command @@ -56,6 +63,7 @@ elif command -v podman >/dev/null; then else die "neither docker nor podman is on PATH" fi +udmabuf=${LAVAPIPE_IMAGE_UDMABUF-/dev/udmabuf} memory=${LAVAPIPE_IMAGE_MEMORY:-$(sed -n 's/^MemTotal: *\([0-9]*\) kB$/\1k/p' /proc/meminfo)} limits=(--memory "$memory" --memory-swap "$memory" --cpus "${CARGO_BUILD_JOBS:-$(nproc)}") @@ -89,7 +97,8 @@ build() { -o -name 'sync-*' ! -name "sync-$date" \) -exec rm -rf {} + if [ ! -s "$tarball" ] || [ "$(sha256sum <"$tarball" | cut -c1-64)" != "$bootstrap_sha256" ]; then rm -f "$tarball" - curl -A curl -fL -C - -o "$tarball.part" "$bootstrap" + curl -A curl -fL --retry 3 -C - -o "$tarball.part" "$bootstrap" || + die "fetching $bootstrap failed (curl exit $?): the archive was unreachable or too slow; nothing was tested" mv "$tarball.part" "$tarball" fi [ "$(sha256sum <"$tarball" | cut -c1-64)" = "$bootstrap_sha256" ] || @@ -133,9 +142,12 @@ EOF pacman -Su --print --print-format %l --noconfirm --needed "$@" | sed -n "/^https:/p" | xargs -r -P 8 -n 1 bash -c '\'' f=/var/cache/pacman/pkg/${1##*/} - curl -A curl -fsSL -C - -o "$f.part" "$1" && mv "$f.part" "$f" || true + curl -A curl -fsSL --retry 3 -C - -o "$f.part" "$1" && mv "$f.part" "$f" || true '\'' fetch - pacman -Su --noconfirm --needed "$@" + pacman -Su --noconfirm --needed "$@" || { + echo "lavapipe-image: pacman could not fetch or install the pin'\''s packages from the archive; nothing was tested" >&2 + exit 1 + } yes | pacman -Sc >/dev/null chown -R "$owner" /var/cache/pacman/pkg /var/lib/pacman/sync ' bash "$(id -u):$(id -g)" "${names[@]}" @@ -185,6 +197,28 @@ check() { names=() for entry in $packages; do names+=("${entry%%=*}"); done +# Whether the containers get the host's udmabuf node: docker's daemon opens it for them; rootless +# podman only where this user may. +has_udmabuf() { + [ -n "$udmabuf" ] && [ -c "$udmabuf" ] && + { [ $runtime = docker ] || { [ -r "$udmabuf" ] && [ -w "$udmabuf" ]; }; } +} + +# Say whether the containers get the node, and answer it. +say_udmabuf() { + if has_udmabuf; then + echo "lavapipe-image: the containers get $udmabuf" + else + echo "lavapipe-image: the containers get no /dev/udmabuf (${udmabuf:-none named}), so lavapipe exports no dma-buf there" + return 1 + fi +} + +# The lines of ./needs-udmabuf whose first word is $1, that word removed. +needs_udmabuf() { + sed -n "s/^$1 //p" "$here/needs-udmabuf" +} + run() { local mounts=(-v "$root:$root:ro") envs=() nextest while [ $# -gt 0 ]; do @@ -213,12 +247,10 @@ run() { if nextest=$(command -v cargo-nextest); then mounts+=(-v "$(realpath "$nextest"):/usr/local/bin/cargo-nextest:ro") fi - # lavapipe exports a dma-buf through /dev/udmabuf: the container gets the host's where the - # host's user may open it, so that it offers the exports the host's lavapipe does. - if [ -c /dev/udmabuf ] && [ -r /dev/udmabuf ] && [ -w /dev/udmabuf ]; then - mounts+=(--device /dev/udmabuf) + if has_udmabuf; then + mounts+=(--device "$udmabuf:/dev/udmabuf") if [ $runtime = docker ]; then - mounts+=(--group-add "$(stat -c %g /dev/udmabuf)") + mounts+=(--group-add "$(stat -c %g "$udmabuf")") else mounts+=(--group-add keep-groups) fi @@ -234,15 +266,31 @@ ensure) build fi check + say_udmabuf || true ;; run) shift run "$@" ;; +udmabuf) + say_udmabuf + ;; nextest) [ $# -ge 3 ] || die "usage: $0 nextest ARCHIVE FILTERS [ARG]..." archive=$(realpath "$2") filters=$(realpath "$3") shift 3 + if ! has_udmabuf; then + kept=$(mktemp) + trap 'rm -f "$kept"' EXIT + cp "$filters" "$kept" + while read -r binary test; do + set_line="binary_id(=$binary) & test(=$test)" + echo "lavapipe-image: skipped $binary $test: it needs a dma-buf export, and the containers get no /dev/udmabuf" + grep -vxF "$set_line" "$kept" >"$kept.next" || true + mv "$kept.next" "$kept" + done < <(needs_udmabuf test) + filters=$kept + fi run --read "$archive" --read "$filters" --env LP_NUM_THREADS=1 -- bash -c ' archive=$1 filters=$2 root=$3 shift 3 @@ -251,6 +299,21 @@ nextest) exec cargo-nextest nextest run --archive-file "$archive" --workspace-remap "$root" "$@" "${sets[@]}" ' bash "$archive" "$filters" "$root" "$@" ;; +replay) + [ $# -eq 2 ] || die "usage: $0 replay CONFORMANCE" + conformance=$2 + cases=() + if ! has_udmabuf; then + skipped=$(needs_udmabuf case) + for name in $skipped; do + echo "lavapipe-image: skipped case $name: it needs a dma-buf export, and the containers get no /dev/udmabuf" + done + while read -r name _; do + [[ " $(echo $skipped) " == *" $name "* ]] || cases+=("$name") + done < <("$conformance" cases) + fi + run --env LP_NUM_THREADS=1 -- "$conformance" replay --cpu "${cases[@]}" + ;; *) sed -n '2,/^set -euo/p' "$0" | sed '$d' >&2 exit 64 diff --git a/scripts/lavapipe-image/needs-udmabuf b/scripts/lavapipe-image/needs-udmabuf new file mode 100644 index 000000000..3f0d28005 --- /dev/null +++ b/scripts/lavapipe-image/needs-udmabuf @@ -0,0 +1,9 @@ +# What needs a dma-buf export, which lavapipe makes through /dev/udmabuf. Where the lavapipe +# image's containers get no /dev/udmabuf, `lavapipe-image nextest` skips each test and +# `lavapipe-image replay` each case named here, and says so in the log. Measured by a run without +# the node: each of these fails there, and passes with it. +test metal2vulkan-validation replay::rt_replay::a_video_surface_is_waited_for_at_its_ready_point_once +case surface-textures-420v-luma-r8 +case surface-textures-420v-chroma-rg8 +case surface-textures-x420-luma-r16 +case surface-textures-x420-chroma-rg16