build: align minimum build dependencies with ndn-cxx
* Recommend gcc >= 7.4.0
* Require clang >= 4.0, or Xcode >= 9.0 on macOS
* Silence an ABI-related diagnostic message from gcc on armv7
* Update Travis CI job matrix
Refs: #5087, #5106
Change-Id: I659aa617dad0ed7eb23967215c37586ef168d88c
diff --git a/tests/boost-multi-log-formatter.hpp b/tests/boost-multi-log-formatter.hpp
deleted file mode 100644
index 50c2031..0000000
--- a/tests/boost-multi-log-formatter.hpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020 Regents of the University of California.
- *
- * Based on work by Martin Ba (http://stackoverflow.com/a/26718189)
- *
- * This file is distributed under the Boost Software License, Version 1.0.
- * (See http://www.boost.org/LICENSE_1_0.txt)
- */
-
-#ifndef NDN_TESTS_BOOST_MULTI_LOG_FORMATTER_HPP
-#define NDN_TESTS_BOOST_MULTI_LOG_FORMATTER_HPP
-
-#include <boost/version.hpp>
-
-#if BOOST_VERSION >= 105900
-#include <boost/test/unit_test_parameters.hpp>
-#else
-#include <boost/test/detail/unit_test_parameters.hpp>
-#endif // BOOST_VERSION >= 105900
-
-#include <boost/test/unit_test_log_formatter.hpp>
-#include <boost/test/output/compiler_log_formatter.hpp>
-#include <boost/test/output/xml_log_formatter.hpp>
-
-namespace boost {
-namespace unit_test {
-namespace output {
-
-/**
- * @brief Log formatter for Boost.Test that outputs the logging to multiple formatters
- *
- * The log formatter is designed to output to one or multiple formatters at the same time. For
- * example, one HRF formatter can output to the standard output, while XML formatter output to
- * the file.
- *
- * Usage:
- *
- * // Call in init_unit_test_suite: (this will override the --log_format parameter)
- * auto formatter = new boost::unit_test::output::multi_log_formatter; // same as already configured logger
- *
- * // Prepare and add additional logger(s)
- * formatter.add(std::make_shared<boost::unit_test::output::xml_log_formatter>(),
- * std::make_shared<std::ofstream>("out.xml"));
- *
- * boost::unit_test::unit_test_log.set_formatter(formatter);
- *
- * @note Calling `boost::unit_test::unit_test_log.set_stream(...)` will change the stream for
- * the original logger.
- */
-class multi_log_formatter : public unit_test_log_formatter
-{
-public:
- /**
- * @brief Create instance of the logger, based on the configured logger instance
- */
- multi_log_formatter()
- {
- auto format =
-#if BOOST_VERSION > 105900
- runtime_config::get<output_format>(runtime_config::LOG_FORMAT);
-#else
- runtime_config::log_format();
-#endif // BOOST_VERSION > 105900
-
- switch (format) {
- default:
-#if BOOST_VERSION >= 105900
- case OF_CLF:
-#else
- case CLF:
-#endif // BOOST_VERSION >= 105900
- m_loggers.push_back({std::make_shared<compiler_log_formatter>(), nullptr});
- break;
-#if BOOST_VERSION >= 105900
- case OF_XML:
-#else
- case XML:
-#endif // BOOST_VERSION >= 105900
- m_loggers.push_back({std::make_shared<xml_log_formatter>(), nullptr});
- break;
- }
- }
-
- void
- add(std::shared_ptr<unit_test_log_formatter> formatter, std::shared_ptr<std::ostream> os)
- {
- m_loggers.push_back({formatter, os});
- }
-
- // Formatter interface
- void
- log_start(std::ostream& os, counter_t test_cases_amount)
- {
- for (auto& l : m_loggers)
- l.logger->log_start(l.os == nullptr ? os : *l.os, test_cases_amount);
- }
-
- void
- log_finish(std::ostream& os)
- {
- for (auto& l : m_loggers)
- l.logger->log_finish(l.os == nullptr ? os : *l.os);
- }
-
- void
- log_build_info(std::ostream& os)
- {
- for (auto& l : m_loggers)
- l.logger->log_build_info(l.os == nullptr ? os : *l.os);
- }
-
- void
- test_unit_start(std::ostream& os, const test_unit& tu)
- {
- for (auto& l : m_loggers)
- l.logger->test_unit_start(l.os == nullptr ? os : *l.os, tu);
- }
-
- void
- test_unit_finish(std::ostream& os, const test_unit& tu, unsigned long elapsed)
- {
- for (auto& l : m_loggers)
- l.logger->test_unit_finish(l.os == nullptr ? os : *l.os, tu, elapsed);
- }
-
- void
- test_unit_skipped(std::ostream& os, const test_unit& tu)
- {
- for (auto& l : m_loggers)
- l.logger->test_unit_skipped(l.os == nullptr ? os : *l.os, tu);
- }
-
-#if BOOST_VERSION >= 105900
- void
- log_exception_start(std::ostream& os, const log_checkpoint_data& lcd, const execution_exception& ex)
- {
- for (auto& l : m_loggers)
- l.logger->log_exception_start(l.os == nullptr ? os : *l.os, lcd, ex);
- }
-
- void
- log_exception_finish(std::ostream& os)
- {
- for (auto& l : m_loggers)
- l.logger->log_exception_finish(l.os == nullptr ? os : *l.os);
- }
-#else
- void
- log_exception(std::ostream& os, const log_checkpoint_data& lcd, const execution_exception& ex)
- {
- for (auto& l : m_loggers)
- l.logger->log_exception(l.os == nullptr ? os : *l.os, lcd, ex);
- }
-#endif // BOOST_VERSION >= 105900
-
- void
- log_entry_start(std::ostream& os, const log_entry_data& entry_data, log_entry_types let)
- {
- for (auto& l : m_loggers)
- l.logger->log_entry_start(l.os == nullptr ? os : *l.os, entry_data, let);
- }
-
- void
- log_entry_value(std::ostream& os, const_string value)
- {
- for (auto& l : m_loggers)
- l.logger->log_entry_value(l.os == nullptr ? os : *l.os, value);
- }
-
- void
- log_entry_finish(std::ostream& os)
- {
- for (auto& l : m_loggers)
- l.logger->log_entry_finish(l.os == nullptr ? os : *l.os);
- }
-
-#if BOOST_VERSION >= 105900
- void
- entry_context_start(std::ostream& os, log_level level)
- {
- for (auto& l : m_loggers)
- l.logger->entry_context_start(l.os == nullptr ? os : *l.os, level);
- }
-
- void
- log_entry_context(std::ostream& os, const_string value)
- {
- for (auto& l : m_loggers)
- l.logger->log_entry_context(l.os == nullptr ? os : *l.os, value);
- }
-
- void
- entry_context_finish(std::ostream& os)
- {
- for (auto& l : m_loggers)
- l.logger->entry_context_finish(l.os == nullptr ? os : *l.os);
- }
-#endif // BOOST_VERSION >= 105900
-
-private:
- struct LoggerInfo
- {
- std::shared_ptr<unit_test_log_formatter> logger;
- std::shared_ptr<std::ostream> os;
- };
- std::vector<LoggerInfo> m_loggers;
-};
-
-} // namespace output
-} // namespace unit_test
-} // namespace boost
-
-#endif // NDN_TESTS_BOOST_MULTI_LOG_FORMATTER_HPP
diff --git a/tests/main.cpp b/tests/main.cpp
index c951124..6ba19e4 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -24,91 +24,4 @@
*/
#define BOOST_TEST_MODULE PSync
-
-#include <boost/version.hpp>
-
-#if BOOST_VERSION >= 106200
-// Boost.Test v3.3 (Boost 1.62) natively supports multi-logger output
-#include "boost-test.hpp"
-#else
-#define BOOST_TEST_ALTERNATIVE_INIT_API
-#define BOOST_TEST_NO_MAIN
-#include "boost-test.hpp"
-#include "boost-multi-log-formatter.hpp"
-
-#include <boost/program_options/options_description.hpp>
-#include <boost/program_options/variables_map.hpp>
-#include <boost/program_options/parsers.hpp>
-
-#include <fstream>
-#include <iostream>
-
-static bool
-init_tests()
-{
- init_unit_test();
-
- namespace po = boost::program_options;
- namespace ut = boost::unit_test;
-
- po::options_description extraOptions;
- std::string logger;
- std::string outputFile = "-";
- extraOptions.add_options()
- ("log_format2", po::value<std::string>(&logger), "Type of second log formatter: HRF or XML")
- ("log_sink2", po::value<std::string>(&outputFile)->default_value(outputFile), "Second log sink, - for stdout")
- ;
- po::variables_map vm;
- try {
- po::store(po::command_line_parser(ut::framework::master_test_suite().argc,
- ut::framework::master_test_suite().argv)
- .options(extraOptions)
- .run(),
- vm);
- po::notify(vm);
- }
- catch (const std::exception& e) {
- std::cerr << "ERROR: " << e.what() << "\n"
- << extraOptions << std::endl;
- return false;
- }
-
- if (vm.count("log_format2") == 0) {
- // second logger is not configured
- return true;
- }
-
- std::shared_ptr<ut::unit_test_log_formatter> formatter;
- if (logger == "XML") {
- formatter = std::make_shared<ut::output::xml_log_formatter>();
- }
- else if (logger == "HRF") {
- formatter = std::make_shared<ut::output::compiler_log_formatter>();
- }
- else {
- std::cerr << "ERROR: only HRF or XML log formatter can be specified" << std::endl;
- return false;
- }
-
- std::shared_ptr<std::ostream> output;
- if (outputFile == "-") {
- output = std::shared_ptr<std::ostream>(&std::cout, std::bind([]{}));
- }
- else {
- output = std::make_shared<std::ofstream>(outputFile.c_str());
- }
-
- auto multiFormatter = new ut::output::multi_log_formatter;
- multiFormatter->add(formatter, output);
- ut::unit_test_log.set_formatter(multiFormatter);
-
- return true;
-}
-
-int
-main(int argc, char* argv[])
-{
- return ::boost::unit_test::unit_test_main(&init_tests, argc, argv);
-}
-
-#endif // BOOST_VERSION >= 106200
+#include "tests/boost-test.hpp"
diff --git a/tests/test-segment-publisher.cpp b/tests/test-segment-publisher.cpp
index 55db765..7b7bfc7 100644
--- a/tests/test-segment-publisher.cpp
+++ b/tests/test-segment-publisher.cpp
@@ -37,11 +37,11 @@
{
public:
SegmentPublisherFixture()
- : face(io, util::DummyClientFace::Options{true, true})
- , publisher(face, keyChain)
- , freshness(1000)
- , numComplete(0)
- , numRepliesFromStore(0)
+ : face(io, util::DummyClientFace::Options{true, true})
+ , publisher(face, keyChain)
+ , freshness(1000)
+ , numComplete(0)
+ , numRepliesFromStore(0)
{
face.setInterestFilter(InterestFilter("/hello/world"),
bind(&SegmentPublisherFixture::onInterest, this, _1, _2),
@@ -55,25 +55,24 @@
}
}
- ~SegmentPublisherFixture() {
+ ~SegmentPublisherFixture()
+ {
fetcher->stop();
}
void
- expressInterest(const Interest& interest) {
- fetcher = util::SegmentFetcher::start(face, interest, ndn::security::v2::getAcceptAllValidator());
- fetcher->onComplete.connect([this] (ConstBufferPtr data) {
- numComplete++;
- });
- fetcher->onError.connect([] (uint32_t errorCode, const std::string& msg) {
- BOOST_CHECK(false);
- });
+ expressInterest(const Interest& interest)
+ {
+ fetcher = util::SegmentFetcher::start(face, interest, ndn::security::getAcceptAllValidator());
+ fetcher->onComplete.connect([this] (auto&&...) { numComplete++; });
+ fetcher->onError.connect([] (auto&&...) { BOOST_CHECK(false); });
advanceClocks(ndn::time::milliseconds(10));
}
void
- onInterest(const Name& prefix, const Interest& interest) {
+ onInterest(const Name& prefix, const Interest& interest)
+ {
if (publisher.replyFromStore(interest.getName())) {
numRepliesFromStore++;
return;