mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +00:00
gtest tweaks
refactor concurency test conu=sumer thread runner to generate timeouts at excessive attempts (32ms*runlength) threadsafefreelist reporting augs scripttest object name conflict resolutions skip testing platform window creation if no monitor was found
This commit is contained in:
parent
cb766f2878
commit
dfd3e65ba4
5 changed files with 32 additions and 24 deletions
|
|
@ -91,18 +91,6 @@ public:
|
|||
ValueRef val = new Value(i, tick);
|
||||
mDeque.pushBack(val);
|
||||
}
|
||||
|
||||
// WORKAROUND: due to a bug in the Deque, we lose an item, and thus the test will loop forever. We currently
|
||||
// don't have a timeout solution, so instead push som extra elements just to make sure Consumer
|
||||
// doesn't get stuck.
|
||||
for(U32 i = mValues.size(); i < mValues.size() + 5; i++)
|
||||
{
|
||||
U32 tick = Platform::getRealMilliseconds();
|
||||
|
||||
ValueRef val = new Value(i, tick);
|
||||
|
||||
mDeque.pushBack(val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -115,10 +103,27 @@ public:
|
|||
|
||||
virtual void run(void*)
|
||||
{
|
||||
for(U32 i = 0; i < mValues.size(); i++)
|
||||
S32 timeOut = mValues.size() * 32;
|
||||
U32 endTime = Platform::getRealMilliseconds() + timeOut;
|
||||
|
||||
for (U32 i = 0; i < mValues.size(); i++)
|
||||
{
|
||||
ValueRef value;
|
||||
while(!mDeque.tryPopFront(value));
|
||||
bool timedOut = false;
|
||||
while (!mDeque.tryPopFront(value))
|
||||
{
|
||||
if (timeOut && Platform::getRealMilliseconds() >= endTime)
|
||||
{
|
||||
timedOut = true;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
ASSERT_FALSE(timedOut)
|
||||
<< "consumer thread timed out!";
|
||||
|
||||
if (timedOut) return;
|
||||
|
||||
EXPECT_EQ(i, value->mIndex);
|
||||
EXPECT_EQ(value->mTick, mValues[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ TEST(ThreadSafePriorityQueue, Serial)
|
|||
const U32 len = 11;
|
||||
|
||||
U32 indices[len] = { 2, 7, 4, 6, 1, 5, 3, 8, 6, 9, 0};
|
||||
F32 priorities[len] = {0.2, 0.7, 0.4, 0.6, 0.1, 0.5, 0.3, 0.8, 0.6, 0.9, 0};
|
||||
F32 priorities[len] = {0.2f, 0.7f, 0.4f, 0.6f, 0.1f, 0.5f, 0.3f, 0.8f, 0.6f, 0.9f, 0.0f};
|
||||
|
||||
ThreadSafePriorityQueue<U32, F32, true> minQueue;
|
||||
ThreadSafePriorityQueue<U32, F32, false> maxQueue;
|
||||
|
|
@ -92,7 +92,7 @@ TEST(ThreadSafePriorityQueue, Concurrent)
|
|||
virtual void run(void*)
|
||||
{
|
||||
U32 indices[LEN] = { 2, 7, 4, 6, 1, 5, 3, 8, 6, 9, 0};
|
||||
F32 priorities[LEN] = {0.2, 0.7, 0.4, 0.6, 0.1, 0.5, 0.3, 0.8, 0.6, 0.9, 0};
|
||||
F32 priorities[LEN] = {0.2f, 0.7f, 0.4f, 0.6f, 0.1f, 0.5f, 0.3f, 0.8f, 0.6f, 0.9f, 0.0f};
|
||||
|
||||
for(U32 i = 0; i < LEN; i++)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue