]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vsock/test: check also expected errno on sigpipe test
authorStefano Garzarella <sgarzare@redhat.com>
Wed, 14 May 2025 14:19:27 +0000 (16:19 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 17 May 2025 01:01:32 +0000 (18:01 -0700)
In the sigpipe test, we expect send() to fail, but we do not check if
send() fails with the errno we expect (EPIPE).

Add this check and repeat the send() in case of EINTR as we do in other
tests.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20250514141927.159456-4-sgarzare@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/vsock/vsock_test.c

index 920867b17965cdf76d9d3eb4938cc387e99facaf..9ea33b78b9fcb532f4f9616b38b4d2b627b04d31 100644 (file)
@@ -1075,7 +1075,7 @@ static void test_stream_check_sigpipe(int fd)
        timeout_begin(TIMEOUT);
        while(1) {
                res = send(fd, "A", 1, 0);
-               if (res == -1)
+               if (res == -1 && errno != EINTR)
                        break;
 
                /* Sleep a little before trying again to avoid flooding the
@@ -1087,6 +1087,10 @@ static void test_stream_check_sigpipe(int fd)
        }
        timeout_end();
 
+       if (errno != EPIPE) {
+               fprintf(stderr, "unexpected send(2) errno %d\n", errno);
+               exit(EXIT_FAILURE);
+       }
        if (!have_sigpipe) {
                fprintf(stderr, "SIGPIPE expected\n");
                exit(EXIT_FAILURE);
@@ -1097,7 +1101,7 @@ static void test_stream_check_sigpipe(int fd)
        timeout_begin(TIMEOUT);
        while(1) {
                res = send(fd, "A", 1, MSG_NOSIGNAL);
-               if (res == -1)
+               if (res == -1 && errno != EINTR)
                        break;
 
                timeout_usleep(SEND_SLEEP_USEC);
@@ -1105,6 +1109,10 @@ static void test_stream_check_sigpipe(int fd)
        }
        timeout_end();
 
+       if (errno != EPIPE) {
+               fprintf(stderr, "unexpected send(2) errno %d\n", errno);
+               exit(EXIT_FAILURE);
+       }
        if (have_sigpipe) {
                fprintf(stderr, "SIGPIPE not expected\n");
                exit(EXIT_FAILURE);