mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Move signals to separate file
Signed-off-by: Baj, Tomasz <tomasz.baj@intel.com> Related-To: NEO-6647
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
31a61a16c0
commit
678ce2ec57
@@ -17,11 +17,43 @@ namespace NEO {
|
||||
extern const unsigned int ultIterationMaxTime;
|
||||
}
|
||||
|
||||
struct sigaction oldSigAbrt;
|
||||
void handleSIGABRT(int signal) {
|
||||
std::cout << "SIGABRT on: " << lastTest << std::endl;
|
||||
if (sigaction(SIGABRT, &oldSigAbrt, nullptr) == -1) {
|
||||
std::cout << "FATAL: cannot fatal SIGABRT handler" << std::endl;
|
||||
std::cout << "FATAL: try SEGV" << std::endl;
|
||||
uint8_t *ptr = nullptr;
|
||||
*ptr = 0;
|
||||
std::cout << "FATAL: still alive, call exit()" << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
raise(signal);
|
||||
}
|
||||
|
||||
void handleSIGALRM(int signal) {
|
||||
std::cout << "Tests timeout on: " << lastTest << std::endl;
|
||||
abort();
|
||||
}
|
||||
|
||||
void handleSIGSEGV(int signal) {
|
||||
std::cout << "SIGSEGV on: " << lastTest << std::endl;
|
||||
abort();
|
||||
}
|
||||
|
||||
int setAbrt(bool enableAbrt) {
|
||||
std::cout << "enable SIGABRT handler: " << enableAbrt << std::endl;
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = &handleSIGABRT;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sigfillset(&sa.sa_mask);
|
||||
if (sigaction(SIGABRT, &sa, &oldSigAbrt) == -1) {
|
||||
std::cout << "FATAL ERROR: cannot intercept SIGABRT" << std::endl;
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setAlarm(bool enableAlarm) {
|
||||
std::cout << "enable SIGALRM handler: " << enableAlarm << std::endl;
|
||||
if (enableAlarm) {
|
||||
@@ -45,3 +77,16 @@ int setAlarm(bool enableAlarm) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setSegv(bool enableSegv) {
|
||||
std::cout << "enable SIGSEGV handler: " << enableSegv << std::endl;
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = &handleSIGSEGV;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sigfillset(&sa.sa_mask);
|
||||
if (sigaction(SIGSEGV, &sa, NULL) == -1) {
|
||||
std::cout << "FATAL ERROR: cannot intercept SIGSEGV" << std::endl;
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,40 @@
|
||||
#include "shared/test/common/libult/signal_utils.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include <windows.h>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
std::string lastTest("");
|
||||
|
||||
LONG WINAPI UltExceptionFilter(
|
||||
_In_ struct _EXCEPTION_POINTERS *exceptionInfo) {
|
||||
std::cout << "UnhandledException: 0x" << std::hex << exceptionInfo->ExceptionRecord->ExceptionCode << std::dec
|
||||
<< " on test: " << lastTest << std::endl;
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
void (*oldSigAbrt)(int) = nullptr;
|
||||
void handleSIGABRT(int sigNo) {
|
||||
std::cout << "SIGABRT on: " << lastTest << std::endl;
|
||||
signal(SIGABRT, oldSigAbrt);
|
||||
raise(sigNo);
|
||||
}
|
||||
|
||||
int setAbrt(bool enableAbrt) {
|
||||
std::cout << "enable SIGABRT handler: " << enableAbrt << std::endl;
|
||||
|
||||
SetUnhandledExceptionFilter(&UltExceptionFilter);
|
||||
if (enableAbrt) {
|
||||
oldSigAbrt = signal(SIGABRT, handleSIGABRT);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setAlarm(bool enableAlarm) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setSegv(bool enableSegv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user