Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Alexander Afanasyev | 08d1874 | 2018-03-15 16:31:28 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014-2018, Regents of the University of California. |
Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 4 | * |
| 5 | * This file is part of NDNS (Named Data Networking Domain Name Service). |
| 6 | * See AUTHORS.md for complete list of NDNS authors and contributors. |
| 7 | * |
| 8 | * NDNS is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #include "test-common.hpp" |
| 21 | |
| 22 | namespace ndn { |
| 23 | namespace ndns { |
| 24 | namespace tests { |
| 25 | |
| 26 | class GlobalConfigurationFixture : boost::noncopyable |
| 27 | { |
| 28 | public: |
| 29 | GlobalConfigurationFixture() |
| 30 | { |
Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 31 | if (getenv("HOME") != nullptr) { |
| 32 | m_home = getenv("HOME"); |
| 33 | } |
| 34 | if (getenv("NDN_CLIENT_PIB") != nullptr) { |
| 35 | m_pib = getenv("NDN_CLIENT_PIB"); |
| 36 | } |
| 37 | if (getenv("NDN_CLIENT_TPM") != nullptr) { |
| 38 | m_tpm = getenv("NDN_CLIENT_TPM"); |
| 39 | } |
| 40 | |
| 41 | boost::filesystem::path dir(TEST_CONFIG_PATH); |
| 42 | dir /= "test-home"; |
| 43 | setenv("HOME", dir.generic_string().c_str(), 1); |
| 44 | |
| 45 | setenv("NDN_CLIENT_PIB", "pib-sqlite3", 1); |
| 46 | setenv("NDN_CLIENT_TPM", "tpm-file", 1); |
| 47 | boost::filesystem::create_directories(dir); |
| 48 | } |
| 49 | |
| 50 | ~GlobalConfigurationFixture() |
| 51 | { |
| 52 | if (!m_home.empty()) { |
| 53 | setenv("HOME", m_home.c_str(), 1); |
| 54 | } |
| 55 | if (!m_pib.empty()) { |
| 56 | setenv("NDN_CLIENT_PIB", m_home.c_str(), 1); |
| 57 | } |
| 58 | if (!m_tpm.empty()) { |
| 59 | setenv("NDN_CLIENT_TPM", m_home.c_str(), 1); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | private: |
| 64 | std::string m_home; |
| 65 | std::string m_pib; |
| 66 | std::string m_tpm; |
| 67 | }; |
| 68 | |
| 69 | BOOST_GLOBAL_FIXTURE(GlobalConfigurationFixture) |
| 70 | #if (BOOST_VERSION >= 105900) |
| 71 | ; |
| 72 | #endif // BOOST_VERSION >= 105900 |
| 73 | |
| 74 | } // namespace tests |
| 75 | } // namespace ndns |
| 76 | } // namespace ndn |