OpenAWE-Project / OpenAWE

A reimplementation of Remedy Entertainments Alan Wake Engine, in later iterations known as the Northlight Engine
GNU General Public License v3.0
163 stars 13 forks source link

Test ThreadPool.multipleJobs fails sometimes #46

Open Jackkal opened 3 months ago

Jackkal commented 3 months ago
$ctest -R ThreadPool.multipleJobs --repeat until-fail:100
...
    Start 84: ThreadPool.multipleJobs
    Test #84: ThreadPool.multipleJobs ..........   Passed    0.01 sec
    Start 84: ThreadPool.multipleJobs
    Test #84: ThreadPool.multipleJobs ..........   Passed    0.01 sec
    Start 84: ThreadPool.multipleJobs
    Test #84: ThreadPool.multipleJobs ..........   Passed    0.01 sec
    Start 84: ThreadPool.multipleJobs
    Test #84: ThreadPool.multipleJobs ..........***Failed    0.01 sec

$ctest -R ThreadPool.multipleJobs --repeat until-fail:100 --verbose
... 
84: Test command: /home/jackkal/code/OpenAWE/build/awe_test "--gtest_filter=ThreadPool.multipleJobs"
84: Test timeout computed to be: 1500
84: Running main() from /home/jackkal/code/googletest/googletest/src/gtest_main.cc
84: Note: Google Test filter = ThreadPool.multipleJobs
84: [==========] Running 1 test from 1 test suite.
84: [----------] Global test environment set-up.
84: [----------] 1 test from ThreadPool
84: [ RUN      ] ThreadPool.multipleJobs
84: /home/jackkal/code/OpenAWE/test/test_common_threadpool.cpp:40: Failure
84: Expected equality of these values:
84:   test2.load()
84:     Which is: 119
84:   120

I did not do a root cause analysis yet, but this is possibly related to the check !Threads.empty() which checks if the queue is empty, but this does not necessarily mean that the last task has finished.

Nostritius commented 3 months ago

Thanks for the hint, this is indeed a problem the empty() method. I will look into it, when I have some time.