EXSWHTEC-363 - Implement tests for Surface Management APIs (#439)

Change-Id: If354846b04fb48974cd0345f3a317e52b046014f


[ROCm/hip-tests commit: 7685c9c46a]
Tento commit je obsažen v:
Mirza Halilcevic
2023-12-09 00:57:19 +05:30
odevzdal Rakesh Roy
rodič a172f93cce
revize 68de68db3b
4 změnil soubory, kde provedl 160 přidání a 0 odebrání
+7
Zobrazit soubor
@@ -186,3 +186,10 @@ THE SOFTWARE.
* This section describes the various Printf use case Scenarios.
* @}
*/
/**
* @defgroup SurfaceTest Surface Management
* @{
* This section describes tests for the surface management functions of HIP runtime API.
* @}
*/
+2
Zobrazit soubor
@@ -23,6 +23,8 @@ set(TEST_SRC
hipSurfaceObj1D.cc
hipSurfaceObj2D.cc
hipSurfaceObj3D.cc
hipCreateSurfaceObject.cc
hipDestroySurfaceObject.cc
)
hip_add_exe_to_target(NAME SurfaceTest
+85
Zobrazit soubor
@@ -0,0 +1,85 @@
/*
Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <hip_test_common.hh>
/**
* @addtogroup hipCreateSurfaceObject hipCreateSurfaceObject
* @{
* @ingroup SurfaceTest
*/
/**
* Test Description
* ------------------------
* - Negative parameters test for `hipCreateSurfaceObject`.
* Test source
* ------------------------
* - unit/texture/hipCreateSurfaceObject.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEST_CASE("Unit_hipCreateSurfaceObject_Negative_Parameters") {
hipArray_t array;
hipChannelFormatDesc desc = hipCreateChannelDesc<float>();
HIP_CHECK(hipMallocArray(&array, &desc, 64, 0, hipArraySurfaceLoadStore));
hipSurfaceObject_t surf;
hipResourceDesc resc = {};
resc.resType = hipResourceTypeArray;
resc.res.array.array = array;
SECTION("pSurfObject is nullptr") {
HIP_CHECK_ERROR(hipCreateSurfaceObject(nullptr, &resc), hipErrorInvalidValue);
}
SECTION("pResDesc is nullptr") {
HIP_CHECK_ERROR(hipCreateSurfaceObject(&surf, nullptr), hipErrorInvalidValue);
}
SECTION("invalid resource type") {
resc.resType = hipResourceTypeLinear;
HIP_CHECK_ERROR(hipCreateSurfaceObject(&surf, &resc), hipErrorInvalidValue);
}
#if HT_NVIDIA // DIsalbed due to defect EXSWHTEC-366
SECTION("array handle is nullptr") {
resc.res.array.array = nullptr;
HIP_CHECK_ERROR(hipCreateSurfaceObject(&surf, &resc), hipErrorInvalidHandle);
}
#endif
#if HT_NVIDIA // Disalbed due to defect EXSWHTEC-367
SECTION("freed array handle") {
hipArray_t invalid_array;
HIP_CHECK(hipMallocArray(&invalid_array, &desc, 64, 0, hipArraySurfaceLoadStore));
HIP_CHECK(hipFreeArray(invalid_array));
resc.res.array.array = invalid_array;
HIP_CHECK_ERROR(hipCreateSurfaceObject(&surf, &resc), hipErrorContextIsDestroyed);
}
#endif
HIP_CHECK(hipFreeArray(array));
}
+66
Zobrazit soubor
@@ -0,0 +1,66 @@
/*
Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <hip_test_common.hh>
/**
* @addtogroup hipDestroySurfaceObject hipDestroySurfaceObject
* @{
* @ingroup SurfaceTest
*/
/**
* Test Description
* ------------------------
* - Negative parameters test for `hipDestroySurfaceObject`.
* Test source
* ------------------------
* - unit/texture/hipDestroySurfaceObject.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEST_CASE("Unit_hipDestroySurfaceObject_Negative_Parameters") {
SECTION("surfObject is NULL") {
HIP_CHECK(hipDestroySurfaceObject(static_cast<hipSurfaceObject_t>(0)));
}
SECTION("double free") {
hipArray_t array;
hipChannelFormatDesc desc = hipCreateChannelDesc<float>();
HIP_CHECK(hipMallocArray(&array, &desc, 64, 0, hipArraySurfaceLoadStore));
hipSurfaceObject_t surf;
hipResourceDesc resc = {};
resc.resType = hipResourceTypeArray;
resc.res.array.array = array;
HIP_CHECK(hipCreateSurfaceObject(&surf, &resc));
HIP_CHECK(hipDestroySurfaceObject(surf));
HIP_CHECK_ERROR(hipDestroySurfaceObject(surf), hipErrorInvalidValue);
HIP_CHECK(hipFreeArray(array));
}
}