[Libreoffice-commits] core.git: sal/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Jan 17 12:18:11 UTC 2019
sal/qa/rtl/doublelock/rtl_doublelocking.cxx | 37 ++--------------------------
1 file changed, 3 insertions(+), 34 deletions(-)
New commits:
commit b122aae83e0fb29cbf36d536ace69c0bb39beb54
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Jan 17 09:07:49 2019 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Jan 17 13:17:47 2019 +0100
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 at redhat.com>
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);
}
More information about the Libreoffice-commits
mailing list