public inbox for [email protected]
 help / color / mirror / Atom feed
From: "Dirk Müller" <[email protected]>
To: [email protected]
Cc: "Dirk Müller" <[email protected]>
Subject: [PATCH] Handle EINTR in tests
Date: Tue,  5 Jul 2022 15:29:39 +0200	[thread overview]
Message-ID: <[email protected]> (raw)

On an otherwise busy machine the test suite is quite flaky. Restart
the syscalls that are aborted with EINTR.

Signed-off-by: Dirk Müller <[email protected]>
---
 test/ce593a6c480a.c | 5 ++++-
 test/io-cancel.c    | 7 ++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/test/ce593a6c480a.c b/test/ce593a6c480a.c
index 1c5669e..4c71fbc 100644
--- a/test/ce593a6c480a.c
+++ b/test/ce593a6c480a.c
@@ -111,7 +111,10 @@ int main(int argc, char *argv[])
 			(void*) (intptr_t) other_fd);
 
 	/* Wait on the event fd for an event to be ready */
-	ret = read(loop_fd, buf, 8);
+	do {
+		ret = read(loop_fd, buf, 8);
+	} while (ret < 0 && errno == EINTR);
+
 	if (ret < 0) {
 		perror("read");
 		return T_EXIT_FAIL;
diff --git a/test/io-cancel.c b/test/io-cancel.c
index d5e3ae9..13bf84f 100644
--- a/test/io-cancel.c
+++ b/test/io-cancel.c
@@ -365,8 +365,13 @@ static int test_cancel_req_across_fork(void)
 		exit(0);
 	} else {
 		int wstatus;
+		pid_t childpid;
 
-		if (waitpid(p, &wstatus, 0) == (pid_t)-1) {
+		do {
+			childpid = waitpid(p, &wstatus, 0);
+		} while (childpid == (pid_t)-1 && errno == EINTR);
+
+		if (childpid == (pid_t)-1) {
 			perror("waitpid()");
 			return 1;
 		}
-- 
2.36.1



             reply	other threads:[~2022-07-05 13:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05 13:29 Dirk Müller [this message]
2022-07-05 14:39 ` [PATCH] Handle EINTR in tests Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox