// pointer to the test
BaseTest* test;
- // failure code (CV_FAIL*)
+ // failure code (TS::FAIL_*)
int code;
// seed value right before the data for the failed test case is prepared.
virtual void set_gtest_status();
// test error codes
- enum
+ enum FailureCode
{
// everything is Ok
OK=0,
RNG& get_rng() { return rng; }
// returns the current error code
- int get_err_code() { return current_test_info.code; }
+ TS::FailureCode get_err_code() { return TS::FailureCode(current_test_info.code); }
// returns the test extensivity scale
double get_test_case_count_scale() { return params.test_case_count_scale; }
const string& get_data_path() const { return data_path; }
// returns textual description of failure code
- static string str_from_code( int code );
+ static string str_from_code( const TS::FailureCode code );
protected:
#ifdef _MSC_VER
static void SEHTranslator( unsigned int /*u*/, EXCEPTION_POINTERS* pExp )
{
- int code = TS::FAIL_EXCEPTION;
+ TS::FailureCode code = TS::FAIL_EXCEPTION;
switch( pExp->ExceptionRecord->ExceptionCode )
{
case EXCEPTION_ACCESS_VIOLATION:
static void signalHandler( int sig_code )
{
- int code = TS::FAIL_EXCEPTION;
+ TS::FailureCode code = TS::FAIL_EXCEPTION;
switch( sig_code )
{
case SIGFPE:
code = TS::FAIL_EXCEPTION;
}
- longjmp( tsJmpMark, code );
+ longjmp( tsJmpMark, (int)code );
}
#endif
if( !_code )
run( start_from );
else
- throw _code;
+ throw TS::FailureCode(_code);
#else
run( start_from );
#endif
const char* errorStr = cvErrorStr(exc.code);
char buf[1 << 16];
- sprintf( buf, "OpenCV Error: %s (%s) in %s, file %s, line %d",
+ sprintf( buf, "OpenCV Error:\n\t%s (%s) in %s, file %s, line %d",
errorStr, exc.err.c_str(), exc.func.size() > 0 ?
exc.func.c_str() : "unknown function", exc.file.c_str(), exc.line );
ts->printf(TS::LOG, "%s\n", buf);
+
ts->set_failed_test_info( TS::FAIL_ERROR_IN_CALLED_FUNC );
}
+ catch (const TS::FailureCode& fc)
+ {
+ std::string errorStr = TS::str_from_code(fc);
+ ts->printf(TS::LOG, "General failure:\n\t%s (%d)\n", errorStr.c_str(), fc);
+
+ ts->set_failed_test_info( fc );
+ }
catch (...)
{
+ ts->printf(TS::LOG, "Unknown failure\n");
+
ts->set_failed_test_info( TS::FAIL_EXCEPTION );
}
}
} // dtor
-string TS::str_from_code( int code )
+string TS::str_from_code( const TS::FailureCode code )
{
switch( code )
{
static int tsErrorCallback( int status, const char* func_name, const char* err_msg, const char* file_name, int line, TS* ts )
{
- ts->printf(TS::LOG, "OpenCV Error: %s (%s) in %s, file %s, line %d\n", cvErrorStr(status), err_msg, func_name[0] != 0 ? func_name : "unknown function", file_name, line);
+ ts->printf(TS::LOG, "OpenCV Error:\n\t%s (%s) in %s, file %s, line %d\n", cvErrorStr(status), err_msg, func_name[0] != 0 ? func_name : "unknown function", file_name, line);
return 0;
}
void TS::set_gtest_status()
{
- int code = get_err_code();
+ TS::FailureCode code = get_err_code();
if( code >= 0 )
return SUCCEED();
if( !output_buf[SUMMARY_IDX].empty() )
logs += "\n-----------------------------------\n\tSUM: " + output_buf[SUMMARY_IDX];
if( !output_buf[LOG_IDX].empty() )
- logs += "\n-----------------------------------\n\tLOG: " + output_buf[LOG_IDX];
+ logs += "\n-----------------------------------\n\tLOG:\n" + output_buf[LOG_IDX];
if( !output_buf[CONSOLE_IDX].empty() )
logs += "\n-----------------------------------\n\tCONSOLE: " + output_buf[CONSOLE_IDX];
logs += "\n-----------------------------------\n";
void TS::set_failed_test_info( int fail_code )
{
if( current_test_info.code >= 0 )
- current_test_info.code = fail_code;
+ current_test_info.code = TS::FailureCode(fail_code);
}
#if defined _MSC_VER && _MSC_VER < 1400