#include <dhcp/dhcp6.h>
#include <dhcp/duid.h>
#include <dhcp/hwaddr.h>
+#include <dhcp/iface_mgr.h>
#include <dhcp/option.h>
#include <dhcp/option_int.h>
#include <dhcpsrv/cfgmgr.h>
HATest::HATest()
: io_service_(new IOService()),
network_state_(new NetworkState()) {
+ // Just make sure that the interface manager is created in the main thread.
+ IfaceMgr::instance();
}
HATest::~HATest() {
io_service_->post(std::bind(&HATest::signalServiceRunning, this, std::ref(running),
std::ref(mutex), std::ref(condvar)));
+
+ // IfaceMgr::instance().setCheckThreadId(false);
+
+ auto f = [](IOServicePtr io_service) {
+ try {
+ io_service->run();
+ } catch (std::exception& ex) {
+ ADD_FAILURE() << "error while running IOService::run: " << ex.what();
+ } catch (...) {
+ ADD_FAILURE() << "error while running IOService::run";
+ }
+ // IfaceMgr::instance().setCheckThreadId(true);
+ };
+
boost::shared_ptr<std::thread>
- th(new std::thread(std::bind(&IOService::run, io_service_.get())));
+ th(new std::thread(std::bind(f, io_service_)));
std::unique_lock<std::mutex> lock(mutex);
- while (!running) {
- condvar.wait(lock);
- }
+ condvar.wait(lock, [&]() { return (running); });
return (th);
}
condvar.notify_one();
}
-
void
HATest::checkThatTimeIsParsable(ElementPtr const& node, bool const null_expected) {
ConstElementPtr system_time(node->get("system-time"));
return (Element::fromJSON(config_text.str()));
}
-
HAConfigPtr
HATest::createValidConfiguration(const HAConfig::HAMode& ha_mode) const {
auto config_storage = HAConfigParser::parse(createValidJsonConfiguration(ha_mode));
return (key);
}
-
Pkt4Ptr
HATest::createMessage4(const uint8_t msg_type, const uint8_t hw_address_seed,
const uint8_t client_id_seed, const uint16_t secs) const {