From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/test/system/systest_settings.cc | 71 +++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/test/system/systest_settings.cc (limited to 'src/test/system/systest_settings.cc') diff --git a/src/test/system/systest_settings.cc b/src/test/system/systest_settings.cc new file mode 100644 index 000000000..787d763fe --- /dev/null +++ b/src/test/system/systest_settings.cc @@ -0,0 +1,71 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2011 New Dream Network + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include "systest_settings.h" + +#include +#include +#include + +pthread_mutex_t g_system_test_settings_lock = PTHREAD_MUTEX_INITIALIZER; + +SysTestSettings& SysTestSettings:: +inst() +{ + pthread_mutex_lock(&g_system_test_settings_lock); + if (!m_inst) + m_inst = new SysTestSettings(); + pthread_mutex_unlock(&g_system_test_settings_lock); + return *m_inst; +} + +bool SysTestSettings:: +use_threads() const +{ + #ifdef _WIN32 + // We can't use multiple processes on Windows for the time being. + // We'd need a mechanism for spawning those procecesses and also handle + // the inter-process communication. + return true; + #else + return m_use_threads; + #endif +} + +std::string SysTestSettings:: +get_log_name(const std::string &suffix) const +{ + if (m_log_file_base.empty()) + return ""; + std::ostringstream oss; + oss << m_log_file_base << "." << suffix; + return oss.str(); +} + +SysTestSettings* SysTestSettings:: +m_inst = NULL; + +SysTestSettings:: +SysTestSettings() +{ + m_use_threads = !!getenv("USE_THREADS"); + const char *lfb = getenv("LOG_FILE_BASE"); + if (lfb) + m_log_file_base.assign(lfb); +} + +SysTestSettings:: +~SysTestSettings() +{ +} -- cgit v1.2.3