diff --git a/projects/hip-tests/catch/hipTestMain/config/config_nvidia_linux_common.json b/projects/hip-tests/catch/hipTestMain/config/config_nvidia_linux_common.json index 84df4337fb..baa25636a0 100644 --- a/projects/hip-tests/catch/hipTestMain/config/config_nvidia_linux_common.json +++ b/projects/hip-tests/catch/hipTestMain/config/config_nvidia_linux_common.json @@ -8,16 +8,18 @@ "=== Below test fails in external CI for PR https://github.com/ROCm-Developer-Tools/hip-tests/pull/85 ===", "Unit_hipFuncSetAttribute_Negative_Parameters", "=== Below test fails in external CI for PR https://github.com/ROCm-Developer-Tools/hip-tests/pull/215 ===", - "Unit_ChannelDescriptor_Positive_Basic_1D - long", - "Unit_ChannelDescriptor_Positive_Basic_1D - unsigned long", - "Unit_ChannelDescriptor_Positive_Basic_1D - ulong1", - "Unit_ChannelDescriptor_Positive_Basic_1D - signed long", - "Unit_ChannelDescriptor_Positive_Basic_1D - long1", - "Unit_ChannelDescriptor_Positive_Basic_2D - ulong2", - "Unit_ChannelDescriptor_Positive_Basic_2D - long2", - "Unit_ChannelDescriptor_Positive_Basic_3D - ulong3", - "Unit_ChannelDescriptor_Positive_Basic_3D - long3", - "Unit_ChannelDescriptor_Positive_Basic_4D - ulong4", - "Unit_ChannelDescriptor_Positive_Basic_4D - long4" + "Unit_ChannelDescriptor_Positive_Basic_1D - long", + "Unit_ChannelDescriptor_Positive_Basic_1D - unsigned long", + "Unit_ChannelDescriptor_Positive_Basic_1D - ulong1", + "Unit_ChannelDescriptor_Positive_Basic_1D - signed long", + "Unit_ChannelDescriptor_Positive_Basic_1D - long1", + "Unit_ChannelDescriptor_Positive_Basic_2D - ulong2", + "Unit_ChannelDescriptor_Positive_Basic_2D - long2", + "Unit_ChannelDescriptor_Positive_Basic_3D - ulong3", + "Unit_ChannelDescriptor_Positive_Basic_3D - long3", + "Unit_ChannelDescriptor_Positive_Basic_4D - ulong4", + "Unit_ChannelDescriptor_Positive_Basic_4D - long4", + "=== Below test fails in external CI for PR https://github.com/ROCm-Developer-Tools/hip-tests/pull/38 ===", + "Unit_hipFreeAsync_negative" ] } diff --git a/projects/hip-tests/catch/unit/memory/CMakeLists.txt b/projects/hip-tests/catch/unit/memory/CMakeLists.txt index 46d8bdf994..1608574891 100644 --- a/projects/hip-tests/catch/unit/memory/CMakeLists.txt +++ b/projects/hip-tests/catch/unit/memory/CMakeLists.txt @@ -108,6 +108,7 @@ set(TEST_SRC hipMemAdvise_old.cc hipMemAdvise.cc hipMemRangeGetAttributes.cc + hipFreeAsync.cc hipMallocAsync.cc hipStreamAttachMemAsync.cc hipMemRangeGetAttributes_old.cc diff --git a/projects/hip-tests/catch/unit/memory/hipFreeAsync.cc b/projects/hip-tests/catch/unit/memory/hipFreeAsync.cc new file mode 100644 index 0000000000..6962189655 --- /dev/null +++ b/projects/hip-tests/catch/unit/memory/hipFreeAsync.cc @@ -0,0 +1,44 @@ +/* +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 + +TEST_CASE("Unit_hipFreeAsync_negative") { + HIP_CHECK(hipSetDevice(0)); + void* p = nullptr; + hipStream_t stream{nullptr}; + hipStreamCreate(&stream); + + SECTION("dev_ptr is nullptr") { REQUIRE(hipFreeAsync(nullptr, stream) != hipSuccess); } + + SECTION("invalid stream handle") { + HIP_CHECK(hipMallocAsync(static_cast(&p), 100, stream)); + HIP_CHECK(hipStreamSynchronize(stream)); + hipError_t error = hipFreeAsync(p, reinterpret_cast(-1)); + HIP_CHECK(hipFreeAsync(p, stream)); + HIP_CHECK(hipStreamSynchronize(stream)); + REQUIRE(error != hipSuccess); + } + + HIP_CHECK(hipStreamSynchronize(stream)); + HIP_CHECK(hipStreamDestroy(stream)); +}