Test case for system exceptions in FeatureTest and try to catch more of them

This commit is contained in:
jriegel 2014-02-20 20:03:33 +01:00
parent 2915712842
commit 56d5e193bb
2 changed files with 14 additions and 4 deletions

View File

@ -921,29 +921,31 @@ void segmentation_fault_handler(int sig)
switch (sig) { switch (sig) {
case SIGSEGV: case SIGSEGV:
std::cerr << "Illegal storage access..." << std::endl; std::cerr << "Illegal storage access..." << std::endl;
throw Base::Exception("Illegal storage access! Please save you work under a new file name and restart the application!");
break; break;
case SIGABRT: case SIGABRT:
std::cerr << "Abnormal program termination..." << std::endl; std::cerr << "Abnormal program termination..." << std::endl;
throw Base::Exception("Break signal occoured");
break; break;
default: default:
std::cerr << "Unknown error occurred..." << std::endl; std::cerr << "Unknown error occurred..." << std::endl;
break; break;
} }
#if defined(__GNUC__)
// According to the documentation to C signals we should exit.
exit(3);
#endif
} }
void unhandled_exception_handler() void unhandled_exception_handler()
{ {
std::cerr << "Unhandled exception..." << std::endl; std::cerr << "Unhandled exception..." << std::endl;
throw Base::Exception("Unhandled exception");
} }
void unexpection_error_handler() void unexpection_error_handler()
{ {
std::cerr << "Unexpected error occurred..." << std::endl; std::cerr << "Unexpected error occurred..." << std::endl;
throw Base::Exception("Unexpected error occurred");
terminate(); terminate();
} }

View File

@ -112,13 +112,21 @@ FeatureTest::~FeatureTest()
DocumentObjectExecReturn *FeatureTest::execute(void) DocumentObjectExecReturn *FeatureTest::execute(void)
{ {
int *i,j;
float f;
void *s;
switch(ExceptionType.getValue()) switch(ExceptionType.getValue())
{ {
case 0: break; case 0: break;
case 1: throw "Test Exeption"; case 1: throw "Test Exeption";
case 2: throw Base::Exception("FeatureTestException::execute(): Testexception"); case 2: throw Base::Exception("FeatureTestException::execute(): Testexception");
case 3: *i=0;printf("%i",*i);break; // seg-vault
case 4: j=0; printf("%i",1/j); break; // int devision by zero
case 5: f=0.0; printf("%f",1/f); break; // float devision by zero
case 6: s = malloc(3600000000);break; // float devision by zero
} }
ExecCount.setValue(ExecCount.getValue() + 1); ExecCount.setValue(ExecCount.getValue() + 1);
ExecResult.setValue("Exec"); ExecResult.setValue("Exec");