tests: remove support for unit-tests.conf
Logging can be configured, as usual, via the
NDN_LOG environment variable.
Change-Id: I488d4c85961cb013b9e3421d049a9baa8ef45357
diff --git a/.gitignore b/.gitignore
index 437db59..608c272 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,5 +26,4 @@
*.py[cod]
# Other
-/unit-tests.conf
/VERSION
diff --git a/README-dev.md b/README-dev.md
index 69b3a35..18f5af8 100644
--- a/README-dev.md
+++ b/README-dev.md
@@ -1,16 +1,13 @@
-Notes for NFD developers
-========================
+# Notes for NFD developers
If you are new to the NDN software community, please read the
[Contributor's Guide](https://github.com/named-data/NFD/blob/master/CONTRIBUTING.md).
-Code style
-----------
+## Code style
NFD code is subject to [NFD code style](https://redmine.named-data.net/projects/nfd/wiki/CodeStyle).
-Licensing
----------
+## Licensing
Contributions to NFD must be licensed under the GPL 3.0 or compatible license. If you
are choosing GPL 3.0, please use the following license boilerplate in all `.hpp` and
@@ -40,8 +37,13 @@
If you are affiliated to an NSF-supported NDN project institution, please use the [NDN Team License
Boilerplate](https://redmine.named-data.net/projects/nfd/wiki/NDN_Team_License_Boilerplate_(NFD)).
-Running unit tests
-------------------
+## Logging
+
+Fine-grained per-module logging can be configured via the `NDN_LOG` environment variable.
+This is especially useful when running unit tests or tools such as `nfdc` that do not
+have a configuration file. See `ndn-log(7)` manual page for syntax and examples.
+
+## Unit tests
To run unit tests, NFD needs to be configured and build with unit test support:
diff --git a/tests/global-configuration.cpp b/tests/global-configuration.cpp
index 25d5061..9a56347 100644
--- a/tests/global-configuration.cpp
+++ b/tests/global-configuration.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -23,10 +23,9 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "core/config-file.hpp"
-#include "core/log-config-section.hpp"
+#include "core/common.hpp"
-#include "boost-test.hpp"
+#include "tests/boost-test.hpp"
#include <boost/filesystem.hpp>
#include <fstream>
@@ -44,26 +43,22 @@
if (envHome)
m_home = envHome;
- const std::string filename = "unit-tests.conf";
- if (boost::filesystem::exists(filename)) {
- ConfigFile config;
- log::setConfigFile(config);
- config.parse(filename, false);
- }
+ auto testHome = boost::filesystem::path(UNIT_TEST_CONFIG_PATH) / "test-home";
+ if (::setenv("HOME", testHome.c_str(), 1) != 0)
+ NDN_THROW(std::runtime_error("setenv() failed"));
- boost::filesystem::path dir{UNIT_TEST_CONFIG_PATH};
- dir /= "test-home";
- ::setenv("HOME", dir.c_str(), 1);
+ boost::filesystem::create_directories(testHome);
- boost::filesystem::create_directories(dir);
- std::ofstream clientConf((dir / ".ndn" / "client.conf").c_str());
+ std::ofstream clientConf((testHome / ".ndn" / "client.conf").c_str());
clientConf << "pib=pib-sqlite3" << std::endl
<< "tpm=tpm-file" << std::endl;
}
- ~GlobalConfiguration()
+ ~GlobalConfiguration() noexcept
{
- if (!m_home.empty())
+ if (m_home.empty())
+ ::unsetenv("HOME");
+ else
::setenv("HOME", m_home.data(), 1);
}
diff --git a/unit-tests.conf.sample b/unit-tests.conf.sample
deleted file mode 100644
index 3ebb9f7..0000000
--- a/unit-tests.conf.sample
+++ /dev/null
@@ -1,32 +0,0 @@
-log
-{
- ; default_level specifies the logging level for modules
- ; that are not explicitly named. All debugging levels
- ; listed above the selected value are enabled.
- ;
- ; Valid values:
- ;
- ; NONE ; no messages
- ; ERROR ; error messages
- ; WARN ; warning messages
- ; INFO ; informational messages (default)
- ; DEBUG ; debugging messages
- ; TRACE ; trace messages (most verbose)
- ; ALL ; all messages
-
- ; default_level INFO
-
- ; You may override default_level by assigning a logging level
- ; to the desired module name. Module names can be found in two ways:
- ;
- ; Run:
- ; nfd --modules
- ;
- ; Or look for NFD_LOG_INIT(<module name>) statements in source files.
- ; Note that the "nfd." prefix can be omitted.
- ;
- ; Example module-level settings:
- ;
- ; FibManager DEBUG
- ; Forwarder INFO
-}