Repository: opencv
Issue: TS module does not map SIGFPE to TS::FAIL_ARITHM_EXCEPTION in ts.cpp
Labels: test,priority: low

<!--
If you have a question rather than reporting a bug please go to http://answers.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->

##### System information (version)
<!-- Example
- OpenCV => 3.1
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2015
-->

- OpenCV => **2.4.13.5**
- Operating System / Platform => **Linux / Ubuntu 16.04**
- Compiler => **linux gcc 5.4**

##### Detailed description
The **TS** module has a signal handler to handle the signals from OS and map it to an appropriate test exception so the cause of the test failure is known. However from the code in **ts.cpp at line no: 216** it is throwing ` _code;` instead of `cv::Exception` object due to which the `SIGFPE` is not mapped to an appropriate **TS**'s error code. Is there any reason it is done like this? I am curious to know why it is left out.

Thank you,
Mani

##### Steps to reproduce
Execute the following program as a simple C++ program by linking to **opencv_ts** and its dependencies **opencv_core, tbb, pthread** and **libz**.

```c++
//============================================================================
// Name        : learn_opencv_ts.cpp
// Author      : Mani Kumar
// Version     :
// Copyright   : Free2Copy
// Description : Hello World in C++, Ansi-style
//============================================================================

/*
 * This module is to learn OpenCV by mani
 */

//============================================================================
// 1. test_precomp.hpp
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__

// Module dependencies
#include "opencv2/ts/ts.hpp"

// Constants

#endif // end of __OPENCV_TEST_PRECOMP_HPP__
//============================================================================

//============================================================================
// 2. module under test
#ifndef __OPENCV_MANI_EXPS_HPP__
#define __OPENCV_MANI_EXPS_HPP__

namespace cv
{

class LearnTSModule
{
public:
	LearnTSModule(int a=0, int b=0): m_a(a), m_b(b){};

	int addNums() const { return m_a + m_b; };
	double divideAbyB() const { return m_a / m_b; };

private:
	int m_a;
	int m_b;
};

}

#endif // __OPENCV_MANI_EXPS_HPP__
//============================================================================

//============================================================================
// 3. test code for module
//#include "test_precomp.hpp"

using namespace cv;
using namespace std;

class CV_LearnTSModuleTest : public cvtest::BaseTest
{
public:
	void run(int)
    {
		ts->printf(cvtest::TS::LOG, "start testing LearnTSModule\n");

		// Write tests for the test suite
		EXPECT_EQ(3, LearnTSModule(1, 2).addNums());
		EXPECT_EQ(6, LearnTSModule(4, 2).addNums());

		EXPECT_EQ(2.0f, LearnTSModule(4, 2).divideAbyB());
		EXPECT_EQ(0.0f, LearnTSModule(4, 0).divideAbyB()) << "Expected to get FPE!\n";

		ts->printf(cvtest::TS::LOG, "start testing LearnTSModule\n");
    }
};

// Write test case i.e. test suite
TEST(ManiExps_LearnTSModule, simple_math_ops) { CV_LearnTSModuleTest test; test.safe_run(); }
//============================================================================

//============================================================================
// 4. test main func
//#include "test_precomp.hpp"

CV_TEST_MAIN("test_opencv_ts")
//============================================================================
```