tests+mgmt: Import common unit test code NFD
This commit introduces BaseFixture, UnitTestTimeFixture,
IdentityManagementFixture, and IdentityManagementTimeFixture.
In addition to that, the command line of the unit test binary (for boost
libraries before 1.62) are extended to support multi-format output.
This commit also addresses a strange bug in the management tool that was
causing spurious segmentation faults during unit tests.
Change-Id: Ib34b4007773f0b35d9ed919eebbdc4e0d413fa1e
diff --git a/tests/unit/mgmt/management-tool.cpp b/tests/unit/mgmt/management-tool.cpp
index 459e9eb..b61ac86 100644
--- a/tests/unit/mgmt/management-tool.cpp
+++ b/tests/unit/mgmt/management-tool.cpp
@@ -17,29 +17,21 @@
* NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "../../src/mgmt/management-tool.hpp"
-
-#include "../../boost-test.hpp"
-#include <boost/test/output_test_stream.hpp>
-using boost::test_tools::output_test_stream;
+#include "mgmt/management-tool.hpp"
#include "ndns-enum.hpp"
#include "ndns-label.hpp"
#include "ndns-tlv.hpp"
-#include <vector>
-#include <iostream>
-#include <fstream>
-#include <string>
-
-#include <boost/filesystem.hpp>
#include <boost/algorithm/string/replace.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
-#include <ndn-cxx/security/validator.hpp>
#include <ndn-cxx/util/io.hpp>
#include <ndn-cxx/util/regex.hpp>
+#include "test-common.hpp"
+
+using boost::test_tools::output_test_stream;
+
namespace ndn {
namespace ndns {
namespace tests {
@@ -50,7 +42,6 @@
static const boost::filesystem::path TEST_CERTDIR = TEST_CONFIG_PATH "/management_tool_certs";
static const Name FAKE_ROOT("/fake-root/123456789");
-
/**
* @brief Recursive copy a directory using Boost Filesystem
*
@@ -102,7 +93,7 @@
};
-class ManagementToolFixture : public TestHome
+class ManagementToolFixture : public TestHome, public IdentityManagementFixture
{
public:
class Error : public std::runtime_error
@@ -126,8 +117,7 @@
};
ManagementToolFixture()
- : m_keyChain("sqlite3", "file")
- , m_tool(TEST_DATABASE.string().c_str(), m_keyChain)
+ : m_tool(TEST_DATABASE.string().c_str(), m_keyChain)
, m_dbMgr(TEST_DATABASE.string().c_str())
, rootKsk("/KEY/ksk-1416974006376/ID-CERT/%FD%00%00%01I%EA%3Bx%BD")
@@ -204,7 +194,6 @@
public:
PreviousStateCleaner cleaner; // must be first variable
- ndn::KeyChain m_keyChain;
ndns::ManagementTool m_tool;
ndns::DbMgr m_dbMgr;