Skip to content

Commit

Permalink
Changes following review
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Jan 7, 2025
1 parent 48b7e69 commit 4b4d49b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
3 changes: 1 addition & 2 deletions common/workunit/wujobq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1269,9 +1269,8 @@ class CJobQueue: public CJobQueueBase, implements IJobQueue
Owned<IJobQueueItem> item;
if (prioritytransitiondelay)
{
unsigned timeout = prioritytransitiondelay;
bool usePrevPrio = true;
item.setown(dodequeue(minPrio, timeout, usePrevPrio, nullptr));
item.setown(dodequeue(minPrio, prioritytransitiondelay, usePrevPrio, nullptr));
}
if (!item)
item.setown(dodequeue(minPrio, timeout-prioritytransitiondelay, false, nullptr));
Expand Down
38 changes: 29 additions & 9 deletions testing/unittests/dalitests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3269,14 +3269,14 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DaliSysInfoLoggerTester, "DaliSysInfoLogg


static constexpr bool traceJobQueue = false;
static unsigned jobQueueStartTick;
static unsigned jobQueueStartTick = 0;
//The following allows the tests to be slowed down to make it easier to debug problems
static constexpr unsigned tickScaling = 1;
static unsigned getJobQueueTick()
{
return (msTick() - jobQueueStartTick) / tickScaling;
}
static void JobQueueSleep(unsigned ms)
static void jobQueueSleep(unsigned ms)
{
MilliSleep(ms * tickScaling);
}
Expand Down Expand Up @@ -3333,7 +3333,7 @@ class JobQueueTester : public CppUnit::TestFixture
log.append(",");
log.append(name).append("@").append(getJobQueueTick());
unsigned delay = item->getPort();
JobQueueSleep(delay);
jobQueueSleep(delay);
processedSem.signal();
return true;
}
Expand Down Expand Up @@ -3494,7 +3494,7 @@ class JobQueueTester : public CppUnit::TestFixture
jobQueueStartTick = msTick();
for (auto & job : jobs)
{
JobQueueSleep(job.delayMs);
jobQueueSleep(job.delayMs);
if (traceJobQueue)
DBGLOG("Add (%s, %d, %d) @%u", job.name, job.delayMs, job.processingMs, getJobQueueTick());
Owned<IJobQueueItem> item = createJobQueueItem(job.name);
Expand Down Expand Up @@ -3527,8 +3527,28 @@ class JobQueueTester : public CppUnit::TestFixture
{
JobProcessor & cur = jobProcessors.item(i3);
DBGLOG(" Result: '%s' '%s'", cur.queryOutput(), cur.queryLog());
// if (i3 < expectedResults.size())
// CPPUNIT_ASSERT_EQUAL(std::string(expectedResults.begin()[i3]), std::string(cur.queryOutput()));

//If expected results are provided, check that the result matches one of them (it is undefined which
//processor will match which result)
if (expectedResults.size())
{
bool matched = false;
StringBuffer expectedText;
for (auto & expected : expectedResults)
{
if (streq(expected, cur.queryOutput()))
{
matched = true;
break;
}
expectedText.append(", ").append(expected);
}
if (!matched)
{
DBGLOG("Result does not match any expected: %s", expectedText.str()+2);
CPPUNIT_ASSERT_MESSAGE("Result does not match any of the expected results", false);
}
}
}
}

Expand Down Expand Up @@ -3630,9 +3650,9 @@ class JobQueueTester : public CppUnit::TestFixture
void testDouble()
{
runTestCaseX2("2 wu, 2 standard", twoWuTest, { StandardProcessor, StandardProcessor }, { "abcd", "ABCD" });
runTestCaseX2("lo hi wu, 2 standard", lowHighTest, { StandardProcessor, StandardProcessor }, { "aBDc" "ACbd" });
runTestCaseX2("lo hi2 wu, 2 standard", lowHigh2Test, { StandardProcessor, StandardProcessor }, { "a"});
runTestCaseX2("lo hi2 wu, 2 thor", lowHigh2Test, { ThorProcessor, ThorProcessor }, {});
runTestCaseX2("lo hi wu, 2 standard", lowHighTest, { StandardProcessor, StandardProcessor }, { "abcd", "ABCD" });
runTestCaseX2("lo hi2 wu, 2 standard", lowHigh2Test, { StandardProcessor, StandardProcessor }, { "aBDc", "ACbd" });
runTestCaseX2("lo hi2 wu, 2 thor", lowHigh2Test, { ThorProcessor, ThorProcessor }, { "aBDc", "ACbd" });
runTestCaseX2("lo hi2 wu, 2 newthor", lowHigh2Test, { NewThorProcessor, NewThorProcessor }, {});

runTestCaseX2("lo hi3 wu, 2 thor", lowHigh3Test, { ThorProcessor, ThorProcessor }, {});
Expand Down

0 comments on commit 4b4d49b

Please sign in to comment.