[apiConformance] Stop work after crash and save report (#16539)
This commit is contained in:
1 parent
c2a90f4c01
commit
a368e10fff
3 files changed
+38
-18
No files matched your search
@@ -44,10 +44,9 @@ inline std::shared_ptr<ngraph::Function> getDefaultNGraphFunctionForTheDevice(st
|
||||
|
||||
class APIBaseTest : public CommonTestUtils::TestsCommon {
|
||||
private:
|
||||
// place to jump in case of a crash
|
||||
int jmpRes = 0;
|
||||
// in case of crash jump will be made and work will be continued
|
||||
const std::unique_ptr<CommonTestUtils::CrashHandler> crashHandler = std::unique_ptr<CommonTestUtils::CrashHandler>(new CommonTestUtils::CrashHandler());
|
||||
const std::unique_ptr<CommonTestUtils::CrashHandler> crashHandler = std::unique_ptr<CommonTestUtils::CrashHandler>(
|
||||
new CommonTestUtils::CrashHandler(CommonTestUtils::CONFORMANCE_TYPE::api));
|
||||
|
||||
protected:
|
||||
size_t k = 1;
|
||||
@@ -66,17 +65,7 @@ public:
|
||||
k = test_name.find("_mandatory") != std::string::npos || test_name.find("mandatory_") != std::string::npos ? 1 : 0;
|
||||
std::cout << "[ CONFORMANCE ] Influence coefficient: " << k << std::endl;
|
||||
api_summary.updateStat(api_entity, target_device, ov::test::utils::PassRate::Statuses::CRASHED, k);
|
||||
#ifdef _WIN32
|
||||
jmpRes = setjmp(CommonTestUtils::env);
|
||||
#else
|
||||
jmpRes = sigsetjmp(CommonTestUtils::env, 0);
|
||||
#endif
|
||||
if (jmpRes == CommonTestUtils::JMP_STATUS::ok) {
|
||||
crashHandler->StartTimer();
|
||||
} else if (jmpRes == CommonTestUtils::JMP_STATUS::alarmErr) {
|
||||
api_summary.updateStat(api_entity, target_device, ov::test::utils::PassRate::Statuses::HANGED, k);
|
||||
GTEST_FAIL();
|
||||
}
|
||||
crashHandler->StartTimer();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
||||
+2
-1
@@ -16,13 +16,14 @@ namespace CommonTestUtils {
|
||||
extern jmp_buf env;
|
||||
|
||||
enum JMP_STATUS { ok = 0, anyError = 1, alarmErr = 2 };
|
||||
enum CONFORMANCE_TYPE { op = 0, api = 1 };
|
||||
|
||||
class CrashHandler {
|
||||
private:
|
||||
static unsigned int MAX_TEST_WORK_TIME;
|
||||
static bool IGNORE_CRASH;
|
||||
public:
|
||||
CrashHandler();
|
||||
CrashHandler(CONFORMANCE_TYPE type = CONFORMANCE_TYPE::op);
|
||||
~CrashHandler();
|
||||
static void SetUpTimeout(unsigned int timeout);
|
||||
static void SetUpPipelineAfterCrash(bool ignore_crash);
|
||||
|
||||
@@ -3,24 +3,34 @@
|
||||
//
|
||||
|
||||
#include "functional_test_utils/summary/op_summary.hpp"
|
||||
#include "functional_test_utils/summary/api_summary.hpp"
|
||||
|
||||
#include "functional_test_utils/crash_handler.hpp"
|
||||
#include <signal.h>
|
||||
#include <limits.h>
|
||||
|
||||
namespace CommonTestUtils {
|
||||
|
||||
#if defined(__APPLE__)
|
||||
typedef sig_t sighandler;
|
||||
#elif defined(_WIN32)
|
||||
typedef _crt_signal_t sighandler;
|
||||
#else
|
||||
typedef sighandler_t sighandler;
|
||||
#endif
|
||||
|
||||
// enviroment to restore in case of crash
|
||||
jmp_buf env;
|
||||
unsigned int CrashHandler::MAX_TEST_WORK_TIME = UINT_MAX;
|
||||
bool CrashHandler::IGNORE_CRASH = false;
|
||||
|
||||
CrashHandler::CrashHandler() {
|
||||
CrashHandler::CrashHandler(CONFORMANCE_TYPE type) {
|
||||
// setup default value for timeout in 15 minutes
|
||||
if (MAX_TEST_WORK_TIME == UINT_MAX) {
|
||||
MAX_TEST_WORK_TIME = 900;
|
||||
}
|
||||
|
||||
auto crashHandler = [](int errCode) {
|
||||
sighandler crashHandler = [](int errCode) {
|
||||
std::cerr << "Unexpected application crash with code: " << errCode << std::endl;
|
||||
|
||||
// reset custom signal handler to avoid infinit loop
|
||||
@@ -43,7 +53,7 @@ CrashHandler::CrashHandler() {
|
||||
#ifdef _WIN32
|
||||
longjmp(env, JMP_STATUS::anyError);
|
||||
#else
|
||||
// reset timeout
|
||||
// reset timeout
|
||||
alarm(0);
|
||||
|
||||
if (errCode == SIGALRM) {
|
||||
@@ -55,6 +65,26 @@ CrashHandler::CrashHandler() {
|
||||
#endif
|
||||
};
|
||||
|
||||
if (type == CONFORMANCE_TYPE::api) {
|
||||
crashHandler = [](int errCode) {
|
||||
std::cerr << "Unexpected application crash with code: " << errCode << ". Program will aborted." << std::endl;
|
||||
|
||||
// reset custom signal handler to avoid infinit loop
|
||||
// if for some reasons sigsetjmp will not be available
|
||||
signal(SIGABRT, SIG_DFL);
|
||||
signal(SIGSEGV, SIG_DFL);
|
||||
signal(SIGILL, SIG_DFL);
|
||||
#ifndef _WIN32
|
||||
signal(SIGBUS, SIG_DFL);
|
||||
signal(SIGFPE, SIG_DFL);
|
||||
signal(SIGALRM, SIG_DFL);
|
||||
#endif
|
||||
auto &s = ov::test::utils::ApiSummary::getInstance();
|
||||
s.saveReport();
|
||||
std::abort();
|
||||
};
|
||||
}
|
||||
|
||||
// setup custom handler for signals
|
||||
signal(SIGABRT, crashHandler);
|
||||
signal(SIGSEGV, crashHandler);
|
||||
|
||||
Reference in new issue
Block a user