Skip to content

Commit 715c7a3

Browse files
committed
selftests: tls: make the new data_steal test less flaky
The CI has hit a couple of cases of: RUN global.data_steal ... tls.c:2762:data_steal:Expected recv(cfd, buf2, sizeof(buf2), MSG_DONTWAIT) (20000) == -1 (-1) data_steal: Test terminated by timeout FAIL global.data_steal Looks like the 2msec sleep is not long enough. Make the sleep longer, and then instead of second sleep wait for the thieving process to exit. That way we can be sure it called recv() before us. While at it also avoid trying to steal more than a record, this seems to be causing issues in manual testing as well. Fixes: d7e8259 ("selftests: tls: test TCP stealing data from under the TLS socket") Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 12da2b9 commit 715c7a3

File tree

1 file changed

+5
-7
lines changed
  • tools/testing/selftests/net

1 file changed

+5
-7
lines changed

tools/testing/selftests/net/tls.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,27 +2748,25 @@ TEST(data_steal) {
27482748
pid = fork();
27492749
ASSERT_GE(pid, 0);
27502750
if (!pid) {
2751-
EXPECT_EQ(recv(cfd, buf, sizeof(buf), MSG_WAITALL),
2752-
sizeof(buf));
2751+
EXPECT_EQ(recv(cfd, buf, sizeof(buf) / 2, MSG_WAITALL),
2752+
sizeof(buf) / 2);
27532753
exit(!__test_passed(_metadata));
27542754
}
27552755

2756-
usleep(2000);
2756+
usleep(10000);
27572757
ASSERT_EQ(setsockopt(fd, SOL_TLS, TLS_TX, &tls, tls.len), 0);
27582758
ASSERT_EQ(setsockopt(cfd, SOL_TLS, TLS_RX, &tls, tls.len), 0);
27592759

27602760
EXPECT_EQ(send(fd, buf, sizeof(buf), 0), sizeof(buf));
2761-
usleep(2000);
2761+
EXPECT_EQ(wait(&status), pid);
2762+
EXPECT_EQ(status, 0);
27622763
EXPECT_EQ(recv(cfd, buf2, sizeof(buf2), MSG_DONTWAIT), -1);
27632764
/* Don't check errno, the error will be different depending
27642765
* on what random bytes TLS interpreted as the record length.
27652766
*/
27662767

27672768
close(fd);
27682769
close(cfd);
2769-
2770-
EXPECT_EQ(wait(&status), pid);
2771-
EXPECT_EQ(status, 0);
27722770
}
27732771

27742772
static void __attribute__((constructor)) fips_check(void) {

0 commit comments

Comments
 (0)