Bladeren bron

Tests: Update HIP.MathFunctions case for nodiscard enforcement

Brad King 2 jaren geleden
bovenliggende
commit
bc435bc288
1 gewijzigde bestanden met toevoegingen van 8 en 4 verwijderingen
  1. 8 4
      Tests/HIP/MathFunctions/main.hip

+ 8 - 4
Tests/HIP/MathFunctions/main.hip

@@ -18,11 +18,15 @@ bool verify(F f, T expected)
 {
   std::unique_ptr<T> cpu_T(new T);
   T* gpu_T = nullptr;
-  hipMalloc((void**)&gpu_T, sizeof(T));
+  if (hipMalloc((void**)&gpu_T, sizeof(T)) != hipSuccess) {
+    return false;
+  }
+  bool result = true;
   hipLaunchKernelGGL(global_entry_point, 1, 1, 0, 0, f, gpu_T);
-  hipMemcpy(cpu_T.get(), gpu_T, sizeof(T), hipMemcpyDeviceToHost);
-  hipFree(gpu_T);
-  return (*cpu_T == expected);
+  result = hipMemcpy(cpu_T.get(), gpu_T, sizeof(T), hipMemcpyDeviceToHost) == hipSuccess && result;
+  result = hipFree(gpu_T) == hipSuccess && result;
+  result = *cpu_T == expected && result;
+  return result;
 }
 }