tests: use LimitedIo API for time or IO limits
Change-Id: Id5cc1cea9bf1329e730d92c4099e80adbfc0f500
diff --git a/tests/core/limited-io.cpp b/tests/core/limited-io.cpp
index ea19585..b381696 100644
--- a/tests/core/limited-io.cpp
+++ b/tests/core/limited-io.cpp
@@ -5,10 +5,13 @@
*/
#include "limited-io.hpp"
+#include "core/logger.hpp"
namespace nfd {
namespace tests {
+NFD_LOG_INIT("LimitedIo");
+
const int LimitedIo::UNLIMITED_OPS = std::numeric_limits<int>::max();
const time::Duration LimitedIo::UNLIMITED_TIME = time::nanoseconds(-1);
@@ -30,7 +33,14 @@
m_timeout = scheduler::schedule(nTimeLimit, bind(&LimitedIo::afterTimeout, this));
}
- getGlobalIoService().run();
+ try {
+ getGlobalIoService().run();
+ }
+ catch (std::exception& ex) {
+ m_reason = EXCEPTION;
+ NFD_LOG_ERROR("g_io.run() exception: " << ex.what());
+ m_lastException = ex;
+ }
getGlobalIoService().reset();
scheduler::cancel(m_timeout);
@@ -55,5 +65,11 @@
getGlobalIoService().stop();
}
+const std::exception&
+LimitedIo::getLastException() const
+{
+ return m_lastException;
+}
+
} // namespace tests
} // namespace nfd