@@ -526,6 +526,28 @@ static void test_send_receive(bssl::UniquePtr<BIO> &sender_bio,
526
526
ASSERT_EQ (Bytes (buff), Bytes (kTestMessage ));
527
527
}
528
528
529
+ static void test_puts_receive (bssl::UniquePtr<BIO> &sender_bio,
530
+ bssl::UniquePtr<BIO> &receiver_bio) {
531
+ static constexpr char kTestMessage [] = " test" ;
532
+
533
+ // Send a message
534
+ ASSERT_EQ ((int )strlen (kTestMessage ),
535
+ BIO_puts (sender_bio.get (), kTestMessage ))
536
+ << LastSocketError ();
537
+ // BIO_flush is a no-op, but test it anyway.
538
+ ASSERT_EQ (1 , BIO_flush (sender_bio.get ())) << LastSocketError ();
539
+
540
+ // Receive a message.
541
+ char buff[1024 ];
542
+ // `BIO_puts` does not send the \0 byte at the end of the string.
543
+ ASSERT_EQ ((int )strlen (kTestMessage ),
544
+ BIO_read (receiver_bio.get (), buff, sizeof (buff)))
545
+ << LastSocketError ();
546
+
547
+ // Verify the message received matches the message sent.
548
+ ASSERT_EQ (Bytes (buff), Bytes (kTestMessage ));
549
+ }
550
+
529
551
class BIODgramTest : public testing ::TestWithParam<int > {
530
552
// You can implement all the usual fixture class members here.
531
553
// To access the test parameter, call GetParam() from class
@@ -583,7 +605,10 @@ TEST_P(BIODgramTest, SocketDatagramSetPeer) {
583
605
ASSERT_EQ (bio_server_addr, bio_server_addr_copy) << LastSocketError ();
584
606
585
607
test_send_receive (client_bio, server_bio);
608
+ ASSERT_EQ (0 , BIO_dgram_send_timedout (client_bio.get ()));
609
+ ASSERT_EQ (0 , BIO_dgram_recv_timedout (server_bio.get ()));
586
610
test_send_receive (server_bio, client_bio);
611
+ test_puts_receive (client_bio, server_bio);
587
612
}
588
613
589
614
TEST_P (BIODgramTest, SocketDatagramSetConnected) {
0 commit comments