fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-trx/+/43103?usp=email )
Change subject: tests: speed up InterthreadTest by shrinking the fuzz sleep ......................................................................
tests: speed up InterthreadTest by shrinking the fuzz sleep
qWriter()/mapWriter() each had a 50% chance per iteration (20 iterations) of sleep(1), making the test take up to ~13s just to exercise thread interleaving. The delay only needs to be long enough to encourage preemption, not a full second.
Change-Id: Id6bc453f9217ae392dcd3288dfa6784c533f8eb6 --- M tests/CommonLibs/InterthreadTest.cpp 1 file changed, 3 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/03/43103/1
diff --git a/tests/CommonLibs/InterthreadTest.cpp b/tests/CommonLibs/InterthreadTest.cpp index a00980f..523a5bd 100644 --- a/tests/CommonLibs/InterthreadTest.cpp +++ b/tests/CommonLibs/InterthreadTest.cpp @@ -30,6 +30,7 @@ #include "Interthread.h" #include <iostream> #include <mutex> +#include <unistd.h>
std::mutex dbg_cout;
@@ -52,7 +53,7 @@ CERR("queue write " << *p); gQ.write(p); q_last_write_val = i; - if (random()%2) sleep(1); + if (random()%2) usleep(1000); } p = new int; *p = -1; @@ -88,7 +89,7 @@ CERR("map write " << *p); gMap.write(i,p); m_last_write_val = i; - if (random()%2) sleep(1); + if (random()%2) usleep(1000); } return NULL; }