Alexander Afanasyev | 8495a4a | 2016-12-25 15:27:25 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | a9369b4 | 2017-01-11 11:58:00 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2017, Regents of the University of California. |
Alexander Afanasyev | 8495a4a | 2016-12-25 15:27:25 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | a9369b4 | 2017-01-11 11:58:00 -0800 | [diff] [blame] | 5 | * This file is part of ChronoShare, a decentralized file sharing application over NDN. |
Alexander Afanasyev | 8495a4a | 2016-12-25 15:27:25 -0800 | [diff] [blame] | 6 | * |
Alexander Afanasyev | a9369b4 | 2017-01-11 11:58:00 -0800 | [diff] [blame] | 7 | * 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 Afanasyev | 8495a4a | 2016-12-25 15:27:25 -0800 | [diff] [blame] | 10 | * |
Alexander Afanasyev | a9369b4 | 2017-01-11 11:58:00 -0800 | [diff] [blame] | 11 | * 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 Afanasyev | 8495a4a | 2016-12-25 15:27:25 -0800 | [diff] [blame] | 14 | * |
Alexander Afanasyev | a9369b4 | 2017-01-11 11:58:00 -0800 | [diff] [blame] | 15 | * 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 Afanasyev | 8495a4a | 2016-12-25 15:27:25 -0800 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include "core/chronoshare-config.hpp" |
| 22 | |
Alexander Afanasyev | a9369b4 | 2017-01-11 11:58:00 -0800 | [diff] [blame] | 23 | #include <boost/version.hpp> |
| 24 | #include <boost/filesystem.hpp> |
| 25 | |
Alexander Afanasyev | 8495a4a | 2016-12-25 15:27:25 -0800 | [diff] [blame] | 26 | #include "test-common.hpp" |
| 27 | |
| 28 | namespace ndn { |
| 29 | namespace chronoshare { |
| 30 | namespace tests { |
| 31 | |
| 32 | class GlobalConfigurationFixture : boost::noncopyable |
| 33 | { |
| 34 | public: |
| 35 | GlobalConfigurationFixture() |
| 36 | { |
Alexander Afanasyev | 8495a4a | 2016-12-25 15:27:25 -0800 | [diff] [blame] | 37 | 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 | |
| 69 | private: |
| 70 | std::string m_home; |
| 71 | std::string m_pib; |
| 72 | std::string m_tpm; |
| 73 | }; |
| 74 | |
| 75 | BOOST_GLOBAL_FIXTURE(GlobalConfigurationFixture) |
| 76 | #if (BOOST_VERSION >= 105900) |
| 77 | ; |
| 78 | #endif // BOOST_VERSION >= 105900 |
| 79 | |
| 80 | } // namespace tests |
| 81 | } // namespace chronoshare |
| 82 | } // namespace ndn |