Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014-2016, Regents of the University of California. |
| 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 | { |
| 31 | log::init("unit-tests.log4cxx"); |
| 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_CONFIG_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 |