From b4ee452c4d39424f9b5a8910d85776eb979e4211 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 2 Jul 2019 18:17:47 -0500 Subject: [PATCH] Test that a join actually delays the parent --- modules/libcom/test/epicsThreadTest.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/libcom/test/epicsThreadTest.cpp b/modules/libcom/test/epicsThreadTest.cpp index d07552d15..4796438a1 100644 --- a/modules/libcom/test/epicsThreadTest.cpp +++ b/modules/libcom/test/epicsThreadTest.cpp @@ -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);