summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-01-17 09:07:49 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-01-17 13:17:47 +0100
commitb122aae83e0fb29cbf36d536ace69c0bb39beb54 (patch)
tree24aabd0a74feb262264c5de68eb56352f57546f6 /sal
parenteb5f725c3eceec7221b058e1479147883eeb38e4 (diff)
Fix rtl_DoubleLocking::getValue_002 test
At least <https://ci.libreoffice.org//job/lo_tb_master_win/20394/> once failed with > Value in Thread #1 is 0 > Value in Thread #2 is 5 > C:/cygwin/home/tdf/lode/jenkins/workspace/lo_tb_master_win/sal/qa/rtl/doublelock/rtl_doublelocking.cxx:202:rtl_DoubleLocking::getValue::getValue_002 > assertion failed > - Expression: nValueOK != 0 > - getValue() failed, wrong value expected. and there is indeed no guarantee that either of the OGetThreads has already been through its while loop by the time the main thread calls terminate(). So make execution of the threads deterministic (and take out the sleeps that are no longer necessary, and use the now-deterministic expected values in the result checks). Change-Id: I61726906f646ffae7a21b1e08b1d973a4e51265b Reviewed-on: https://gerrit.libreoffice.org/66494 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/qa/rtl/doublelock/rtl_doublelocking.cxx37
1 files changed, 3 insertions, 34 deletions
diff --git a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
index cba75e99f728..af70e989d6b2 100644
--- a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
+++ b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
@@ -24,7 +24,6 @@
#include <sal/types.h>
#include <osl/thread.hxx>
-#include <osl/time.h>
#include <rtl/instance.hxx>
#include <rtl/ustring.hxx>
@@ -53,28 +52,6 @@ struct Gregorian : public rtl::StaticWithInit<OUString, Gregorian> {
};
}
-namespace ThreadHelper
-{
- // typedef enum {
- // QUIET=1,
- // VERBOSE
- // } eSleepVerboseMode;
-
- static void thread_sleep_tenth_sec(sal_Int32 _nTenthSec/*, eSleepVerboseMode nVerbose = VERBOSE*/)
- {
- // if (nVerbose == VERBOSE)
- // {
- // printf("wait %d tenth seconds. ", _nTenthSec );
- // fflush(stdout);
- // }
- osl::Thread::wait(std::chrono::milliseconds(_nTenthSec * 100));
- // if (nVerbose == VERBOSE)
- // {
- // printf("done\n");
- // }
- }
-}
-
/** Simple thread for testing Thread-create.
* Just add 1 of value 0, and after running, result is 1.
*/
@@ -104,7 +81,7 @@ protected:
*/
void SAL_CALL run() override
{
- while(schedule())
+ for (int i = 0; i != 5; ++i)
{
OUString aStr = Gregorian::get();
if (aStr == m_sConstStr)
@@ -117,7 +94,6 @@ protected:
osl::MutexGuard g(m_mutex);
m_nFails++;
}
- ThreadHelper::thread_sleep_tenth_sec(1);
}
}
@@ -171,11 +147,6 @@ namespace rtl_DoubleLocking
pThread->create();
p2Thread->create();
- ThreadHelper::thread_sleep_tenth_sec(5);
-
- pThread->terminate();
- p2Thread->terminate();
-
pThread->join();
p2Thread->join();
@@ -196,10 +167,8 @@ namespace rtl_DoubleLocking
delete pThread;
delete p2Thread;
- CPPUNIT_ASSERT_MESSAGE(
- "getValue() failed, wrong value expected.",
- nValueOK != 0
- );
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(5), nValueOK);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(5), nValueOK2);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nValueFails);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nValueFails2);
}