selftests/tls: add test for sleeping even though there is data
authorJakub Kicinski <jakub.kicinski@netronome.com>
Fri, 24 May 2019 17:34:33 +0000 (10:34 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 May 2019 04:47:13 +0000 (21:47 -0700)
Add a test which sends 15 bytes of data, and then tries
to read 10 byes twice.  Previously the second read would
sleep indifinitely, since the record was already decrypted
and there is only 5 bytes left, not full 10.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/tls.c

index 01efbcd2258c9368ea0d96b4e780fc08c44a067a..278c8613455619573934edeff1e9d8ac599dab52 100644 (file)
@@ -442,6 +442,21 @@ TEST_F(tls, multiple_send_single_recv)
        EXPECT_EQ(memcmp(send_mem, recv_mem + send_len, send_len), 0);
 }
 
+TEST_F(tls, single_send_multiple_recv_non_align)
+{
+       const unsigned int total_len = 15;
+       const unsigned int recv_len = 10;
+       char recv_mem[recv_len * 2];
+       char send_mem[total_len];
+
+       EXPECT_GE(send(self->fd, send_mem, total_len, 0), 0);
+       memset(recv_mem, 0, total_len);
+
+       EXPECT_EQ(recv(self->cfd, recv_mem, recv_len, 0), recv_len);
+       EXPECT_EQ(recv(self->cfd, recv_mem + recv_len, recv_len, 0), 5);
+       EXPECT_EQ(memcmp(send_mem, recv_mem, total_len), 0);
+}
+
 TEST_F(tls, recv_partial)
 {
        char const *test_str = "test_read_partial";