]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/system/systest_settings.cc
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / test / system / systest_settings.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2011 New Dream Network
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #include "systest_settings.h"
16
17 #include <pthread.h>
18 #include <sstream>
19 #include <stdlib.h>
20
21 pthread_mutex_t g_system_test_settings_lock = PTHREAD_MUTEX_INITIALIZER;
22
23 SysTestSettings& SysTestSettings::
24 inst()
25 {
26 pthread_mutex_lock(&g_system_test_settings_lock);
27 if (!m_inst)
28 m_inst = new SysTestSettings();
29 pthread_mutex_unlock(&g_system_test_settings_lock);
30 return *m_inst;
31 }
32
33 bool SysTestSettings::
34 use_threads() const
35 {
36 return m_use_threads;
37 }
38
39 std::string SysTestSettings::
40 get_log_name(const std::string &suffix) const
41 {
42 if (m_log_file_base.empty())
43 return "";
44 std::ostringstream oss;
45 oss << m_log_file_base << "." << suffix;
46 return oss.str();
47 }
48
49 SysTestSettings* SysTestSettings::
50 m_inst = NULL;
51
52 SysTestSettings::
53 SysTestSettings()
54 {
55 m_use_threads = !!getenv("USE_THREADS");
56 const char *lfb = getenv("LOG_FILE_BASE");
57 if (lfb)
58 m_log_file_base.assign(lfb);
59 }
60
61 SysTestSettings::
62 ~SysTestSettings()
63 {
64 }