SWDEV-388833 - [catch2][dtest] g++ test migrated from dtests to catch2 (#353)

Change-Id: I6f23fa88dc6066c2c779348c245a1eb69fb807cb

[ROCm/hip-tests commit: a50aaea803]
Этот коммит содержится в:
ROCm CI Service Account
2023-07-09 08:53:17 +05:30
коммит произвёл GitHub
родитель d407c5799b
Коммит 15b519869c
6 изменённых файлов: 135 добавлений и 1 удалений
+8 -1
Просмотреть файл
@@ -102,7 +102,14 @@ THE SOFTWARE.
*/
/**
* @defgroup KernelTest Kernel Functions Management
* @defgroup MemoryTest memory Management APIs
* @{
* This section describes the memory management types & functions of HIP runtime API.
* @}
*/
/**
* @defgroup KernelTest Kernel Functions Management
* @{
* This section describes the various kernel functions invocation.
* @}
+2
Просмотреть файл
@@ -36,7 +36,9 @@ add_subdirectory(compiler)
add_subdirectory(errorHandling)
add_subdirectory(cooperativeGrps)
add_subdirectory(context)
add_subdirectory(g++)
add_subdirectory(module)
if(HIP_PLATFORM STREQUAL "amd")
add_subdirectory(callback)
#add_subdirectory(clock)
+19
Просмотреть файл
@@ -0,0 +1,19 @@
# AMD specific test
if(HIP_PLATFORM MATCHES "amd")
if(UNIX)
set(TEST_SRC
hipMalloc.cc
)
# Creating Custom object file
add_custom_target(malloc_custom COMMAND g++ -c ${CMAKE_CURRENT_SOURCE_DIR}/hipMalloc.cpp -I${HIP_PATH}/include -D__HIP_PLATFORM_AMD__ -o malloc.o BYPRODUCTS malloc.o)
add_library(malloc_gpp OBJECT IMPORTED)
set_property(TARGET malloc_gpp PROPERTY IMPORTED_OBJECTS "${CMAKE_CURRENT_BINARY_DIR}/malloc.o")
hip_add_exe_to_target(NAME gppTests
TEST_SRC ${TEST_SRC}
TEST_TARGET_NAME build_tests
LINKER_LIBS malloc_gpp)
add_dependencies(gppTests malloc_custom)
endif()
endif()
+49
Просмотреть файл
@@ -0,0 +1,49 @@
/*
* 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 WARRANNTY OF ANY KIND, EXPRESS OR
* IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* */
#include <hip_test_common.hh>
#include <hip_test_defgroups.hh>
#include "hipMalloc.h"
/**
* @addtogroup hipMalloc hipMalloc
* @{
* @ingroup MemoryTest
* `hipError_t hipMalloc(void** ptr, size_t size)` -
* Allocate memory on the default accelerator.
* @}
*/
/**
* Test Description
* ------------------------
* - Allocate memory by using hipMalloc API and verify hipSuccess is returned.
* Test source
* ------------------------
* - catch/unit/g++/hipMalloc.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.6
*/
TEST_CASE("Unit_hipMalloc_gpptest") {
printf("calling cpp function from here\n");
int result = MallocFunc();
REQUIRE(result == 1);
}
+35
Просмотреть файл
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2019 - 2021 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 WARRANNTY OF ANY KIND, EXPRESS OR
* IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* */
#include <hip/hip_runtime_api.h>
#include <iostream>
#include "hipMalloc.h"
int MallocFunc() {
int* Ad;
hipError_t err;
err = hipMalloc(reinterpret_cast<void**>(&Ad), 1024);
if (err == hipSuccess) {
std::cout <<"PASSED!" <<std::endl;
return 1;
} else {
std::cout <<"FAILED!" <<std::endl;
return 0;
}
}
+22
Просмотреть файл
@@ -0,0 +1,22 @@
/*
* 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 WARRANNTY OF ANY KIND, EXPRESS OR
* IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* */
#include <iostream>
extern int MallocFunc();