Adding Integration tests for later building option (#126)

* Adding Integeration tests for later building option

* Update CMakeLists.txt

---------

Co-authored-by: Ammar ELWazir <aelwazir@amd.com>

[ROCm/aqlprofile commit: e4bb0df9d5]
This commit is contained in:
Elwazir, Ammar
2025-06-23 16:53:17 -05:00
committed by GitHub
parent 14c997d5b4
commit fb6ec25d41
17 changed files with 44 additions and 25 deletions
+17 -6
View File
@@ -12,9 +12,9 @@ include(GNUInstallDirs)
## Adding default path cmake modules ## Adding default path cmake modules
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" ) list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
## Include common cmake modules ## Include common cmake modules
include ( utils ) include (utils)
## Set build environment ## Set build environment
include ( env ) include (env)
set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "Library install directory") set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "Library install directory")
@@ -65,6 +65,13 @@ set ( TEST_BINARY_DIR ${PROJECT_BINARY_DIR}/test )
add_subdirectory ( ${TEST_DIR} ${TEST_BINARY_DIR} ) add_subdirectory ( ${TEST_DIR} ${TEST_BINARY_DIR} )
endif() endif()
if(AQLPROFILE_INSTALL_TESTS)
# Install Integration Tests
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/integration/
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests/integration
COMPONENT tests)
endif()
## Add the install directives for the runtime library. ## Add the install directives for the runtime library.
set ( DEST_NAME ${AQLPROFILE_NAME} ) set ( DEST_NAME ${AQLPROFILE_NAME} )
install ( TARGETS ${AQLPROFILE_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime ) install ( TARGETS ${AQLPROFILE_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime )
@@ -72,12 +79,16 @@ install ( TARGETS ${AQLPROFILE_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDI
## Add the packaging directives for the runtime library. ## Add the packaging directives for the runtime library.
if ( ENABLE_ASAN_PACKAGING ) if ( ENABLE_ASAN_PACKAGING )
set ( CPACK_PACKAGE_NAME ${AQLPROFILE_NAME}-asan ) set (CPACK_PACKAGE_NAME ${AQLPROFILE_NAME}-asan)
# ASAN Package requires only asan component with libraries and license file # ASAN Package requires only asan component with libraries and license file
set ( CPACK_COMPONENTS_ALL asan ) set (CPACK_COMPONENTS_ALL asan )
else() else()
set ( CPACK_PACKAGE_NAME ${AQLPROFILE_NAME} ) set (CPACK_PACKAGE_NAME ${AQLPROFILE_NAME})
set ( CPACK_COMPONENTS_ALL runtime tests ) set (CPACK_COMPONENTS_ALL runtime)
# Add tests component if INSTALL_TESTS is enabled
if(AQLPROFILE_INSTALL_TESTS)
list(APPEND CPACK_COMPONENTS_ALL tests)
endif()
endif() endif()
set ( CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc." ) set ( CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc." )
set ( CPACK_PACKAGE_VERSION_MAJOR ${BUILD_VERSION_MAJOR} ) set ( CPACK_PACKAGE_VERSION_MAJOR ${BUILD_VERSION_MAJOR} )
+1 -1
View File
@@ -25,7 +25,7 @@ set ( LIB_SRC
) )
add_library ( ${TARGET_LIB} SHARED ${LIB_SRC} ) add_library ( ${TARGET_LIB} SHARED ${LIB_SRC} )
target_include_directories ( ${TARGET_LIB} PRIVATE ${LIB_DIR} ${API_PATH}) target_include_directories ( ${TARGET_LIB} PRIVATE ${LIB_DIR} ${API_PATH} ${LIB_DIR}/core/include)
target_link_libraries( ${TARGET_LIB} PRIVATE pthread hsa-runtime64::hsa-runtime64 ) target_link_libraries( ${TARGET_LIB} PRIVATE pthread hsa-runtime64::hsa-runtime64 )
## Generating definitions ## Generating definitions
+1 -1
View File
@@ -21,7 +21,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#include "core/aql_profile.hpp" #include "core/aql_profile.hpp"
#include "core/include/aql_profile_v2.h" #include "aqlprofile-sdk/aql_profile_v2.h"
#include <cstdint> #include <cstdint>
#include <future> #include <future>
+1 -1
View File
@@ -27,7 +27,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include "include/aql_profile_v2.h" #include "aqlprofile-sdk/aql_profile_v2.h"
#include "core/aql_profile_exception.h" #include "core/aql_profile_exception.h"
+1 -1
View File
@@ -21,7 +21,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#include "core/aql_profile.hpp" #include "core/aql_profile.hpp"
#include "core/include/aql_profile_v2.h" #include "aqlprofile-sdk/aql_profile_v2.h"
#include <array> #include <array>
#include <cstddef> #include <cstddef>
@@ -1,5 +1,5 @@
set(AQLPROFILE_HEADER_FILES set(AQLPROFILE_HEADER_FILES
aql_profile_v2.h aqlprofile-sdk/aql_profile_v2.h
) )
install( install(
@@ -26,7 +26,7 @@
#include <mutex> #include <mutex>
#include <unordered_map> #include <unordered_map>
#include <memory> #include <memory>
#include "include/aql_profile_v2.h" #include "aqlprofile-sdk/aql_profile_v2.h"
#include <stdexcept> #include <stdexcept>
#include "pm4/trace_config.h" #include "pm4/trace_config.h"
+1 -1
View File
@@ -34,7 +34,7 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include "core/include/aql_profile_v2.h" #include "aqlprofile-sdk/aql_profile_v2.h"
#include "core/aql_profile.hpp" #include "core/aql_profile.hpp"
#include "core/aql_profile_exception.h" #include "core/aql_profile_exception.h"
#include "def/gpu_block_info.h" #include "def/gpu_block_info.h"
@@ -1,3 +1,6 @@
cmake_minimum_required(VERSION 3.16.0)
project(aqlprofile-sdk-tests)
# write a CMakeLists.txt file for the gfx9_factory_test # write a CMakeLists.txt file for the gfx9_factory_test
# that includes the necessary libraries and sets the properties for the test # that includes the necessary libraries and sets the properties for the test
include(GoogleTest) include(GoogleTest)
@@ -23,7 +23,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <hsa/hsa.h> #include <hsa/hsa.h>
#include "core/include/aql_profile_v2.h" #include "aqlprofile-sdk/aql_profile_v2.h"
// Mocks and helpers // Mocks and helpers
namespace { namespace {
@@ -94,7 +94,7 @@ TEST(CountersTest, DeletePackets) {
hsa_status_t status = aqlprofile_pmc_create_packets( hsa_status_t status = aqlprofile_pmc_create_packets(
&handle, &packets, profile, mock_alloc, mock_dealloc, mock_memcpy, &mem); &handle, &packets, profile, mock_alloc, mock_dealloc, mock_memcpy, &mem);
// Only proceed if creation succeeded // Only proceed if creation succeeded
if (status == HSA_STATUS_SUCCESS) { if (status == HSA_STATUS_SUCCESS) {
// This should not crash or throw // This should not crash or throw
@@ -106,13 +106,13 @@ TEST(CountersTest, DeletePackets) {
TEST(CountersTest, ValidateEvent) { TEST(CountersTest, ValidateEvent) {
aqlprofile_agent_handle_t agent = {}; aqlprofile_agent_handle_t agent = {};
agent.handle = 0; agent.handle = 0;
aqlprofile_pmc_event_t event = {}; aqlprofile_pmc_event_t event = {};
event.block_name = HSA_VEN_AMD_AQLPROFILE_BLOCK_NAME_GRBM; event.block_name = HSA_VEN_AMD_AQLPROFILE_BLOCK_NAME_GRBM;
bool result = true; bool result = true;
hsa_status_t status = aqlprofile_validate_pmc_event(agent, &event, &result); hsa_status_t status = aqlprofile_validate_pmc_event(agent, &event, &result);
// In a mock environment, we can't guarantee validation, but we can check that it runs // In a mock environment, we can't guarantee validation, but we can check that it runs
EXPECT_TRUE(status == HSA_STATUS_SUCCESS || status == HSA_STATUS_ERROR); EXPECT_TRUE(status == HSA_STATUS_SUCCESS || status == HSA_STATUS_ERROR);
} }
+1 -1
View File
@@ -21,7 +21,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#include "core/aql_profile.hpp" #include "core/aql_profile.hpp"
#include "core/include/aql_profile_v2.h" #include "aqlprofile-sdk/aql_profile_v2.h"
#include <cstdint> #include <cstdint>
#include <future> #include <future>
+6 -2
View File
@@ -7,8 +7,11 @@ if ( NOT DEFINED TEST_DIR )
set ( TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) set ( TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
set ( TEST_BINARY_DIR ${CMAKE_BINARY_DIR} ) set ( TEST_BINARY_DIR ${CMAKE_BINARY_DIR} )
project ( ${EXE_NAME} ) project ( ${EXE_NAME} )
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules" )
## Set build environment ## Set build environment
include ( env ) include ( env )
enable_testing()
include(CTest)
endif () endif ()
## Util sources ## Util sources
@@ -83,7 +86,8 @@ install(FILES ${TEST_DIR}/run_install.sh RENAME run_tests.sh
add_test(NAME legacy-tests COMMAND "${TEST_BINARY_DIR}/run.sh") add_test(NAME legacy-tests COMMAND "${TEST_BINARY_DIR}/run.sh")
if(AQLPROFILE_BUILD_TESTS) option(AQLPROFILE_BUILD_INTEGERATION_TESTS "Build integration tests" ON)
if(AQLPROFILE_BUILD_INTEGERATION_TESTS)
add_subdirectory(integration) add_subdirectory(integration)
enable_testing()
endif() endif()
+1 -1
View File
@@ -22,7 +22,7 @@
#include "hsa/hsa_ext_amd.h" #include "hsa/hsa_ext_amd.h"
#include "aql_profile_v2.h" #include "aqlprofile-sdk/aql_profile_v2.h"
#include <stdlib.h> #include <stdlib.h>
#include <string> #include <string>
@@ -11,6 +11,8 @@ if(NOT DEFINED AQLPROFILE_TARGET)
HINTS /opt/rocm ${CMAKE_INSTALL_PREFIX} HINTS /opt/rocm ${CMAKE_INSTALL_PREFIX}
PATHS /opt/rocm PATHS /opt/rocm
PATH_SUFFIXES lib) PATH_SUFFIXES lib)
enable_testing()
include(CTest)
endif() endif()
find_package( find_package(
@@ -38,8 +38,7 @@
#include <hsa/hsa.h> #include <hsa/hsa.h>
#include <hsa/hsa_ext_amd.h> #include <hsa/hsa_ext_amd.h>
#include <hsa/hsa_ven_amd_aqlprofile.h> #include <hsa/hsa_ven_amd_aqlprofile.h>
//#include "/opt/rocm/include/aqlprofile-sdk/aql_profile_v2.h" #include "aqlprofile-sdk/aql_profile_v2.h"
#include "aql_profile_v2.h"
#define CHECK_HSA(x) if ((x) != HSA_STATUS_SUCCESS) { std::cerr << __FILE__ << " error at " << __LINE__ << std::endl; exit(-1); } #define CHECK_HSA(x) if ((x) != HSA_STATUS_SUCCESS) { std::cerr << __FILE__ << " error at " << __LINE__ << std::endl; exit(-1); }
@@ -26,7 +26,7 @@
#include <hsa/hsa.h> #include <hsa/hsa.h>
#include <hsa/hsa_ext_amd.h> #include <hsa/hsa_ext_amd.h>
#include <hsa/hsa_ven_amd_aqlprofile.h> #include <hsa/hsa_ven_amd_aqlprofile.h>
#include "aql_profile_v2.h" #include "aqlprofile-sdk/aql_profile_v2.h"
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <atomic> #include <atomic>