[PATCH 20/22] selftests/coredump: ignore ENOSPC errors

Christian Brauner posted 22 patches 3 months, 1 week ago
[PATCH 20/22] selftests/coredump: ignore ENOSPC errors
Posted by Christian Brauner 3 months, 1 week ago
If we crash multiple processes at the same time we may run out of space.
Just ignore those errors. They're not actually all that relevant for the
test.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 tools/testing/selftests/coredump/coredump_socket_protocol_test.c | 4 ++++
 tools/testing/selftests/coredump/coredump_socket_test.c          | 5 +++--
 tools/testing/selftests/coredump/coredump_test_helpers.c         | 2 ++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/coredump/coredump_socket_protocol_test.c b/tools/testing/selftests/coredump/coredump_socket_protocol_test.c
index 566545e96d7f..d19b6717c53e 100644
--- a/tools/testing/selftests/coredump/coredump_socket_protocol_test.c
+++ b/tools/testing/selftests/coredump/coredump_socket_protocol_test.c
@@ -184,6 +184,8 @@ TEST_F(coredump, socket_request_kernel)
 
 			bytes_write = write(fd_core_file, buffer, bytes_read);
 			if (bytes_read != bytes_write) {
+				if (bytes_write < 0 && errno == ENOSPC)
+					continue;
 				fprintf(stderr, "socket_request_kernel: write to core file failed (read=%zd, write=%zd): %m\n",
 					bytes_read, bytes_write);
 				goto out;
@@ -1366,6 +1368,8 @@ TEST_F_TIMEOUT(coredump, socket_multiple_crashing_coredumps, 500)
 
 				bytes_write = write(fd_core_file, buffer, bytes_read);
 				if (bytes_read != bytes_write) {
+					if (bytes_write < 0 && errno == ENOSPC)
+						continue;
 					fprintf(stderr, "write failed for fd %d: %m\n", fd_core_file);
 					goto out;
 				}
diff --git a/tools/testing/selftests/coredump/coredump_socket_test.c b/tools/testing/selftests/coredump/coredump_socket_test.c
index 0a37d0456672..da558a0e37aa 100644
--- a/tools/testing/selftests/coredump/coredump_socket_test.c
+++ b/tools/testing/selftests/coredump/coredump_socket_test.c
@@ -158,8 +158,9 @@ TEST_F(coredump, socket)
 
 			bytes_write = write(fd_core_file, buffer, bytes_read);
 			if (bytes_read != bytes_write) {
-				fprintf(stderr, "socket test: write to core file failed (read=%zd, write=%zd): %m\n",
-					bytes_read, bytes_write);
+				if (bytes_write < 0 && errno == ENOSPC)
+					continue;
+				fprintf(stderr, "socket test: write to core file failed (read=%zd, write=%zd): %m\n", bytes_read, bytes_write);
 				goto out;
 			}
 		}
