From 5cc74bf8724c97cd610907eb3edf13d417febb4c Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Wed, 19 Mar 2014 14:27:01 +0400 Subject: [PATCH] Tests: fixed spin() for InterlinkedTestNodes --- libuavcan/test/node/test_node.hpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/libuavcan/test/node/test_node.hpp b/libuavcan/test/node/test_node.hpp index f1e1157c7b..0c1b26631f 100644 --- a/libuavcan/test/node/test_node.hpp +++ b/libuavcan/test/node/test_node.hpp @@ -130,10 +130,19 @@ struct InterlinkedTestNodes int spinBoth(uavcan::MonotonicDuration duration) { - const uavcan::MonotonicDuration duration_per_node = duration * 0.5; - const int ret = a.spin(duration_per_node); - if (ret < 0) - return ret; - return b.spin(duration_per_node); + assert(duration.isPositive()); + unsigned int nspins2 = duration.toMSec() / 2 + 1; + assert(nspins2 > 0); + while (nspins2 --> 0) + { + int ret = -1; + ret = a.spin(uavcan::MonotonicDuration::fromMSec(1)); + if (ret < 0) + return ret; + ret = b.spin(uavcan::MonotonicDuration::fromMSec(1)); + if (ret < 0) + return ret; + } + return 0; } };