diff --git a/projects/hip-tests/catch/hipTestMain/config/config_amd_linux b/projects/hip-tests/catch/hipTestMain/config/config_amd_linux index 5964a7aad9..d24f21a772 100644 --- a/projects/hip-tests/catch/hipTestMain/config/config_amd_linux +++ b/projects/hip-tests/catch/hipTestMain/config/config_amd_linux @@ -268,6 +268,10 @@ "Unit_hipModuleGetGlobal_Negative_Name_Is_Empty_String", "Note: Test disabled due to defect - EXSWHTEC-165", "Unit_hipModuleGetGlobal_Negative_Dptr_And_Bytes_Are_Nullptr", + "Note: Test disabled due to defect - EXSWHTEC-166", + "Unit_hipModuleGetTexRef_Negative_Hmod_Is_Nullptr", + "Note: Test disabled due to defect - EXSWHTEC-167", + "Unit_hipModuleGetTexRef_Negative_Name_Is_Empty_String", #endif #if defined VEGA20 "=== SWDEV-419112 Below tests fail in stress test on 29/08/23 ===", diff --git a/projects/hip-tests/catch/hipTestMain/config/config_amd_windows b/projects/hip-tests/catch/hipTestMain/config/config_amd_windows index c26e5cdd67..9a780a8730 100644 --- a/projects/hip-tests/catch/hipTestMain/config/config_amd_windows +++ b/projects/hip-tests/catch/hipTestMain/config/config_amd_windows @@ -369,6 +369,10 @@ "Unit_hipModuleGetGlobal_Negative_Name_Is_Empty_String", "Note: Test disabled due to defect - EXSWHTEC-165", "Unit_hipModuleGetGlobal_Negative_Dptr_And_Bytes_Are_Nullptr", + "Note: Test disabled due to defect - EXSWHTEC-166", + "Unit_hipModuleGetTexRef_Negative_Hmod_Is_Nullptr", + "Note: Test disabled due to defect - EXSWHTEC-167", + "Unit_hipModuleGetTexRef_Negative_Name_Is_Empty_String", #endif "End of json" ] diff --git a/projects/hip-tests/catch/unit/module/CMakeLists.txt b/projects/hip-tests/catch/unit/module/CMakeLists.txt index 3d2611753c..f8ab77055c 100644 --- a/projects/hip-tests/catch/unit/module/CMakeLists.txt +++ b/projects/hip-tests/catch/unit/module/CMakeLists.txt @@ -28,6 +28,7 @@ set(TEST_SRC hipModuleGetFunction.cc hipModuleLaunchKernel.cc hipModuleGetGlobal.cc + hipModuleGetTexRef.cc ) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/get_function_module.code @@ -46,6 +47,12 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/get_global_test_module.cod add_custom_target(get_global_test_module ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/get_global_test_module.code) +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/get_tex_ref_module.code + COMMAND ${CMAKE_CXX_COMPILER} --genco --std=c++17 ${CMAKE_CURRENT_SOURCE_DIR}/get_tex_ref_module.cc -o get_tex_ref_module.code + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/get_tex_ref_module.cc) +add_custom_target(get_tex_ref_module ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/get_tex_ref_module.code) + + add_custom_target(empty_module.code COMMAND ${CMAKE_CXX_COMPILER} --genco ${OFFLOAD_ARCH_STR} ${CMAKE_CURRENT_SOURCE_DIR}/empty_module.cc @@ -151,6 +158,7 @@ add_dependencies(build_tests empty_module.code) add_dependencies(ModuleTest get_function_module) add_dependencies(ModuleTest launch_kernel_module) add_dependencies(ModuleTest get_global_test_module) +add_dependencies(ModuleTest get_tex_ref_module) if(HIP_PLATFORM MATCHES "amd") add_dependencies(build_tests copyKernel.code copyKernel.s) diff --git a/projects/hip-tests/catch/unit/module/get_tex_ref_module.cc b/projects/hip-tests/catch/unit/module/get_tex_ref_module.cc new file mode 100644 index 0000000000..ffe2213ea0 --- /dev/null +++ b/projects/hip-tests/catch/unit/module/get_tex_ref_module.cc @@ -0,0 +1,24 @@ +/* +Copyright (c) 2022 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 + +texture tex; \ No newline at end of file diff --git a/projects/hip-tests/catch/unit/module/hipModuleGetTexRef.cc b/projects/hip-tests/catch/unit/module/hipModuleGetTexRef.cc new file mode 100644 index 0000000000..1b3c8a50b4 --- /dev/null +++ b/projects/hip-tests/catch/unit/module/hipModuleGetTexRef.cc @@ -0,0 +1,67 @@ +/* +Copyright (c) 2022 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_module_common.hh" + +#include +#include + +static hipModule_t GetModule() { + HIP_CHECK(hipFree(nullptr)); + static const auto mg = ModuleGuard::LoadModule("get_tex_ref_module.code"); + return mg.module(); +} + +TEST_CASE("Unit_hipModuleGetTexRef_Positive_Basic") { + hipTexRef tex_ref = nullptr; + HIP_CHECK(hipModuleGetTexRef(&tex_ref, GetModule(), "tex")); + REQUIRE(tex_ref != nullptr); +} + +TEST_CASE("Unit_hipModuleGetTexRef_Negative_Parameters") { + hipModule_t module = GetModule(); + hipTexRef tex_ref = nullptr; + + SECTION("texRef == nullptr") { + HIP_CHECK_ERROR(hipModuleGetTexRef(nullptr, module, "tex"), hipErrorInvalidValue); + } + + SECTION("name == nullptr") { + HIP_CHECK_ERROR(hipModuleGetTexRef(&tex_ref, module, nullptr), hipErrorInvalidValue); + } + + SECTION("name == non existent texture") { + HIP_CHECK_ERROR(hipModuleGetTexRef(&tex_ref, module, "non_existent_texture"), hipErrorNotFound); + } +} + +TEST_CASE("Unit_hipModuleGetTexRef_Negative_Hmod_Is_Nullptr") { + hipTexRef tex_ref = nullptr; + + HIP_CHECK_ERROR(hipModuleGetTexRef(&tex_ref, nullptr, "tex"), hipErrorInvalidResourceHandle); +} + +TEST_CASE("Unit_hipModuleGetTexRef_Negative_Name_Is_Empty_String") { + hipModule_t module = GetModule(); + hipTexRef tex_ref = nullptr; + + HIP_CHECK_ERROR(hipModuleGetTexRef(&tex_ref, module, ""), hipErrorInvalidValue); +} \ No newline at end of file