[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 20/21] tests: use g_usleep instead of rem = sleep(tim
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PULL 20/21] tests: use g_usleep instead of rem = sleep(time) |
Date: |
Mon, 14 Jan 2019 15:01:28 +0000 |
Relying on sleep to always return having slept isn't safe as a signal
may have occurred. If signals are constantly incoming the program will
never reach its termination condition. This is believed to be the
mechanism causing time outs for qht-test in Travis.
The glib g_usleep() deals with all of this for us so lets use it instead.
Signed-off-by: Alex Bennée <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
diff --git a/tests/atomic64-bench.c b/tests/atomic64-bench.c
index 71692560ed..121a8c14f4 100644
--- a/tests/atomic64-bench.c
+++ b/tests/atomic64-bench.c
@@ -74,16 +74,14 @@ static void *thread_func(void *arg)
static void run_test(void)
{
- unsigned int remaining;
unsigned int i;
while (atomic_read(&n_ready_threads) != n_threads) {
cpu_relax();
}
+
atomic_set(&test_start, true);
- do {
- remaining = sleep(duration);
- } while (remaining);
+ g_usleep(duration * G_USEC_PER_SEC);
atomic_set(&test_stop, true);
for (i = 0; i < n_threads; i++) {
diff --git a/tests/atomic_add-bench.c b/tests/atomic_add-bench.c
index 2f6c72f63a..5666f6bbff 100644
--- a/tests/atomic_add-bench.c
+++ b/tests/atomic_add-bench.c
@@ -76,16 +76,14 @@ static void *thread_func(void *arg)
static void run_test(void)
{
- unsigned int remaining;
unsigned int i;
while (atomic_read(&n_ready_threads) != n_threads) {
cpu_relax();
}
+
atomic_set(&test_start, true);
- do {
- remaining = sleep(duration);
- } while (remaining);
+ g_usleep(duration * G_USEC_PER_SEC);
atomic_set(&test_stop, true);
for (i = 0; i < n_threads; i++) {
diff --git a/tests/qht-bench.c b/tests/qht-bench.c
index ab4e708180..e3b512f26f 100644
--- a/tests/qht-bench.c
+++ b/tests/qht-bench.c
@@ -398,16 +398,14 @@ static void pr_stats(void)
static void run_test(void)
{
- unsigned int remaining;
int i;
while (atomic_read(&n_ready_threads) != n_rw_threads + n_rz_threads) {
cpu_relax();
}
+
atomic_set(&test_start, true);
- do {
- remaining = sleep(duration);
- } while (remaining);
+ g_usleep(duration * G_USEC_PER_SEC);
atomic_set(&test_stop, true);
for (i = 0; i < n_rw_threads; i++) {
--
2.17.1
- [Qemu-devel] [PULL 00/21] misc testing fixes for Travis and docker, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 03/21] tests: remove obsolete 'debian' dockerfile, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 06/21] tests: use in-place sed magic for enabling deb-src in travis image, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 04/21] tests: update Fedora dockerfile to use Fedora 29, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 07/21] travis: add whitespace between each major section & matrix entry, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 01/21] docker: Use stable git tag for virglrenderer, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 05/21] tests: update Fedora i386 cross image to Fedora 29, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 08/21] travis: define all the build matrix entries in one place, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 20/21] tests: use g_usleep instead of rem = sleep(time),
Alex Bennée <=
- [Qemu-devel] [PULL 09/21] travis: standardize the syntax used for env variables, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 15/21] travis: remove matrix settings that duplicate global settings, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 10/21] travis: don't clone git submodules upfront, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 02/21] tests: run ldconfig after installing extra software, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 12/21] travis: stop redefining the script commands, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 19/21] tests/docker: remove SID_AGE test hack, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 14/21] travis: run tests in verbose mode, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 18/21] tests/docker: update our Travis image, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 13/21] travis: stop using container based envs, Alex Bennée, 2019/01/14
- [Qemu-devel] [PULL 21/21] Revert "tests: Disable qht-bench parallel test when using gprof", Alex Bennée, 2019/01/14