CI: Fail closed in GPU test jobs when NVIDIA device is missing libeigen/eigen!3450 Co-authored-by: Antonio Sanchez <cantonios@google.com>
diff --git a/ci/scripts/test.linux.script.sh b/ci/scripts/test.linux.script.sh index 7a9d577..014bcf2 100755 --- a/ci/scripts/test.linux.script.sh +++ b/ci/scripts/test.linux.script.sh
@@ -38,6 +38,16 @@ cd ${EIGEN_CI_BUILDDIR} +# Verify GPU availability for GPU test suites. Never allow non-GPU runners +# to silently skip tests and report false-positive success. +if [[ "${EIGEN_CI_CTEST_LABEL}" == "gpu" || "${CI_JOB_NAME:-}" == *":cuda"* ]]; then + if ! command -v nvidia-smi >/dev/null 2>&1 || ! nvidia-smi >/dev/null 2>&1; then + echo "ERROR: GPU test suite requested, but no functional NVIDIA device or driver was detected by nvidia-smi." >&2 + echo "Refusing to report a false-positive pass without GPU hardware." >&2 + exit 1 + fi +fi + target="" if [[ ${EIGEN_CI_CTEST_REGEX} ]]; then target="-R ${EIGEN_CI_CTEST_REGEX}"
diff --git a/ci/scripts/test.windows.script.ps1 b/ci/scripts/test.windows.script.ps1 index 99e02bb..3e618a2 100644 --- a/ci/scripts/test.windows.script.ps1 +++ b/ci/scripts/test.windows.script.ps1
@@ -51,6 +51,20 @@ } } +# Verify GPU availability for GPU test suites. Never allow non-GPU runners +# to silently skip tests and report false-positive success. +if ($EIGEN_CI_CTEST_LABEL -eq "gpu" -or $Env:CI_JOB_NAME -like "*:cuda*") { + $has_gpu = $false + if (Get-Command nvidia-smi -ErrorAction SilentlyContinue) { + & nvidia-smi > $null 2>&1 + if ($LASTEXITCODE -eq 0) { $has_gpu = $true } + } + if (-not $has_gpu) { + Write-Error "ERROR: GPU test suite requested, but no functional NVIDIA device or driver was detected by nvidia-smi." + exit 1 + } +} + # Determine number of processors for parallel tests. $NPROC=${Env:NUMBER_OF_PROCESSORS}