Kaydet (Commit) d1401579 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Fix race in test code

seen it fail at <https://ci.libreoffice.org/job/lo_tb_master_win/19591/>

> Value in Thread #1 is 0
> Value in Thread #2 is 0
> C:/cygwin/home/tdf/lode/jenkins/workspace/lo_tb_master_win/sal/qa/rtl/doublelock/rtl_doublelocking.cxx:199:rtl_DoubleLocking::getValue::getValue_002
> assertion failed
> - Expression: nValueOK != 0
> - getValue() failed, wrong value expected.
>
> rtl_DoubleLocking::getValue::getValue_002 finished in: 1267ms

Change-Id: I6ac85a9ff4da8c046412add40c9447ee53ef8d7e
Reviewed-on: https://gerrit.libreoffice.org/63320
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 607ab542
......@@ -80,6 +80,7 @@ namespace ThreadHelper
*/
class OGetThread : public osl::Thread
{
osl::Mutex m_mutex;
sal_Int32 m_nOK;
sal_Int32 m_nFails;
......@@ -92,8 +93,8 @@ public:
m_sConstStr = CONST_TEST_STRING;
}
sal_Int32 getOK() { return m_nOK; }
sal_Int32 getFails() {return m_nFails;}
sal_Int32 getOK() { osl::MutexGuard g(m_mutex); return m_nOK; }
sal_Int32 getFails() {osl::MutexGuard g(m_mutex); return m_nFails;}
protected:
......@@ -108,10 +109,12 @@ protected:
OUString aStr = Gregorian::get();
if (aStr == m_sConstStr)
{
osl::MutexGuard g(m_mutex);
m_nOK++;
}
else
{
osl::MutexGuard g(m_mutex);
m_nFails++;
}
ThreadHelper::thread_sleep_tenth_sec(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment