mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-29 13:07:50 +00:00
[#1878] fixed unittests
This commit is contained in:
parent
ef6f0a4ddf
commit
fbb389aea2
@ -32,9 +32,8 @@ RunScriptImpl::configure(LibraryHandle& handle) {
|
||||
if (name->getType() != Element::string) {
|
||||
isc_throw(InvalidParameter, "The 'name' parameter must be a string");
|
||||
}
|
||||
IOServicePtr io_service(new asiolink::IOService());
|
||||
try {
|
||||
ProcessSpawn process(io_service, name->stringValue());
|
||||
ProcessSpawn process(IOServicePtr(), name->stringValue());
|
||||
} catch (const isc::Exception& ex) {
|
||||
isc_throw(InvalidParameter, "Invalid 'name' parameter: " << ex.what());
|
||||
}
|
||||
@ -50,7 +49,7 @@ RunScriptImpl::configure(LibraryHandle& handle) {
|
||||
|
||||
void
|
||||
RunScriptImpl::runScript(const ProcessArgs& args, const ProcessEnvVars& vars) {
|
||||
ProcessSpawn process(io_service_, name_, args, vars);
|
||||
ProcessSpawn process(getIOService(), name_, args, vars);
|
||||
process.spawn(true);
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,13 @@ public:
|
||||
io_service_ = io_service;
|
||||
}
|
||||
|
||||
/// @brief Gets IO service to be used by the @ref ProcessSpawn instance.
|
||||
///
|
||||
/// @return The IOService object, used for all ASIO operations.
|
||||
static isc::asiolink::IOServicePtr getIOService() {
|
||||
return (io_service_);
|
||||
}
|
||||
|
||||
/// @brief Extract boolean data and append to environment.
|
||||
///
|
||||
/// @param value The value to be exported to target script environment.
|
||||
|
@ -34,6 +34,12 @@ public:
|
||||
/// @brief IOService instance to process IO.
|
||||
asiolink::IOServicePtr io_service_;
|
||||
|
||||
/// @brief Single instance of IOService.
|
||||
static asiolink::IOServicePtr getIOService() {
|
||||
static asiolink::IOServicePtr io_service(new asiolink::IOService());
|
||||
return (io_service);
|
||||
}
|
||||
|
||||
/// @brief Failsafe timer to ensure test(s) do not hang.
|
||||
isc::asiolink::IntervalTimer test_timer_;
|
||||
|
||||
@ -48,7 +54,7 @@ public:
|
||||
|
||||
/// @brief Constructor.
|
||||
ProcessSpawnTest() :
|
||||
io_service_(new asiolink::IOService()), test_timer_(*io_service_),
|
||||
io_service_(getIOService()), test_timer_(*io_service_),
|
||||
test_time_ms_(0), io_signal_set_(), processed_signals_() {
|
||||
|
||||
io_signal_set_.reset(new IOSignalSet(io_service_,
|
||||
@ -58,7 +64,9 @@ public:
|
||||
}
|
||||
|
||||
/// @brief Destructor.
|
||||
~ProcessSpawnTest() {}
|
||||
~ProcessSpawnTest() {
|
||||
io_signal_set_->remove(SIGCHLD);
|
||||
}
|
||||
|
||||
/// @brief Method used as the IOSignalSet handler.
|
||||
///
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
MemfileLeaseMgrTest() :
|
||||
io4_(getLeaseFilePath("leasefile4_0.csv")),
|
||||
io6_(getLeaseFilePath("leasefile6_0.csv")),
|
||||
io_service_(new IOService()),
|
||||
io_service_(getIOService()),
|
||||
timer_mgr_(TimerMgr::instance()) {
|
||||
|
||||
timer_mgr_->setIOService(io_service_);
|
||||
@ -253,6 +253,11 @@ public:
|
||||
return (!elapsed);
|
||||
}
|
||||
|
||||
/// @brief Single instance of IOService.
|
||||
static asiolink::IOServicePtr getIOService() {
|
||||
static asiolink::IOServicePtr io_service(new asiolink::IOService());
|
||||
return (io_service);
|
||||
}
|
||||
|
||||
/// @brief Generates a DHCPv4 lease with random content.
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user