From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: [PULL 2/7] tests/unit/test-iov: Fix timeout problem on NetBSD and OpenBSD
Date: Wed, 24 Jan 2024 11:42:26 +0100 [thread overview]
Message-ID: <20240124104231.603418-3-thuth@redhat.com> (raw)
In-Reply-To: <20240124104231.603418-1-thuth@redhat.com>
The test-iov code uses usleep() with small values (<= 30) in some
nested loops with many iterations. This causes a small delay on OSes
like Linux that have a precise sleeping mechanism, but on systems
like NetBSD and OpenBSD, each usleep() call takes multiple microseconds,
which then sum up in a total test time of multiple minutes!
Looking at the code, the usleep() does not really seem to be necessary
here - if not enough data could be send, we should simply always use
select() to wait 'til we can send more. Thus remove the usleep() and
re-arrange the code a little bit to make it more clear what is going
on here.
Suggested-by: "Daniel P. Berrangé" <berrange@redhat.com>
Message-ID: <20240122153347.71654-1-thuth@redhat.com>
Reviewed-by: "Daniel P. Berrangé" <berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/unit/test-iov.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/tests/unit/test-iov.c b/tests/unit/test-iov.c
index 6f7623d310..75bc3be005 100644
--- a/tests/unit/test-iov.c
+++ b/tests/unit/test-iov.c
@@ -197,15 +197,17 @@ static void test_io(void)
s = g_test_rand_int_range(0, j - k + 1);
r = iov_send(sv[1], iov, niov, k, s);
g_assert(memcmp(iov, siov, sizeof(*iov)*niov) == 0);
- if (r >= 0) {
- k += r;
- usleep(g_test_rand_int_range(0, 30));
- } else if (errno == EAGAIN) {
- select(sv[1]+1, NULL, &fds, NULL, NULL);
- continue;
- } else {
- perror("send");
- exit(1);
+ if (r < 0) {
+ if (errno == EAGAIN) {
+ r = 0;
+ } else {
+ perror("send");
+ exit(1);
+ }
+ }
+ k += r;
+ if (k < j) {
+ select(sv[1] + 1, NULL, &fds, NULL, NULL);
}
} while(k < j);
}
--
2.43.0
next prev parent reply other threads:[~2024-01-24 10:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-24 10:42 [PULL 0/7] Test timeout fixes and URI code clean up Thomas Huth
2024-01-24 10:42 ` [PULL 1/7] tests/qtest: Bump timeout of the boot-serial-test to 360 seconds Thomas Huth
2024-01-24 10:42 ` Thomas Huth [this message]
2024-01-24 10:42 ` [PULL 3/7] tests/qtest: Bump timeouts of boot_sector_test()-based tests to 610 seconds Thomas Huth
2024-01-24 10:42 ` [PULL 4/7] util/uri: Remove uri_string_unescape() Thomas Huth
2024-01-24 10:42 ` [PULL 5/7] util/uri: Remove unused functions uri_resolve() and uri_resolve_relative() Thomas Huth
2024-01-24 10:42 ` [PULL 6/7] util/uri: Remove the uri_string_escape() function Thomas Huth
2024-01-24 10:42 ` [PULL 7/7] util/uri: Remove unused macros ISA_RESERVED() and ISA_GEN_DELIM() Thomas Huth
2024-01-25 15:11 ` [PULL 0/7] Test timeout fixes and URI code clean up Peter Maydell
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 \
--in-reply-to=20240124104231.603418-3-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.