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