blob: 659edf9c7ec73e45f37c41bd20e40ee0718652f9 [file] [log] [blame]
Alexander Afanasyev8495a4a2016-12-25 15:27:25 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyeva9369b42017-01-11 11:58:00 -08003 * Copyright (c) 2013-2017, Regents of the University of California.
Alexander Afanasyev8495a4a2016-12-25 15:27:25 -08004 *
Alexander Afanasyeva9369b42017-01-11 11:58:00 -08005 * This file is part of ChronoShare, a decentralized file sharing application over NDN.
Alexander Afanasyev8495a4a2016-12-25 15:27:25 -08006 *
Alexander Afanasyeva9369b42017-01-11 11:58:00 -08007 * ChronoShare is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
Alexander Afanasyev8495a4a2016-12-25 15:27:25 -080010 *
Alexander Afanasyeva9369b42017-01-11 11:58:00 -080011 * ChronoShare is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyev8495a4a2016-12-25 15:27:25 -080014 *
Alexander Afanasyeva9369b42017-01-11 11:58:00 -080015 * You should have received copies of the GNU General Public License along with
16 * ChronoShare, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ChronoShare authors and contributors.
Alexander Afanasyev8495a4a2016-12-25 15:27:25 -080019 */
20
21#include "core/chronoshare-config.hpp"
22
Alexander Afanasyeva9369b42017-01-11 11:58:00 -080023#include <boost/version.hpp>
24#include <boost/filesystem.hpp>
25
Alexander Afanasyev8495a4a2016-12-25 15:27:25 -080026#include "test-common.hpp"
27
28namespace ndn {
29namespace chronoshare {
30namespace tests {
31
32class GlobalConfigurationFixture : boost::noncopyable
33{
34public:
35 GlobalConfigurationFixture()
36 {
Alexander Afanasyev8495a4a2016-12-25 15:27:25 -080037 if (getenv("HOME") != nullptr) {
38 m_home = getenv("HOME");
39 }
40 if (getenv("NDN_CLIENT_PIB") != nullptr) {
41 m_pib = getenv("NDN_CLIENT_PIB");
42 }
43 if (getenv("NDN_CLIENT_TPM") != nullptr) {
44 m_tpm = getenv("NDN_CLIENT_TPM");
45 }
46
47 boost::filesystem::path dir(UNIT_TEST_CONFIG_PATH);
48 dir /= "test-home";
49 setenv("HOME", dir.generic_string().c_str(), 1);
50
51 setenv("NDN_CLIENT_PIB", "pib-sqlite3", 1);
52 setenv("NDN_CLIENT_TPM", "tpm-file", 1);
53 boost::filesystem::create_directories(dir);
54 }
55
56 ~GlobalConfigurationFixture()
57 {
58 if (!m_home.empty()) {
59 setenv("HOME", m_home.c_str(), 1);
60 }
61 if (!m_pib.empty()) {
62 setenv("NDN_CLIENT_PIB", m_home.c_str(), 1);
63 }
64 if (!m_tpm.empty()) {
65 setenv("NDN_CLIENT_TPM", m_home.c_str(), 1);
66 }
67 }
68
69private:
70 std::string m_home;
71 std::string m_pib;
72 std::string m_tpm;
73};
74
75BOOST_GLOBAL_FIXTURE(GlobalConfigurationFixture)
76#if (BOOST_VERSION >= 105900)
77;
78#endif // BOOST_VERSION >= 105900
79
80} // namespace tests
81} // namespace chronoshare
82} // namespace ndn