]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests: tls: use ASSERT_GE in test_mutliproc
authorGeliang Tang <tanggeliang@kylinos.cn>
Thu, 21 May 2026 09:11:53 +0000 (17:11 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 22 May 2026 22:36:51 +0000 (15:36 -0700)
In test_mutliproc(), when send() or recv() returns an error (e.g.,
-1), the test continues to execute the remaining code and fails
repeatedly due to using EXPECT_GE.

For example, if a TLS connection is broken and recv() returns -1,
EXPECT_GE(res, 0) records a failure but does not stop the test.
The test then proceeds with left -= res (where res = -1), causing
left to increase unexpectedly, and the loop continues indefinitely.

This results in a massive number of identical failure messages:

 # tls.c:1686:mutliproc_sendpage_writers:Expected res (-1) >= 0 (0)
 # tls.c:1686:mutliproc_sendpage_writers:Expected res (-1) >= 0 (0)
 ... (hundreds of identical failures)

Fix this by replacing EXPECT_GE with ASSERT_GE. When send() or recv()
fails, ASSERT_GE immediately aborts the current test, preventing
the subsequent undefined behavior and endless failure messages.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Link: https://patch.msgid.link/0ee9f412b6bd1a260a547d19f979f73b396746ac.1779354585.git.tanggeliang@kylinos.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/tls.c

index 30a236b8e9f733ff34dd21d95cb62c8c58bc7ecc..9b9a3cb2700d1bc54d37e1f08e138127563f6fa0 100644 (file)
@@ -1549,7 +1549,7 @@ test_mutliproc(struct __test_metadata *_metadata, struct _test_data_tls *self,
                        res = recv(self->cfd, rb,
                                   left > sizeof(rb) ? sizeof(rb) : left, 0);
 
-                       EXPECT_GE(res, 0);
+                       ASSERT_GE(res, 0);
                        left -= res;
                }
        } else {
@@ -1566,7 +1566,7 @@ test_mutliproc(struct __test_metadata *_metadata, struct _test_data_tls *self,
                                res = send(self->fd, buf,
                                           left > file_sz ? file_sz : left, 0);
 
-                       EXPECT_GE(res, 0);
+                       ASSERT_GE(res, 0);
                        left -= res;
                }
        }