diff --git a/projects/hip-tests/catch/include/hip_test_defgroups.hh b/projects/hip-tests/catch/include/hip_test_defgroups.hh index 97e9bea8ab..b0e57cd791 100644 --- a/projects/hip-tests/catch/include/hip_test_defgroups.hh +++ b/projects/hip-tests/catch/include/hip_test_defgroups.hh @@ -50,6 +50,13 @@ THE SOFTWARE. * @} */ +/** + * @defgroup ErrorTest Error Handling + * @{ + * This section describes tests for the error handling functions of HIP runtime API. + * @} + */ + /** * @defgroup ShflTest warp shuffle function Management * @{ diff --git a/projects/hip-tests/catch/unit/errorHandling/hipGetErrorName.cc b/projects/hip-tests/catch/unit/errorHandling/hipGetErrorName.cc index f8c7f624be..a498e62387 100644 --- a/projects/hip-tests/catch/unit/errorHandling/hipGetErrorName.cc +++ b/projects/hip-tests/catch/unit/errorHandling/hipGetErrorName.cc @@ -25,6 +25,26 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipGetErrorName hipGetErrorName + * @{ + * @ingroup ErrorTest + * `hipGetErrorName(hipError_t hip_error)` - + * Return hip error as text string form. + */ + +/** + * Test Description + * ------------------------ + * - Validate that a non-empty string is returned for each supported + * device error enumeration. + * Test source + * ------------------------ + * - unit/errorHandling/hipGetErrorName.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetErrorName_Positive_Basic") { const char* error_string = nullptr; const auto enumerator = @@ -36,6 +56,20 @@ TEST_CASE("Unit_hipGetErrorName_Positive_Basic") { REQUIRE(strlen(error_string) > 0); } +/** + * Test Description + * ------------------------ + * - Validate handling of invalid arguments: + * -# When error enumerator is invalid (-1) + * - AMD expected output: return "hipErrorUnknown" + * - NVIDIA expected output: return "cudaErrorUnknown" + * Test source + * ------------------------ + * - unit/errorHandling/hipGetErrorName.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetErrorName_Negative_Parameters") { const char* error_string = hipGetErrorName(static_cast(-1)); REQUIRE(error_string != nullptr); diff --git a/projects/hip-tests/catch/unit/errorHandling/hipGetErrorString.cc b/projects/hip-tests/catch/unit/errorHandling/hipGetErrorString.cc index fe3f5523c2..e38f0dc54e 100644 --- a/projects/hip-tests/catch/unit/errorHandling/hipGetErrorString.cc +++ b/projects/hip-tests/catch/unit/errorHandling/hipGetErrorString.cc @@ -24,6 +24,26 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipGetErrorString hipGetErrorString + * @{ + * @ingroup ErrorTest + * `hipGetErrorString(hipError_t hipError)` - + * Return handy text string message to explain the error which occurred. + */ + +/** + * Test Description + * ------------------------ + * - Validate that a non-empty string is returned for each supported + * device error enumeration. + * Test source + * ------------------------ + * - unit/errorHandling/hipGetErrorString.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetErrorString_Positive_Basic") { const char* error_string = nullptr; const auto enumerator = @@ -35,6 +55,19 @@ TEST_CASE("Unit_hipGetErrorString_Positive_Basic") { REQUIRE(strlen(error_string) > 0); } +/** + * Test Description + * ------------------------ + * - Validate handling of invalid arguments: + * -# When error enumerator is invalid (-1) + * - Expected output: do not return `nullptr` + * Test source + * ------------------------ + * - unit/errorHandling/hipGetErrorString.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetErrorString_Negative_Parameters") { const char* error_string = hipGetErrorString(static_cast(-1)); REQUIRE(error_string != nullptr); diff --git a/projects/hip-tests/catch/unit/errorHandling/hipGetLastError.cc b/projects/hip-tests/catch/unit/errorHandling/hipGetLastError.cc index f2b8f1cfd3..6d39b8bf33 100644 --- a/projects/hip-tests/catch/unit/errorHandling/hipGetLastError.cc +++ b/projects/hip-tests/catch/unit/errorHandling/hipGetLastError.cc @@ -24,6 +24,27 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipGetLastError hipGetLastError + * @{ + * @ingroup ErrorTest + * `hipGetLastError(void)` - + * Return last error returned by any HIP runtime API call and resets the stored error code to + * `hipSuccess`. + */ + +/** + * Test Description + * ------------------------ + * - Validate that `hipErrorInvalidValue` is returned after invalid `hipMalloc` call. + * - Validate that `hipSuccess` is returned afterwards. + * Test source + * ------------------------ + * - unit/errorHandling/hipGetLastError.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetLastError_Positive_Basic") { HIP_CHECK(hipGetLastError()); HIP_CHECK_ERROR(hipMalloc(nullptr, 1), hipErrorInvalidValue); @@ -31,6 +52,18 @@ TEST_CASE("Unit_hipGetLastError_Positive_Basic") { HIP_CHECK(hipGetLastError()); } +/** + * Test Description + * ------------------------ + * - Validate that appropriate error is returned when working with multiple threads. + * - Cause error on purpose within one of the threads. + * Test source + * ------------------------ + * - unit/errorHandling/hipGetLastError.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetLastError_Positive_Threaded") { class HipGetLastErrorThreadedTest : public ThreadedZigZagTest { public: diff --git a/projects/hip-tests/catch/unit/errorHandling/hipPeekAtLastError.cc b/projects/hip-tests/catch/unit/errorHandling/hipPeekAtLastError.cc index ce7c605719..ae22a3067a 100644 --- a/projects/hip-tests/catch/unit/errorHandling/hipPeekAtLastError.cc +++ b/projects/hip-tests/catch/unit/errorHandling/hipPeekAtLastError.cc @@ -24,6 +24,26 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipPeekAtLastError hipPeekAtLastError + * @{ + * @ingroup ErrorTest + * `hipPeekAtLastError(void)` - + * Return last error returned by any HIP runtime API call. + */ + +/** + * Test Description + * ------------------------ + * - Validate that `hipErrorInvalidValue` is returned after invalid `hipMalloc` call. + * - Validate that `hipSuccess` is returned again for getting the last error. + * Test source + * ------------------------ + * - unit/errorHandling/hipPeekAtLastError.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipPeekAtLastError_Positive_Basic") { HIP_CHECK(hipPeekAtLastError()); HIP_CHECK_ERROR(hipMalloc(nullptr, 1), hipErrorInvalidValue); @@ -32,6 +52,19 @@ TEST_CASE("Unit_hipPeekAtLastError_Positive_Basic") { HIP_CHECK(hipPeekAtLastError()); } +/** + * Test Description + * ------------------------ + * - Validate that appropriate error is returned when working with multiple threads. + * - Validate that appropriate error is returned for getting the last erro when working with multiple threads. + * - Cause error on purpose within one of the threads. + * Test source + * ------------------------ + * - unit/errorHandling/hipPeekAtLastError.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipPeekAtLastError_Positive_Threaded") { class HipPeekAtLastErrorTest : public ThreadedZigZagTest { public: