test_infra: improve NVIDIA diagnostics

Avoid panicking when nvidia-smi fails during GPU checks. Run the
command through a shell wrapper that preserves stdout and stderr
even when nvidia-smi exits with a failure status.

Keep printing guest dmesg on failure and label the nvidia-smi
text as diagnostic output, since SSH-level failures are reported
through the same path.

Assisted-by: OpenCode:gpt-5.5

Signed-off-by: Damian Barabonkov <dbctl@pm.me>
This commit is contained in:
Damian Barabonkov
2026-05-29 13:31:45 +02:00
committed by Rob Bradford
parent 99f5537984
commit bbd271e85b

View File

@@ -1607,7 +1607,9 @@ impl Guest {
#[cfg(target_arch = "x86_64")]
pub fn check_nvidia_gpu(&self) -> bool {
let output = self.ssh_command("nvidia-smi").unwrap();
let output = self
.ssh_command("nvidia-smi 2>&1; echo CH_NVIDIA_SMI_STATUS:$?")
.unwrap_or_else(|e| format!("failed to run nvidia-smi: {e:?}"));
if output.contains("NVIDIA L40S") {
return true;
@@ -1619,10 +1621,10 @@ impl Guest {
eprintln!(
"\n\n==== Guest dmesg (nvidia-smi check failed) ====\n\n\
{dmesg}\n\
\n==== End guest dmesg ====\n\n"
{dmesg}\n\
\n==== End guest dmesg ====\n\n"
);
eprintln!("nvidia-smi output did not contain 'NVIDIA L40S': {output}");
eprintln!("nvidia-smi diagnostic output: {output}");
false
}