From d38a932419699bce59df19117cfac64060d1cb97 Mon Sep 17 00:00:00 2001
From: Christoph Alt <typ@ohnebild.com>
Date: Wed, 16 Aug 2023 15:03:18 +0200
Subject: [PATCH] using pytest skip if there is no nvcc or gpu available

---
 tests/test_benchmark.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py
index a45fcdd..b47f9c5 100755
--- a/tests/test_benchmark.py
+++ b/tests/test_benchmark.py
@@ -19,11 +19,17 @@ config_kwargs = ({},
 
 
 def nvidia_gpu_available():
-    return subprocess.call(['nvidia-smi']) == 0
+    try:
+        return subprocess.call(['nvidia-smi']) == 0
+    except (FileNotFoundError,):
+        return False
 
 
 def nvcc_available():
-    return subprocess.call(['nvcc', '--version']) == 0
+    try:
+        return subprocess.call(['nvcc', '--version']) == 0
+    except (FileNotFoundError,):
+        return False
 
 
 @pytest.mark.parametrize('compiler', compilers)
@@ -72,8 +78,8 @@ def test_generate_gpu(kwargs):
         temp_dir = Path(temp_dir)
         pb.gpu.generate_benchmark([kernel_vadd, kernel_daxpy], temp_dir, compiler=compiler, **kwargs)
         if not nvcc_available():
-            return
+            pytest.skip("nvcc is not available!")
         subprocess.run(['make', '-C', f'{temp_dir}'], check=True)
         if not nvidia_gpu_available():
-            return
+            pytest.skip("There is no GPU available!")
         subprocess.run([f'{temp_dir}/benchmark-{compiler.name}', '10'], check=True)
-- 
GitLab