Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Need timeout == pass

LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in C/C++test
Infinite loop timeout
I want C++Test to report a success if timeout is triggered.
I have an infinitely looping task. I expect a timeout. I don't want the timeout reported as an error.

Here is the basic setup of the function (which I am not free to change) ...

void MyInfiniteTask(void)
{
while (TRUE) { do_some_junk_repeatedly }
}


Thanks

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Hi David,

    What you're looking for is the use of the built-in C++test testing macros.
    If you open up your C++Test userguide you should see a section at the very bottom that's labeled "C++test API Documentation". If you click on it you should see a section titled "Test Suite/Test Case Registration" where you can read about the various macros that you can use with your test cases. I'm assuming you've already generated unit tests and test suites for your test cases. By default you should see CPPTEST_TEST(testCaseName) for each of your test cases. What you can do is change that to CPPTEST_TEST_ERROR(testCaseName, CPPTEST_TIMEOUT), since you said you were expecting a timeout from the test case. This should make it so that C++Test expects a timeout from this test case and it should not be marked as a failure anymore. You can find more information about this particular macro in the section of the userguide I mentioned earlier.

    Let me know if you have any other issues.

  • chris
    chris Posts: 9

    @LegacyForum I tried this but getting an error about mismatch with the CPPTEST_TIMEOUT. Is there something else that I need to change in the actual test?

  • chris
    chris Posts: 9

    @LegacyForum sorry ignore my last post, it worked fine. it was another test that was failing.