[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4-0' - test/helpers.hpp

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 10 14:26:38 UTC 2019


 test/helpers.hpp |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit a5035a0f7734478a22b383ecab6cb499f53a824f
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Thu Sep 26 16:59:40 2019 -0400
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Oct 10 16:26:21 2019 +0200

    wsd: test: protect std::cerr from multiple threads
    
    Some tests fire up multiple threads and access
    the log, which uses std::cerr, concurrently.
    This can corrupt the cerr string buffer and
    cause random failures.
    
    Change-Id: I04c68a27a8fff668ab8e7c62ff2d52d85c3a26d5
    Reviewed-on: https://gerrit.libreoffice.org/80320
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 7414b27d4..5b526b01b 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -40,10 +40,12 @@
 #endif
 
 // Logging in unit-tests go to cerr, for now at least.
-#define TST_LOG_NAME_BEGIN(NAME, X) do { std::cerr << NAME << "(@" << helpers::timeSinceTestStartMs() << "ms) " << X; } while (false)
+static std::mutex MutexLog;
+#define TST_LOG_MUTEX std::unique_lock<std::mutex> lock(MutexLog)
+#define TST_LOG_NAME_BEGIN(NAME, X) do { TST_LOG_MUTEX; std::cerr << NAME << "(@" << helpers::timeSinceTestStartMs() << "ms) " << X; } while (false)
 #define TST_LOG_BEGIN(X) TST_LOG_NAME_BEGIN(testname, X)
-#define TST_LOG_APPEND(X) do { std::cerr << X; } while (false)
-#define TST_LOG_END do { std::cerr << "| " << __FILE__ << ':' << __LINE__ << std::endl; } while (false)
+#define TST_LOG_APPEND(X) do { TST_LOG_MUTEX; std::cerr << X; } while (false)
+#define TST_LOG_END do { TST_LOG_MUTEX; std::cerr << "| " << __FILE__ << ':' << __LINE__ << std::endl; } while (false)
 #define TST_LOG_NAME(NAME, X) TST_LOG_NAME_BEGIN(NAME, X); TST_LOG_END
 #define TST_LOG(X) TST_LOG_NAME(testname, X)
 


More information about the Libreoffice-commits mailing list