SWDEV-546865 - Disable core dumps when running tests (#880)

* SWDEV-546865 - Disable core dumps when running tests

* SWDEV-546865 - Disable core dumps only for tests that require it
Этот коммит содержится в:
vstojilj
2025-09-15 15:58:41 +02:00
коммит произвёл GitHub
родитель d1b2b5ed44
Коммит f24e2ca676
2 изменённых файлов: 42 добавлений и 0 удалений
+30
Просмотреть файл
@@ -36,6 +36,10 @@ THE SOFTWARE.
#include <thread>
#include "hip_test_features.hh"
#if HT_LINUX
#include <sys/resource.h>
#endif
#ifdef TEST_CLOCK_CYCLE
#define clock_function() clock64()
#else
@@ -634,3 +638,29 @@ class BlockingContext {
} \
HIP_CHECK(hipStreamDestroy(stream)); \
}
// Manage core dumps in specific tests which require it disabled (e.g., hipGetLastErrorOnAbort.cc)
#if HT_LINUX
#define DISABLE_CORE_DUMPS() \
struct rlimit core_limit; \
bool rlimit_saved = false; \
if (getrlimit(RLIMIT_CORE, &core_limit) == 0) { \
if (core_limit.rlim_cur != 0) { \
struct rlimit new_limit; \
new_limit.rlim_cur = 0; \
new_limit.rlim_max = core_limit.rlim_max; \
if (setrlimit(RLIMIT_CORE, &new_limit) == 0) { \
rlimit_saved = true; \
} \
} \
}
#define RESTORE_CORE_DUMPS() \
if (rlimit_saved) { \
setrlimit(RLIMIT_CORE, &core_limit); \
rlimit_saved = false; \
}
#else
#define DISABLE_CORE_DUMPS()
#define RESTORE_CORE_DUMPS()
#endif
+12
Просмотреть файл
@@ -46,6 +46,8 @@ static __global__ void squareKernel(int* arr) {
* - HIP_VERSION >= 7.0
*/
TEST_CASE("Unit_hipGetLastError_KernelFailure_ValidAndInvalidOperations") {
DISABLE_CORE_DUMPS();
int* devMem = nullptr;
HIP_CHECK(hipMalloc(&devMem, sizeBytes));
REQUIRE(devMem != nullptr);
@@ -83,6 +85,8 @@ TEST_CASE("Unit_hipGetLastError_KernelFailure_ValidAndInvalidOperations") {
ret = hipGetLastError();
REQUIRE(ret == hipErrorIllegalAddress);
RESTORE_CORE_DUMPS();
}
/**
@@ -106,6 +110,8 @@ TEST_CASE("Unit_hipGetLastError_KernelFailure_TwoDevices") {
return;
}
DISABLE_CORE_DUMPS();
// Perform Invalid operation on Device 0
HIP_CHECK(hipSetDevice(0));
@@ -147,6 +153,8 @@ TEST_CASE("Unit_hipGetLastError_KernelFailure_TwoDevices") {
ret = hipGetLastError();
REQUIRE(ret == expectedError);
RESTORE_CORE_DUMPS();
}
/**
@@ -163,6 +171,8 @@ TEST_CASE("Unit_hipGetLastError_KernelFailure_TwoDevices") {
* - HIP_VERSION >= 7.0
*/
TEST_CASE("Unit_hipGetLastError_KernelFailure_TwoStreams") {
DISABLE_CORE_DUMPS();
int* devMem = nullptr;
HIP_CHECK(hipMalloc(&devMem, sizeBytes));
REQUIRE(devMem != nullptr);
@@ -197,4 +207,6 @@ TEST_CASE("Unit_hipGetLastError_KernelFailure_TwoStreams") {
ret = hipGetLastError();
REQUIRE(ret == hipErrorIllegalAddress);
RESTORE_CORE_DUMPS();
}