@@ -24,7 +24,7 @@ namespace Drv {
2424// Construction and destruction
2525// ----------------------------------------------------------------------
2626
27- void UdpTester::test_with_loop (U32 iterations, bool recv_thread) {
27+ void UdpTester::test_with_loop (U32 iterations, bool recv_thread, bool send_only ) {
2828 U8 buffer[sizeof (m_data_storage)] = {};
2929 Drv::SocketIpStatus status1 = Drv::SOCK_SUCCESS;
3030 Drv::SocketIpStatus status2 = Drv::SOCK_SUCCESS;
@@ -47,8 +47,9 @@ void UdpTester::test_with_loop(U32 iterations, bool recv_thread) {
4747
4848 // Configure the component
4949 this ->component .configureSend (" 127.0.0.1" , port1, 0 , 100 );
50- this ->component .configureRecv (" 127.0.0.1" , port2);
51-
50+ if (not send_only) {
51+ this ->component .configureRecv (" 127.0.0.1" , port2);
52+ }
5253 // Start up a receive thread
5354 if (recv_thread) {
5455 Os::TaskString name (" receiver thread" );
@@ -72,8 +73,10 @@ void UdpTester::test_with_loop(U32 iterations, bool recv_thread) {
7273 Drv::Test::get_configured_delay_ms () / 10 + 1 ));
7374 }
7475 EXPECT_TRUE (this ->component .isOpened ());
75-
76- udp2.configureSend (" 127.0.0.1" , port2, 0 , 100 );
76+ // Other side socket only receives when component is send-only
77+ if (not send_only) {
78+ udp2.configureSend (" 127.0.0.1" , port2, 0 , 100 );
79+ }
7780 udp2.configureRecv (" 127.0.0.1" , port1);
7881 status2 = udp2.open (udp2_fd);
7982
@@ -93,7 +96,7 @@ void UdpTester::test_with_loop(U32 iterations, bool recv_thread) {
9396 Drv::Test::receive_all (udp2, udp2_fd, buffer, size);
9497 Drv::Test::validate_random_buffer (m_data_buffer, buffer);
9598 // If receive thread is live, try the other way
96- if (recv_thread) {
99+ if (recv_thread and not send_only ) {
97100 m_spinner = false ;
98101 m_data_buffer.setSize (sizeof (m_data_storage));
99102 udp2.send (udp2_fd, m_data_buffer.getData (), m_data_buffer.getSize ());
@@ -144,6 +147,14 @@ void UdpTester ::test_multiple_messaging() {
144147 test_with_loop (100 );
145148}
146149
150+ void UdpTester ::test_basic_unidirectional_messaging () {
151+ test_with_loop (1 , false , true );
152+ }
153+
154+ void UdpTester ::test_multiple_unidirectional_messaging () {
155+ test_with_loop (100 , false , true );
156+ }
157+
147158void UdpTester ::test_receive_thread () {
148159 test_with_loop (1 , true );
149160}
0 commit comments