Timeout is normal

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in C/C++test
I have a piece of code that should wait on a semaphore for forever if everything is working OK.

/*Setup threads and wait*/
sem_wait(&semaphore); //Wait for forever unless program termination is required.
/*Case for exit conditions*/

and should only fail if one of the child threads releases the semaphore, meaning some unrecoverable error has occurred and the function must terminate.
C++Test times out after 5 seconds, and that is just fine, but how to I register this a a normal condition?

Comments

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Hello galto

    > CI have a piece of code that should wait on a semaphore for forever if everything is working OK.

    > /*Setup threads and wait*/
    > sem_wait(&semaphore); //Wait for forever unless program termination is required.
    > /*Case for exit conditions*/

    > and should only fail if one of the child threads releases the semaphore, meaning some unrecoverable error has occurred and >the function must terminate.
    >C++Test times out after 5 seconds, and that is just fine, but how to I register this a a normal condition?


    Without a small example it is hard to give you concrete solution. However I would suggest creating a user defined stub that has a condition statement that will call either CppTest_Assert, or CppTest_Break(), whenever semi_wait function is called.
Sign In or Register to comment.