diff --git a/tools/testing/selftests/coredump/coredump_test_helpers.c b/tools/testing/selftests/coredump/coredump_test_helpers.c
index 65deb3cfbe1b..a6f6d5f2ae07 100644
--- a/tools/testing/selftests/coredump/coredump_test_helpers.c
+++ b/tools/testing/selftests/coredump/coredump_test_helpers.c
@@ -357,6 +357,8 @@ void process_coredump_worker(int fd_coredump, int fd_peer_pidfd, int fd_core_fil
 					goto done;
 				ssize_t bytes_write = write(fd_core_file, buffer, bytes_read);
 				if (bytes_write != bytes_read) {
+					if (bytes_write < 0 && errno == ENOSPC)
+						continue;
 					fprintf(stderr, "Worker: write() failed (read=%zd, write=%zd): %m\n",
 						bytes_read, bytes_write);
 					goto out;

-- 
2.47.3
Re: [PATCH 20/22] selftests/coredump: ignore ENOSPC errors
Posted by Alexander Mikhalitsyn 3 months ago
Am Di., 28. Okt. 2025 um 09:47 Uhr schrieb Christian Brauner
<brauner@kernel.org>:
>
> If we crash multiple processes at the same time we may run out of space.
> Just ignore those errors. They're not actually all that relevant for the
> test.
>
> Signed-off-by: Christian Brauner <brauner@kernel.org>

Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>

> ---
>  tools/testing/selftests/coredump/coredump_socket_protocol_test.c | 4 ++++
>  tools/testing/selftests/coredump/coredump_socket_test.c          | 5 +++--
>  tools/testing/selftests/coredump/coredump_test_helpers.c         | 2 ++
>  3 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/coredump/coredump_socket_protocol_test.c b/tools/testing/selftests/coredump/coredump_socket_protocol_test.c
> index 566545e96d7f..d19b6717c53e 100644
> --- a/tools/testing/selftests/coredump/coredump_socket_protocol_test.c
> +++ b/tools/testing/selftests/coredump/coredump_socket_protocol_test.c
> @@ -184,6 +184,8 @@ TEST_F(coredump, socket_request_kernel)
>
>                         bytes_write = write(fd_core_file, buffer, bytes_read);
>                         if (bytes_read != bytes_write) {
> +                               if (bytes_write < 0 && errno == ENOSPC)
> +                                       continue;
>                                 fprintf(stderr, "socket_request_kernel: write to core file failed (read=%zd, write=%zd): %m\n",
>                                         bytes_read, bytes_write);
>                                 goto out;
> @@ -1366,6 +1368,8 @@ TEST_F_TIMEOUT(coredump, socket_multiple_crashing_coredumps, 500)
>
>                                 bytes_write = write(fd_core_file, buffer, bytes_read);
>                                 if (bytes_read != bytes_write) {
> +                                       if (bytes_write < 0 && errno == ENOSPC)
> +                                               continue;
>                                         fprintf(stderr, "write failed for fd %d: %m\n", fd_core_file);
>                                         goto out;
>                                 }
> diff --git a/tools/testing/selftests/coredump/coredump_socket_test.c b/tools/testing/selftests/coredump/coredump_socket_test.c
> index 0a37d0456672..da558a0e37aa 100644
> --- a/tools/testing/selftests/coredump/coredump_socket_test.c
> +++ b/tools/testing/selftests/coredump/coredump_socket_test.c
> @@ -158,8 +158,9 @@ TEST_F(coredump, socket)
>
>                         bytes_write = write(fd_core_file, buffer, bytes_read);
>                         if (bytes_read != bytes_write) {
> -                               fprintf(stderr, "socket test: write to core file failed (read=%zd, write=%zd): %m\n",
> -                                       bytes_read, bytes_write);
> +                               if (bytes_write < 0 && errno == ENOSPC)
> +                                       continue;
> +                               fprintf(stderr, "socket test: write to core file failed (read=%zd, write=%zd): %m\n", bytes_read, bytes_write);
>                                 goto out;
>                         }
>                 }
> diff --git a/tools/testing/selftests/coredump/coredump_test_helpers.c b/tools/testing/selftests/coredump/coredump_test_helpers.c
> index 65deb3cfbe1b..a6f6d5f2ae07 100644
> --- a/tools/testing/selftests/coredump/coredump_test_helpers.c
> +++ b/tools/testing/selftests/coredump/coredump_test_helpers.c
> @@ -357,6 +357,8 @@ void process_coredump_worker(int fd_coredump, int fd_peer_pidfd, int fd_core_fil
>                                         goto done;
>                                 ssize_t bytes_write = write(fd_core_file, buffer, bytes_read);
>                                 if (bytes_write != bytes_read) {
> +                                       if (bytes_write < 0 && errno == ENOSPC)
> +                                               continue;
>                                         fprintf(stderr, "Worker: write() failed (read=%zd, write=%zd): %m\n",
>                                                 bytes_read, bytes_write);
>                                         goto out;
>
> --
> 2.47.3
>