Signal handling

TestApe will react to signals from the operating system. If the signal is caused by one of the VALIDATE macros, for example by accessing memory through an invalid pointer, that validation will fail and execution of the test will continue.

If the signal is caused by one of the functions in the unit being tested, TestApe will terminate the current test and carry on with the next test, however if parameters are used and the test is setup to run more than once, the test will execute again with next parameter until there is no more parameters in the list.

Sample192.1will run test divide twice with parameters 0 and 1. The first execution will fail because a signal is raised when the denominator is zero. The second will pass. The output looks like this2.2

  Executing test test_division (step 1 of 2) using range 0-1 value 0

    Expecting function call to divide

    PASSED verify function call to divide
      expected .......... divide
      actual ............ divide

  FAILED test test_division (caught exception, signal 0xc0000094)
    caught exception in test test_division

  Executing test test_division (step 2 of 2) using range 0-1 value 1

    Expecting function call to divide

    PASSED verify function call to divide
      expected .......... divide
      actual ............ divide

  PASSED test test_division

As default, signals will cause the test to fail, but that can be changed. TestApe will pass the signal number to the function testape_exception_handler. The default implementation of this will simply return 1. Any non-zero value returned from here will cause the test to fail. If the return value is zero the test will pass, so by using any of the mocking functions, e.g. EXPECT(testape_exception_handler, 0) at the proper place, the same test can be made to pass. For example, if sample19 is modified like this

  void test_division(void) {
    EXPECT( divide );
    if (0 == PARAMETER_VALUE) { 
      EXPECT(testape_exception_handler, 0);
    }
    calculate(10,PARAMETER_VALUE,'/');
  }

  void testmain(void)  {
    PARAMETER_RANGE(0,1);
    EXECUTE(test_division);
  }
the output becomes2.2
  Executing test test_division (step 1 of 2) using range 0-1 value 0

    Expecting function call to divide
    Expecting function call to testape_exception_handler

    PASSED verify function call to divide
      expected .......... divide
      actual ............ divide

    PASSED verify function call to testape_exception_handler
      expected .......... testape_exception_handler
      actual ............ testape_exception_handler

  PASSED test test_division

  Executing test test_division (step 2 of 2) using range 0-1 value 1

    Expecting function call to divide

    PASSED verify function call to divide
      expected .......... divide
      actual ............ divide

  PASSED test test_division

testape

News

The latest headlines from Testape.com

TestApe Release 1171 available, Aug 20th 2014

It has been a long time since last official release and the list of bugfixes, features and supported platforms accumulating in the beta has grown substantially. I am happy to annouce that a new release is ready.

more

TestApe beta version available, Jul 21th 2014

New beta version is now available for download.

more

TestApe Release 880 available, Dec 3rd 2011

New is this release are support for floating point validations and function mocking. Also, MinGW has been added to the list of supported platforms.

more

Forum change, Mar 27th 2011

TestApe forum is now hosted on Proboards. Support questions can be posted here or send directly on email. Due to ...

more

TestApe beta release available, Sep 27th 2011

TestApe can now be used with MinGW GCC on windows. Also supported in this beta are floating point types in validations or when mocking functions

more

IPad update for WebTTY, May 15th 2011

A small fix for webtty scripts, to allow the usage from Apple IPads. Tab on textarea to bring up IPad keyboard - you may have to scroll webpage beneath keyboard, in order to actually see what you're typing.

TestApe Release 791 available, Apr 2nd 2010

This release contains a new flexible mocking system with default mocks automatically generated for unresolved functions. Installation packages are available for GCC/Linux, GCC/CygWin as well Visual Studio 2009/Windows XP or Vista.

more