test: improve logging in unit tests
include API name unify tests timeout/sigabrt message across OSes Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
parent
a4bbfb41b4
commit
a361ca1e3f
|
@ -14,6 +14,10 @@
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
extern std::vector<_ze_driver_handle_t *> *globalDriverHandles;
|
extern std::vector<_ze_driver_handle_t *> *globalDriverHandles;
|
||||||
}
|
}
|
||||||
|
namespace NEO {
|
||||||
|
const char *apiName = "L0";
|
||||||
|
}
|
||||||
|
|
||||||
using namespace NEO;
|
using namespace NEO;
|
||||||
void cleanTestHelpers() {
|
void cleanTestHelpers() {
|
||||||
delete L0::globalDriverHandles;
|
delete L0::globalDriverHandles;
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace NEO {
|
||||||
class OsLibrary;
|
class OsLibrary;
|
||||||
void __attribute__((destructor)) platformsDestructor();
|
void __attribute__((destructor)) platformsDestructor();
|
||||||
extern const DeviceDescriptor deviceDescriptorTable[];
|
extern const DeviceDescriptor deviceDescriptorTable[];
|
||||||
|
const char *apiName = "OCL";
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|
||||||
NEO::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace) {
|
NEO::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2021-2024 Intel Corporation
|
* Copyright (C) 2021-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -11,5 +11,6 @@ unsigned int ultIterationMaxTimeInS = 90;
|
||||||
#else
|
#else
|
||||||
unsigned int ultIterationMaxTimeInS = 45;
|
unsigned int ultIterationMaxTimeInS = 45;
|
||||||
#endif
|
#endif
|
||||||
const char *executionName = "OCLOC";
|
const char *executionName = "ULT";
|
||||||
|
const char *apiName = "OCLOC";
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
#include "opencl/test/unit_test/ult_config_listener.h"
|
#include "opencl/test/unit_test/ult_config_listener.h"
|
||||||
|
|
||||||
#include "test_files_setup.h"
|
#include "test_files_setup.h"
|
||||||
|
namespace NEO {
|
||||||
|
const char *apiName = "OCL";
|
||||||
|
}
|
||||||
using namespace NEO;
|
using namespace NEO;
|
||||||
|
|
||||||
void applyWorkarounds() {
|
void applyWorkarounds() {
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
extern std::string lastTest;
|
extern std::string lastTest;
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
extern const char *executionName;
|
extern const char *executionName;
|
||||||
}
|
extern const char *apiName;
|
||||||
|
} // namespace NEO
|
||||||
|
|
||||||
class CCustomEventListener : public ::testing::TestEventListener {
|
class CCustomEventListener : public ::testing::TestEventListener {
|
||||||
public:
|
public:
|
||||||
|
@ -114,28 +115,28 @@ class CCustomEventListener : public ::testing::TestEventListener {
|
||||||
if (unitTest.Failed()) {
|
if (unitTest.Failed()) {
|
||||||
ultStatus = "FAILED";
|
ultStatus = "FAILED";
|
||||||
}
|
}
|
||||||
auto executionNameLen = strlen(NEO::executionName);
|
auto targetNameLen = strlen(NEO::apiName) + 1 + strlen(NEO::executionName);
|
||||||
|
|
||||||
if (hardwarePrefix != "---") {
|
if (hardwarePrefix != "---") {
|
||||||
paddingS = std::string(hardwarePrefix.length() + executionNameLen, ' ');
|
paddingS = std::string(hardwarePrefix.length() + targetNameLen, ' ');
|
||||||
paddingE = std::string(hardwarePrefix.length() + executionNameLen, '=');
|
paddingE = std::string(hardwarePrefix.length() + targetNameLen, '=');
|
||||||
|
|
||||||
fprintf(
|
fprintf(
|
||||||
stdout,
|
stdout,
|
||||||
"\n"
|
"\n"
|
||||||
"%s==================\n"
|
"%s==================\n"
|
||||||
"== %s %ss %s ==\n"
|
"== %s %s %ss %s ==\n"
|
||||||
"%s==================\n",
|
"%s==================\n",
|
||||||
paddingE.c_str(), hardwarePrefix.c_str(), NEO::executionName, ultStatus.c_str(), paddingE.c_str());
|
paddingE.c_str(), hardwarePrefix.c_str(), NEO::apiName, NEO::executionName, ultStatus.c_str(), paddingE.c_str());
|
||||||
} else {
|
} else {
|
||||||
paddingE = std::string(executionNameLen, '=');
|
paddingE = std::string(targetNameLen, '=');
|
||||||
fprintf(
|
fprintf(
|
||||||
stdout,
|
stdout,
|
||||||
"\n"
|
"\n"
|
||||||
"%s==================\n"
|
"%s==================\n"
|
||||||
"== %ss %s ==\n"
|
"== %s %ss %s ==\n"
|
||||||
"%s==================\n",
|
"%s==================\n",
|
||||||
paddingE.c_str(), NEO::executionName, ultStatus.c_str(), paddingE.c_str());
|
paddingE.c_str(), NEO::apiName, NEO::executionName, ultStatus.c_str(), paddingE.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(
|
fprintf(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2024 Intel Corporation
|
* Copyright (C) 2022-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -17,6 +17,7 @@ std::string lastTest("");
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
extern const unsigned int ultIterationMaxTimeInS;
|
extern const unsigned int ultIterationMaxTimeInS;
|
||||||
extern const char *executionName;
|
extern const char *executionName;
|
||||||
|
extern const char *apiName;
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|
||||||
int newStdOut = -1;
|
int newStdOut = -1;
|
||||||
|
@ -26,7 +27,7 @@ void handleSIGABRT(int signal) {
|
||||||
if (newStdOut != -1) {
|
if (newStdOut != -1) {
|
||||||
dup2(newStdOut, 1);
|
dup2(newStdOut, 1);
|
||||||
}
|
}
|
||||||
std::cout << "SIGABRT in " << NEO::executionName << ", on: " << lastTest << std::endl;
|
std::cout << "SIGABRT in " << NEO::apiName << " " << NEO::executionName << ", on: " << lastTest << std::endl;
|
||||||
if (sigaction(SIGABRT, &oldSigAbrt, nullptr) == -1) {
|
if (sigaction(SIGABRT, &oldSigAbrt, nullptr) == -1) {
|
||||||
std::cout << "FATAL: cannot fatal SIGABRT handler" << std::endl;
|
std::cout << "FATAL: cannot fatal SIGABRT handler" << std::endl;
|
||||||
std::cout << "FATAL: try SEGV" << std::endl;
|
std::cout << "FATAL: try SEGV" << std::endl;
|
||||||
|
@ -44,7 +45,7 @@ void handleSIGALRM(int signal) {
|
||||||
if (newStdOut != -1) {
|
if (newStdOut != -1) {
|
||||||
dup2(newStdOut, 1);
|
dup2(newStdOut, 1);
|
||||||
}
|
}
|
||||||
std::cout << "Tests timeout in " << NEO::executionName << ", ";
|
std::cout << "Tests timeout in " << NEO::apiName << " " << NEO::executionName << ",";
|
||||||
if (clock_gettime(CLOCK_MONOTONIC_RAW, &alrmTimeSpec) == 0) {
|
if (clock_gettime(CLOCK_MONOTONIC_RAW, &alrmTimeSpec) == 0) {
|
||||||
auto deltaSec = alrmTimeSpec.tv_sec - startTimeSpec.tv_sec;
|
auto deltaSec = alrmTimeSpec.tv_sec - startTimeSpec.tv_sec;
|
||||||
std::cout << " after: " << deltaSec << " seconds";
|
std::cout << " after: " << deltaSec << " seconds";
|
||||||
|
@ -57,7 +58,7 @@ void handleSIGSEGV(int signal) {
|
||||||
if (newStdOut != -1) {
|
if (newStdOut != -1) {
|
||||||
dup2(newStdOut, 1);
|
dup2(newStdOut, 1);
|
||||||
}
|
}
|
||||||
std::cout << "SIGSEGV in " << NEO::executionName << ", on: " << lastTest << std::endl;
|
std::cout << "SIGSEGV in " << NEO::apiName << " " << NEO::executionName << ", on: " << lastTest << std::endl;
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ std::string lastTest("");
|
||||||
static int newStdOut = -1;
|
static int newStdOut = -1;
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
extern const char *apiName;
|
||||||
extern const char *executionName;
|
extern const char *executionName;
|
||||||
extern unsigned int ultIterationMaxTimeInS;
|
extern unsigned int ultIterationMaxTimeInS;
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
@ -39,7 +40,7 @@ void handleSIGABRT(int sigNo) {
|
||||||
if (newStdOut != -1) {
|
if (newStdOut != -1) {
|
||||||
_dup2(newStdOut, 1);
|
_dup2(newStdOut, 1);
|
||||||
}
|
}
|
||||||
std::cout << "SIGABRT on: " << lastTest << std::endl;
|
std::cout << "SIGABRT in " << NEO::apiName << " " << NEO::executionName << ", on: " << lastTest << std::endl;
|
||||||
signal(SIGABRT, oldSigAbrt);
|
signal(SIGABRT, oldSigAbrt);
|
||||||
raise(sigNo);
|
raise(sigNo);
|
||||||
}
|
}
|
||||||
|
@ -92,20 +93,20 @@ int setAlarm(bool enableAlarm) {
|
||||||
std::cout << "set timeout to: " << alarmTimeInS << " seconds" << std::endl;
|
std::cout << "set timeout to: " << alarmTimeInS << " seconds" << std::endl;
|
||||||
threadStarted = true;
|
threadStarted = true;
|
||||||
std::chrono::high_resolution_clock::time_point startTime, endTime;
|
std::chrono::high_resolution_clock::time_point startTime, endTime;
|
||||||
std::chrono::milliseconds elapsedTime{};
|
std::chrono::milliseconds elapsedTimeInMs{};
|
||||||
startTime = std::chrono::high_resolution_clock::now();
|
startTime = std::chrono::high_resolution_clock::now();
|
||||||
do {
|
do {
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||||
endTime = std::chrono::high_resolution_clock::now();
|
endTime = std::chrono::high_resolution_clock::now();
|
||||||
elapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
|
elapsedTimeInMs = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
|
||||||
if (!abortOnTimeout) {
|
if (!abortOnTimeout) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} while (abortOnTimeout && elapsedTime.count() < alarmTimeInS * 1000);
|
} while (abortOnTimeout && elapsedTimeInMs.count() < alarmTimeInS * 1000);
|
||||||
|
|
||||||
if (abortOnTimeout) {
|
if (abortOnTimeout) {
|
||||||
printf("timeout on: %s\n", lastTest.c_str());
|
printf("Tests timeout in %s %s, after %u seconds on %s\n", NEO::apiName, NEO::executionName, static_cast<uint32_t>(elapsedTimeInMs.count() / 1000), lastTest.c_str());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,6 +38,7 @@ void CpuPageFaultManager::allowCPUMemoryEviction(bool evict, void *ptr, PageFaul
|
||||||
|
|
||||||
void RootDeviceEnvironment::initApiGfxCoreHelper() {
|
void RootDeviceEnvironment::initApiGfxCoreHelper() {
|
||||||
}
|
}
|
||||||
|
const char *apiName = "SHARED";
|
||||||
|
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue