From c769626eefb4c502f15b6283473c42f82e906433 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 28 Mar 2014 02:04:22 +0400 Subject: [PATCH] Fixed timings for tests in order to reduce probability of test failure on a non-realtime system --- .../test/protocol/data_type_info_provider.cpp | 12 ++++++------ .../test/protocol/global_time_sync_master.cpp | 2 +- .../test/protocol/global_time_sync_slave.cpp | 16 ++++++++-------- libuavcan/test/protocol/logger.cpp | 10 +++++----- libuavcan/test/protocol/node_status_monitor.cpp | 4 ++-- libuavcan/test/protocol/panic_broadcaster.cpp | 2 +- libuavcan/test/protocol/param_server.cpp | 2 +- .../test/protocol/restart_request_server.cpp | 8 ++++---- .../test/protocol/transport_stats_provider.cpp | 8 ++++---- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/libuavcan/test/protocol/data_type_info_provider.cpp b/libuavcan/test/protocol/data_type_info_provider.cpp index 5c9cc74747..d3fd47184b 100644 --- a/libuavcan/test/protocol/data_type_info_provider.cpp +++ b/libuavcan/test/protocol/data_type_info_provider.cpp @@ -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(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(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(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()); diff --git a/libuavcan/test/protocol/global_time_sync_master.cpp b/libuavcan/test/protocol/global_time_sync_master.cpp index 3d736e90a5..0e4979c6b3 100644 --- a/libuavcan/test/protocol/global_time_sync_master.cpp +++ b/libuavcan/test/protocol/global_time_sync_master.cpp @@ -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; diff --git a/libuavcan/test/protocol/global_time_sync_slave.cpp b/libuavcan/test/protocol/global_time_sync_slave.cpp index edfecf43b3..3d9cbf8322 100644 --- a/libuavcan/test/protocol/global_time_sync_slave.cpp +++ b/libuavcan/test/protocol/global_time_sync_slave.cpp @@ -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()); diff --git a/libuavcan/test/protocol/logger.cpp b/libuavcan/test/protocol/logger.cpp index 9b8c00466d..48dae6081d 100644 --- a/libuavcan/test/protocol/logger.cpp +++ b/libuavcan/test/protocol/logger.cpp @@ -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"); diff --git a/libuavcan/test/protocol/node_status_monitor.cpp b/libuavcan/test/protocol/node_status_monitor.cpp index 52aacc8168..eae83b3c24 100644 --- a/libuavcan/test/protocol/node_status_monitor.cpp +++ b/libuavcan/test/protocol/node_status_monitor.cpp @@ -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 diff --git a/libuavcan/test/protocol/panic_broadcaster.cpp b/libuavcan/test/protocol/panic_broadcaster.cpp index 47f21cda6b..edf9ba09e8 100644 --- a/libuavcan/test/protocol/panic_broadcaster.cpp +++ b/libuavcan/test/protocol/panic_broadcaster.cpp @@ -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(); diff --git a/libuavcan/test/protocol/param_server.cpp b/libuavcan/test/protocol/param_server.cpp index afe5767390..95df1f3ef1 100644 --- a/libuavcan/test/protocol/param_server.cpp +++ b/libuavcan/test/protocol/param_server.cpp @@ -78,7 +78,7 @@ template 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()); } diff --git a/libuavcan/test/protocol/restart_request_server.cpp b/libuavcan/test/protocol/restart_request_server.cpp index d1900fe964..7b27621bf2 100644 --- a/libuavcan/test/protocol/restart_request_server.cpp +++ b/libuavcan/test/protocol/restart_request_server.cpp @@ -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); diff --git a/libuavcan/test/protocol/transport_stats_provider.cpp b/libuavcan/test/protocol/transport_stats_provider.cpp index 27776ac81a..ded5af54ad 100644 --- a/libuavcan/test/protocol/transport_stats_provider.cpp +++ b/libuavcan/test/protocol/transport_stats_provider.cpp @@ -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