Skip to content

Commit

Permalink
bugFix ros-industrial#26: simple_message tcp test requires ROS-spin f…
Browse files Browse the repository at this point in the history
…or MessageManager
  • Loading branch information
JeremyZoss committed Nov 8, 2012
1 parent 8c29ea4 commit e8069ab
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion simple_message/test/utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ TEST(DISABLED_MessageManagerSuite, udp)
pthread_join(udpSrvThrd, NULL);
}

TEST(DISABLED_MessageManagerSuite, tcp)
TEST(MessageManagerSuite, tcp)
{
const int tcpPort = 11000;
char ipAddr[] = "127.0.0.1";
Expand All @@ -330,6 +330,10 @@ TEST(DISABLED_MessageManagerSuite, tcp)
SimpleMessage pingRequest, pingReply;
MessageManager tcpManager;

// MessageManager uses ros::ok, which needs ros spinner
ros::AsyncSpinner spinner(0);
spinner.start();

ASSERT_TRUE(pingRequest.init(StandardMsgTypes::PING, CommTypes::SERVICE_REQUEST, ReplyTypes::INVALID));

// TCP Socket testing
Expand Down Expand Up @@ -362,12 +366,15 @@ TEST(DISABLED_MessageManagerSuite, tcp)
delete tcpClient;
sleep(10); //Allow time for client to destruct and free up port
tcpClient = new TcpClient();

ASSERT_TRUE(tcpClient->init(&ipAddr[0], tcpPort));
ASSERT_TRUE(tcpClient->makeConnect());
ASSERT_TRUE(tcpClient->sendAndReceiveMsg(pingRequest, pingReply));

pthread_cancel(tcpSrvThrd);
pthread_join(tcpSrvThrd, NULL);

delete tcpClient;
}

TEST(JointMessage, init)
Expand Down Expand Up @@ -588,6 +595,7 @@ TEST(JointTraj, equal)
// Run all the tests that were declared with TEST()
int main(int argc, char **argv)
{
ros::init(argc, argv, "test"); // some tests need ROS framework
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Expand Down

0 comments on commit e8069ab

Please sign in to comment.