Files
TheRock/rocm-systems/projects/hip-tests/catch/unit/errorHandling/hipDynamicLogging.cc
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

139 lines
3.7 KiB
C++

/*
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
*
* SPDX-License-Identifier: MIT
*/
#include <hip_test_common.hh>
#include "OutCapture.hh"
/**
* @addtogroup hipDynamicLogging hipDynamicLogging
* @{
* @ingroup ErrorTest
* `hipExtSetLoggingParams(size_t log_level, size_t log_size, size_t log_mask)` -
* Sets logging parameters for HIP runtime.
* `hipExtEnableLogging()` -
* Enables HIP runtime logging.
* `hipExtDisableLogging()` -
* Disables HIP runtime logging.
*/
static bool hipDynamicLoggingTest() {
// Create output capture instance
OutCapture capture;
capture.startCapture();
// Set Logging params
HIP_CHECK(hipExtSetLoggingParams(4, 0, -1));
// Logging is disabled here - allocate memory
int* dptr = nullptr;
HIP_CHECK(hipMalloc(&dptr, sizeof(int)));
// Stop capture after hipMalloc and check no output (logging disabled)
std::string malloc_output = capture.stopCapture();
if (malloc_output.size() != 0) {
INFO("Unexpected logging output during hipMalloc (logging should be disabled): " << malloc_output);
return false;
}
// Start capture before enabling logging
capture.startCapture();
// Enable logging and do memset
HIP_CHECK(hipExtEnableLogging());
HIP_CHECK(hipMemset(dptr, 0x00, sizeof(int)));
// Disable logging
HIP_CHECK(hipExtDisableLogging());
// Stop capture after disabling logging and check for output
std::string logging_output = capture.stopCapture();
if (logging_output.size() == 0) {
INFO("Expected logging output during enabled logging period, but got none");
return false;
}
// Clean up
HIP_CHECK(hipFree(dptr));
INFO("Successfully captured HIP logging output (" << logging_output.size() << " bytes)");
INFO("Logging output: " << logging_output);
return true;
}
/**
* Test Description
* ------------------------
* - Validates that HIP dynamic logging works correctly:
* 1. No output when logging is disabled
* 2. Logging output is captured when logging is enabled
* 3. hipMemset operation produces logging output during enabled period
* Test source
* ------------------------
* - unit/errorHandling/hipDynamicLogging.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.6
*/
HIP_TEST_CASE(Unit_hipDynamicLogging_Positive_Basic) {
int numDevices = 0;
HIP_CHECK(hipGetDeviceCount(&numDevices));
if (numDevices <= 0) {
HIP_SKIP_TEST(HipTest::SkipReason::kNoGpuDevice);
}
REQUIRE(hipDynamicLoggingTest() == true);
}
/**
* Test Description
* ------------------------
* - Validates that hipExtSetLoggingParams sets logging parameters correctly
* and that logging can be enabled/disabled multiple times
* Test source
* ------------------------
* - unit/errorHandling/hipDynamicLogging.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.6
*/
HIP_TEST_CASE(Unit_hipDynamicLogging_Positive_MultipleEnableDisable) {
int numDevices = 0;
HIP_CHECK(hipGetDeviceCount(&numDevices));
if (numDevices <= 0) {
HIP_SKIP_TEST(HipTest::SkipReason::kNoGpuDevice);
}
// Test multiple enable/disable cycles
OutCapture capture;
int* dptr = nullptr;
HIP_CHECK(hipMalloc(&dptr, sizeof(int)));
// Set different logging parameters
HIP_CHECK(hipExtSetLoggingParams(3, 0, -1));
for (int i = 0; i < 3; ++i) {
// Start capture and enable logging
capture.startCapture();
HIP_CHECK(hipExtEnableLogging());
HIP_CHECK(hipMemset(dptr, 0x42, sizeof(int)));
HIP_CHECK(hipExtDisableLogging());
// Check that we captured some output
std::string output = capture.stopCapture();
REQUIRE(output.size() > 0);
}
HIP_CHECK(hipFree(dptr));
}
/**
* End doxygen group ErrorTest.
* @}
*/