diff --git a/CMakeLists.txt b/CMakeLists.txt index a90354cea..168b985f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,6 +200,7 @@ add_test(NAME serve_hangup COMMAND ${CMAKE_SOURCE_DIR}/tests/serve_hangup_test.s # engine#1945: scripts/bump-hrx-sync.sh tells AMD's own commit from a line AMD rebased apart from a commit that # is not AMD's. Local git repositories only: no network, no GPU. add_test(NAME bump_hrx_sync COMMAND bash ${CMAKE_SOURCE_DIR}/tests/bump_hrx_sync_test.sh ${CMAKE_SOURCE_DIR}/scripts/bump-hrx-sync.sh) +add_test(NAME hrx_test_compile COMMAND bash ${CMAKE_SOURCE_DIR}/tests/hrx_test_compile_test.sh ${CMAKE_SOURCE_DIR}/scripts/hrx-test-compile.sh) add_test(NAME bump_hrx_report COMMAND bash ${CMAKE_SOURCE_DIR}/tests/bump_hrx_report_test.sh ${CMAKE_SOURCE_DIR}/scripts/bump-hrx-report.sh) add_test(NAME metrics_serve COMMAND ${CMAKE_SOURCE_DIR}/tests/metrics_serve.sh $) # serve --print-backend: the llama-server Lemonade starts itself, one hop (docs/serve.md): no GPU. diff --git a/scripts/hrx-test-compile.sh b/scripts/hrx-test-compile.sh new file mode 100755 index 000000000..8a3dc1d26 --- /dev/null +++ b/scripts/hrx-test-compile.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# Copyright 2026 bong-water-water-bong +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# hrx-test-compile.sh -- compile the fork's HRX test targets, and nothing else. +# +# Why this exists (engine#2068): `tests/hrx-backend-test.cpp` in 1bit-MONSTER/llama.cpp stopped compiling at +# llama.cpp#262 and NOBODY SAW IT, because no automated job builds that file -- it is registered under +# `if (TARGET ggml-hrx)` in the fork's tests/CMakeLists.txt, so a build without the HRX backend skips it, and no +# build asks for tests. Three host rows then failed in a binary nothing ran. A compile break in a 654 KB test +# file is the one thing a *build* catches for free and a *run* never gets the chance to. +# +# This is a compile gate only: it never runs the tests and needs no device. +# +# usage: hrx-test-compile.sh [--build-dir DIR] +# exit: 0 all HRX test targets built; 1 a target failed to build; 2 usage; 77 the tree has no HRX backend +set -uo pipefail + +if [ $# -lt 1 ]; then + echo "usage: hrx-test-compile.sh [--build-dir DIR]" >&2 + exit 2 +fi +tree=$1 +shift || true +build_dir="" +while [ $# -gt 0 ]; do + case "$1" in + --build-dir) build_dir=${2:?--build-dir needs a path}; shift 2 ;; + *) echo "hrx-test-compile: unknown argument: $1" >&2; exit 2 ;; + esac +done +[ -d "$tree" ] || { echo "hrx-test-compile: not a directory: $tree" >&2; exit 2; } +[ -d "$tree/tests" ] || { echo "hrx-test-compile: no tests/ in $tree" >&2; exit 2; } +[ -n "$build_dir" ] || build_dir="$tree/build-hrx-test-compile" + +# Configure with the HRX backend and the tests on: those two switches are what make the file part of the build. +# GGM L_HRX's own option name is the fork's; if it is renamed, this configure fails loudly rather than skipping. +if ! cmake -S "$tree" -B "$build_dir" -DLLAMA_BUILD_TESTS=ON -DGGML_HRX=ON -DCMAKE_BUILD_TYPE=Release >"$build_dir.configure.log" 2>&1; then + echo "hrx-test-compile: configure FAILED (see $build_dir.configure.log)" >&2 + tail -5 "$build_dir.configure.log" >&2 + exit 1 +fi + +# Which of the HRX test targets this tree actually declares. Asking CMake rather than grepping the CMakeLists keeps +# the gate honest when the target list changes: a target that disappears is reported, not silently dropped. +have=$(cmake --build "$build_dir" --target help 2>/dev/null | sed -n 's/^\.\.\. \([A-Za-z0-9_.-]*\)$/\1/p' | grep -x 'test-hrx-backend\|test-hrx-rope-claim-params' | sort -u) + +if [ -z "$have" ]; then + # Not "passed": no HRX target exists in this tree, so this gate proved nothing about the file it exists for. + echo "hrx-test-compile: no HRX test targets in $tree (GGML_HRX=ON did not produce them) -- SKIP, not PASS" >&2 + exit 77 +fi + +rc=0 +for t in $have; do + if cmake --build "$build_dir" --target "$t" >>"$build_dir.build.log" 2>&1; then + echo "ok built $t" + else + echo "FAIL build $t (see $build_dir.build.log)" >&2 + grep -E "error:" "$build_dir.build.log" | head -3 >&2 + rc=1 + fi +done +[ "$rc" = 0 ] && echo "ok HRX test targets compile ($(echo $have | wc -w) target(s))" +exit "$rc" diff --git a/tests/hrx_test_compile_test.sh b/tests/hrx_test_compile_test.sh new file mode 100755 index 000000000..e9d01619c --- /dev/null +++ b/tests/hrx_test_compile_test.sh @@ -0,0 +1,101 @@ +#!/bin/bash +# Copyright 2026 bong-water-water-bong +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# hrx_test_compile_test.sh -- arms for scripts/hrx-test-compile.sh (engine#2068). +# +# The gate's whole value is that it fails on the source that did not compile (#262) and does not report a pass when +# it never built the file. So the arms are: a tree that builds, a tree whose test source has the #262-shaped error, +# and a tree with no HRX targets at all -- the last one must exit 77, because "not built" and "built fine" are the +# two states this gate exists to keep apart. +# +# usage: hrx_test_compile_test.sh +set -uo pipefail + +S=${1:?usage: hrx_test_compile_test.sh } +[ -x "$S" ] || { echo "not executable: $S"; exit 1; } +command -v cmake >/dev/null 2>&1 || { echo "skip: no cmake (exit 77)"; exit 77; } + +# The stub trees need a real C and C++ compiler, and they must be found the way this box names them: CI configures the +# engine build with gcc-16/g++-16 and may have no plain `cc`/`c++` on PATH at all, which is how this test failed its +# first CI run while passing locally. CMake honours CC/CXX on a first configure, so the arms hand it what exists. +pick() { for c in "$@"; do command -v "$c" >/dev/null 2>&1 && { command -v "$c"; return 0; }; done; return 1; } +CC=$(pick "${CC:-}" cc gcc gcc-16 gcc-15 gcc-14) || { echo "skip: no C compiler (exit 77)"; exit 77; } +CXX=$(pick "${CXX:-}" c++ g++ g++-16 g++-15 g++-14) || { echo "skip: no C++ compiler (exit 77)"; exit 77; } +export CC CXX +work=$(mktemp -d "${TMPDIR:-/tmp}/hrxtc.XXXXXX") # scratch, removed below +trap 'rm -rf "$work"' EXIT +fail=0 +ok() { echo "ok $1"; } +bad() { echo "FAIL $1"; fail=1; } + +# A stub "fork": the smallest tree whose CMakeLists declares the HRX test target the gate looks for, so the gate's +# own logic (configure, ask for the target, build it) is exercised without the real 654 KB source or the HRX toolchain. +mktree() { # mktree [declare-hrx] + local d=$1 body=$2 hrx=${3:-yes} + mkdir -p "$d/tests" + cat > "$d/CMakeLists.txt" < "$d/tests/CMakeLists.txt" <<'EOF' +add_executable(test-hrx-backend hrx-backend-test.cpp) +EOF + printf '%s\n' "$body" > "$d/tests/hrx-backend-test.cpp" +} + +# 1. Compiles cleanly -> 0. +mktree "$work/good" 'int main(void) { return 0; }' +# On failure, print what the gate itself said: an arm that reports only "exits 0" fails the first CI run with no cause, +# which is what happened here (the real reason was a missing compiler, and the arm said nothing about it). +run_arm() { # run_arm