mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-24 09:03:48 +00:00
Prevent tests from never ending due to threading bug
This commit is contained in:
parent
9269a4e13b
commit
be4f3e7f1b
2 changed files with 72 additions and 2 deletions
33
.github/workflows/cmake.yml
vendored
33
.github/workflows/cmake.yml
vendored
|
|
@ -66,9 +66,42 @@ jobs:
|
|||
fi
|
||||
shell: bash
|
||||
|
||||
- name: Upload Test Report
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always() # always run even if the previous step fails
|
||||
with:
|
||||
name: junit-test-results
|
||||
path: '${{github.workspace}}/My Projects/Torque3D/game/test_detail.xml'
|
||||
retention-days: 1
|
||||
|
||||
- name: Publish Test Report
|
||||
uses: mikepenz/action-junit-report@v3
|
||||
if: success() || failure() # always run even if the previous step fails
|
||||
with:
|
||||
report_paths: '${{github.workspace}}/My Projects/Torque3D/game/test_detail.xml'
|
||||
|
||||
---
|
||||
name: Report Test Results
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [CMake]
|
||||
types: [completed]
|
||||
|
||||
permissions:
|
||||
checks: write
|
||||
|
||||
jobs:
|
||||
checks:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download Test Report
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
name: junit-test-results
|
||||
workflow: ${{ github.event.workflow.id }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
- name: Publish Test Report
|
||||
uses: mikepenz/action-junit-report@v3
|
||||
with:
|
||||
commit: ${{github.event.workflow_run.head_sha}}
|
||||
report_paths: '${{github.workspace}}/My Projects/Torque3D/game/test_detail.xml'
|
||||
|
|
|
|||
|
|
@ -91,6 +91,18 @@ 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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -107,7 +119,6 @@ public:
|
|||
{
|
||||
ValueRef value;
|
||||
while(!mDeque.tryPopFront(value));
|
||||
|
||||
EXPECT_EQ(i, value->mIndex);
|
||||
EXPECT_EQ(value->mTick, mValues[i]);
|
||||
}
|
||||
|
|
@ -162,6 +173,8 @@ TEST_FIX(ThreadSafeDeque, PopBack)
|
|||
}
|
||||
|
||||
// Test deque in a concurrent setting.
|
||||
|
||||
// Test many items in a row
|
||||
TEST_FIX(ThreadSafeDeque, Concurrent1)
|
||||
{
|
||||
const U32 NumValues = 100;
|
||||
|
|
@ -183,4 +196,28 @@ TEST_FIX(ThreadSafeDeque, Concurrent1)
|
|||
mValues.clear();
|
||||
};
|
||||
|
||||
#endif
|
||||
// Test a few items many times to catch any race-condition in start-up
|
||||
TEST_FIX(ThreadSafeDeque, Concurrent2)
|
||||
{
|
||||
for (int i = 0; i < 10000; ++i)
|
||||
{
|
||||
Deque mDeque;
|
||||
Vector<U32> mValues;
|
||||
|
||||
mValues.setSize(5);
|
||||
|
||||
ProducerThread pThread(mValues, mDeque);
|
||||
ConsumerThread cThread(mValues, mDeque);
|
||||
|
||||
cThread.start();
|
||||
pThread.start();
|
||||
|
||||
pThread.join();
|
||||
cThread.join();
|
||||
|
||||
mValues.clear();
|
||||
if (::testing::Test::HasFailure()) break;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue