Need timeout == pass

LegacyForumLegacyForum Posts: 1,669 ✭✭
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

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    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.

Sign In or Register to comment.