Test that a join actually delays the parent

This commit is contained in:
Andrew Johnson
2019-07-02 18:17:47 -05:00
parent e5782ae716
commit b4ee452c4d

View File

@@ -102,6 +102,11 @@ void dowait(void *arg)
epicsThreadSleep(0.1);
}
void dodelay(void *arg)
{
epicsThreadSleep(2.0);
}
void joinTests(void *arg)
{
struct joinStuff *stuff = (struct joinStuff *) arg;
@@ -118,6 +123,20 @@ void joinTests(void *arg)
stuff->trigger->signal();
epicsThreadMustJoin(tid);
// Parent gets delayed until task finishes
epicsTime start, end;
start = epicsTime::getCurrent();
tid = epicsThreadCreateOpt("delay",
&dodelay, 0, stuff->opts);
epicsThreadMustJoin(tid);
end = epicsTime::getCurrent();
double duration = end - start;
#ifndef EPICS_THREAD_CAN_JOIN
testTodoBegin("Thread join doesn't work");
#endif
testOk(duration > 1.0, "Join delayed parent (%g seconds)", duration);
testTodoEnd();
// This is a no-op
epicsThreadId self = epicsThreadGetIdSelf();
epicsThreadMustJoin(self);
@@ -192,7 +211,7 @@ static void testOkToBlock()
MAIN(epicsThreadTest)
{
testPlan(12);
testPlan(13);
unsigned int ncpus = epicsThreadGetCPUs();
testDiag("System has %u CPUs", ncpus);