Fixed timings for tests in order to reduce probability of test failure on a non-realtime system

This commit is contained in:
Pavel Kirienko
2014-03-28 02:04:22 +04:00
parent 86269c32ff
commit c769626eef
9 changed files with 32 additions and 32 deletions
@@ -69,7 +69,7 @@ TEST(DataTypeInfoProvider, Basic)
gdti_request.id = GetDataTypeInfo::DefaultDataTypeID;
gdti_request.kind.value = DataTypeKind::SERVICE;
ASSERT_LE(0, gdti_cln.call(1, gdti_request));
nodes.spinBoth(MonotonicDuration::fromMSec(2));
nodes.spinBoth(MonotonicDuration::fromMSec(10));
ASSERT_TRUE(validateDataTypeInfoResponse<GetDataTypeInfo>(gdti_cln.collector.result,
GetDataTypeInfo::Response::MASK_KNOWN |
@@ -82,7 +82,7 @@ TEST(DataTypeInfoProvider, Basic)
gdti_request.id = NodeStatus::DefaultDataTypeID;
gdti_request.kind.value = DataTypeKind::MESSAGE;
ASSERT_LE(0, gdti_cln.call(1, gdti_request));
nodes.spinBoth(MonotonicDuration::fromMSec(2));
nodes.spinBoth(MonotonicDuration::fromMSec(10));
ASSERT_TRUE(validateDataTypeInfoResponse<NodeStatus>(gdti_cln.collector.result,
GetDataTypeInfo::Response::MASK_KNOWN));
@@ -98,7 +98,7 @@ TEST(DataTypeInfoProvider, Basic)
// Request again
ASSERT_LE(0, gdti_cln.call(1, gdti_request));
nodes.spinBoth(MonotonicDuration::fromMSec(2));
nodes.spinBoth(MonotonicDuration::fromMSec(10));
ASSERT_TRUE(validateDataTypeInfoResponse<NodeStatus>(gdti_cln.collector.result,
GetDataTypeInfo::Response::MASK_KNOWN |
@@ -111,7 +111,7 @@ TEST(DataTypeInfoProvider, Basic)
gdti_request.id = ComputeAggregateTypeSignature::DefaultDataTypeID;
gdti_request.kind.value = 0xFF; // INVALID VALUE
ASSERT_LE(0, gdti_cln.call(1, gdti_request));
nodes.spinBoth(MonotonicDuration::fromMSec(2));
nodes.spinBoth(MonotonicDuration::fromMSec(10));
ASSERT_TRUE(gdti_cln.collector.result.get());
ASSERT_TRUE(gdti_cln.collector.result->isSuccessful());
@@ -125,7 +125,7 @@ TEST(DataTypeInfoProvider, Basic)
cats_request.kind.value = DataTypeKind::MESSAGE;
cats_request.known_ids.set(); // Assuming we have all 1023 types
ASSERT_LE(0, cats_cln.call(1, cats_request));
nodes.spinBoth(MonotonicDuration::fromMSec(2));
nodes.spinBoth(MonotonicDuration::fromMSec(10));
ASSERT_TRUE(cats_cln.collector.result.get());
ASSERT_TRUE(cats_cln.collector.result->isSuccessful());
@@ -141,7 +141,7 @@ TEST(DataTypeInfoProvider, Basic)
cats_request.kind.value = 0xFF; // INVALID
cats_request.known_ids.set(); // Assuming we have all 1023 types
ASSERT_LE(0, cats_cln.call(1, cats_request));
nodes.spinBoth(MonotonicDuration::fromMSec(2));
nodes.spinBoth(MonotonicDuration::fromMSec(10));
ASSERT_TRUE(cats_cln.collector.result.get());
ASSERT_TRUE(cats_cln.collector.result->isSuccessful());
@@ -35,7 +35,7 @@ struct GlobalTimeSyncTestNetwork
master_high.can.other = &slave.can;
}
void spinAll(uavcan::MonotonicDuration duration = uavcan::MonotonicDuration::fromMSec(3))
void spinAll(uavcan::MonotonicDuration duration = uavcan::MonotonicDuration::fromMSec(9))
{
assert(!duration.isNegative());
unsigned int nspins3 = duration.toMSec() / 3;
@@ -213,18 +213,18 @@ TEST(GlobalTimeSyncSlave, Validation)
*/
broadcastSyncMsg(slave_can.ifaces.at(0), 0, 8, 0); // Locked on this
broadcastSyncMsg(slave_can.ifaces.at(1), 2000, 8, 0); // Ignored
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(10)));
broadcastSyncMsg(slave_can.ifaces.at(0), 1000, 8, 1); // Adjust 1000 ahead
broadcastSyncMsg(slave_can.ifaces.at(1), 2000, 8, 1); // Ignored
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(10)));
ASSERT_TRUE(gtss.isActive());
ASSERT_EQ(8, gtss.getMasterNodeID().get());
ASSERT_EQ(1000, slave_clock.utc);
broadcastSyncMsg(slave_can.ifaces.at(0), 2000, 8, 2); // Update
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(10)));
ASSERT_EQ(1000, slave_clock.utc);
std::cout << slave_clock.monotonic << std::endl;
@@ -233,7 +233,7 @@ TEST(GlobalTimeSyncSlave, Validation)
* TID jump simulates a frame loss
*/
broadcastSyncMsg(slave_can.ifaces.at(0), 3000, 8, 4); // Adjustment skipped - expected TID 3, update instead
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(10)));
ASSERT_TRUE(gtss.isActive());
ASSERT_EQ(8, gtss.getMasterNodeID().get());
@@ -245,7 +245,7 @@ TEST(GlobalTimeSyncSlave, Validation)
*/
broadcastSyncMsg(slave_can.ifaces.at(0), 3000, 8, 5); // Slave UTC was 1000, master reports 3000 --> shift ahead
broadcastSyncMsg(slave_can.ifaces.at(1), 2000, 8, 5);
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(10)));
ASSERT_TRUE(gtss.isActive());
ASSERT_EQ(8, gtss.getMasterNodeID().get());
@@ -257,17 +257,17 @@ TEST(GlobalTimeSyncSlave, Validation)
*/
broadcastSyncMsg(slave_can.ifaces.at(0), 2000, 8, 6); // Valid update, slave UTC is 3000
broadcastSyncMsg(slave_can.ifaces.at(1), 2000, 8, 6);
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(10)));
slave_clock.monotonic += 5000000;
broadcastSyncMsg(slave_can.ifaces.at(0), 5000, 8, 7); // Adjustment skipped
broadcastSyncMsg(slave_can.ifaces.at(1), 2000, 8, 7);
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(10)));
broadcastSyncMsg(slave_can.ifaces.at(0), 5000, 8, 0); // Valid adjustment now
broadcastSyncMsg(slave_can.ifaces.at(1), 2000, 8, 0);
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(10)));
ASSERT_TRUE(gtss.isActive());
ASSERT_EQ(8, gtss.getMasterNodeID().get());
+5 -5
View File
@@ -86,26 +86,26 @@ TEST(Logger, Basic)
ASSERT_TRUE(sink.popMatchByLevelAndText(uavcan::protocol::debug::LogLevel::DEBUG, "foo", "Debug (sink only)"));
ASSERT_LE(0, logger.logError("foo", "Error"));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(2));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_EQ(log_sub.collector.msg->level.value, uavcan::protocol::debug::LogLevel::ERROR);
ASSERT_EQ(log_sub.collector.msg->source, "foo");
ASSERT_EQ(log_sub.collector.msg->text, "Error");
logger.setLevel(uavcan::protocol::debug::LogLevel::DEBUG);
ASSERT_LE(0, logger.logWarning("foo", "Warning"));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(2));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_EQ(log_sub.collector.msg->level.value, uavcan::protocol::debug::LogLevel::WARNING);
ASSERT_EQ(log_sub.collector.msg->source, "foo");
ASSERT_EQ(log_sub.collector.msg->text, "Warning");
ASSERT_LE(0, logger.logInfo("foo", "Info"));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(2));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_EQ(log_sub.collector.msg->level.value, uavcan::protocol::debug::LogLevel::INFO);
ASSERT_EQ(log_sub.collector.msg->source, "foo");
ASSERT_EQ(log_sub.collector.msg->text, "Info");
ASSERT_LE(0, logger.logDebug("foo", "Debug"));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(2));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_EQ(log_sub.collector.msg->level.value, uavcan::protocol::debug::LogLevel::DEBUG);
ASSERT_EQ(log_sub.collector.msg->source, "foo");
ASSERT_EQ(log_sub.collector.msg->text, "Debug");
@@ -133,7 +133,7 @@ TEST(Logger, Cpp11Formatting)
ASSERT_LE(0, log_sub.start());
ASSERT_LE(0, logger.logWarning("foo", "char='%*', %* is %*", '$', "double", 12.34));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(2));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_EQ(log_sub.collector.msg->level.value, uavcan::protocol::debug::LogLevel::WARNING);
ASSERT_EQ(log_sub.collector.msg->source, "foo");
ASSERT_EQ(log_sub.collector.msg->text, "char='$', double is 12.340000");
@@ -41,7 +41,7 @@ static void publishNodeStatus(CanDriverMock& can, uavcan::NodeID node_id, uavcan
static void shortSpin(TestNode& node)
{
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(10)));
}
@@ -63,7 +63,7 @@ TEST(NodeStatusMonitor, Basic)
uavcan::NodeStatusMonitor nsm(node);
ASSERT_LE(0, nsm.start());
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, node.spin(uavcan::MonotonicDuration::fromMSec(10)));
/*
* Empty NSM, no nodes were registered yet
@@ -25,7 +25,7 @@ TEST(PanicBroadcaster, Basic)
ASSERT_STREQ("I lost ", panicker.getReason().c_str());
ASSERT_TRUE(panicker.isPanicking());
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(2));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_TRUE(sub.collector.msg.get());
ASSERT_STREQ("I lost ", sub.collector.msg->reason_text.c_str());
sub.collector.msg.reset();
+1 -1
View File
@@ -78,7 +78,7 @@ template <typename Client, typename Message>
static void doCall(Client& client, const Message& request, InterlinkedTestNodesWithSysClock& nodes)
{
ASSERT_LE(0, client.call(1, request));
ASSERT_LE(0, nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10)));
ASSERT_TRUE(client.collector.result->isSuccessful());
}
@@ -40,7 +40,7 @@ TEST(RestartRequestServer, Basic)
* Rejected - handler was not set
*/
ASSERT_LE(0, rrs_cln.call(1, request));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(2));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_TRUE(rrs_cln.collector.result.get());
ASSERT_TRUE(rrs_cln.collector.result->isSuccessful());
@@ -54,7 +54,7 @@ TEST(RestartRequestServer, Basic)
rrs.setHandler(&handler);
ASSERT_LE(0, rrs_cln.call(1, request));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(2));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_TRUE(rrs_cln.collector.result->isSuccessful());
ASSERT_TRUE(rrs_cln.collector.result->response.ok);
@@ -65,7 +65,7 @@ TEST(RestartRequestServer, Basic)
handler.accept = false;
ASSERT_LE(0, rrs_cln.call(1, request));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(2));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_TRUE(rrs_cln.collector.result->isSuccessful());
ASSERT_FALSE(rrs_cln.collector.result->response.ok);
@@ -76,7 +76,7 @@ TEST(RestartRequestServer, Basic)
handler.accept = true;
ASSERT_LE(0, rrs_cln.call(1, uavcan::protocol::RestartNode::Request()));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(2));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_TRUE(rrs_cln.collector.result->isSuccessful());
ASSERT_FALSE(rrs_cln.collector.result->response.ok);
@@ -24,7 +24,7 @@ TEST(TransportStatsProvider, Basic)
* First request
*/
ASSERT_LE(0, tsp_cln.call(1, uavcan::protocol::GetTransportStats::Request()));
ASSERT_LE(0, nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10)));
ASSERT_TRUE(tsp_cln.collector.result.get());
ASSERT_TRUE(tsp_cln.collector.result->isSuccessful());
@@ -40,7 +40,7 @@ TEST(TransportStatsProvider, Basic)
* Second request
*/
ASSERT_LE(0, tsp_cln.call(1, uavcan::protocol::GetTransportStats::Request()));
ASSERT_LE(0, nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10)));
ASSERT_TRUE(tsp_cln.collector.result.get());
ASSERT_EQ(0, tsp_cln.collector.result->response.transfer_errors);
@@ -60,7 +60,7 @@ TEST(TransportStatsProvider, Basic)
ASSERT_TRUE(frame.compile(can_frame));
nodes.can_a.read_queue.push(can_frame);
ASSERT_LE(0, nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10)));
/*
* Introducing a CAN driver error
@@ -71,7 +71,7 @@ TEST(TransportStatsProvider, Basic)
* Third request
*/
ASSERT_LE(0, tsp_cln.call(1, uavcan::protocol::GetTransportStats::Request()));
ASSERT_LE(0, nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(1)));
ASSERT_LE(0, nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10)));
ASSERT_TRUE(tsp_cln.collector.result.get());
ASSERT_EQ(1, tsp_cln.collector.result->response.transfer_errors); // That broken frame