From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCJhh-0002qM-Vp for qemu-devel@nongnu.org; Thu, 01 Dec 2016 00:14:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCJhg-0007Ln-Um for qemu-devel@nongnu.org; Thu, 01 Dec 2016 00:14:41 -0500 Received: from mail-yw0-x241.google.com ([2607:f8b0:4002:c05::241]:34097) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cCJhg-0007L0-Nl for qemu-devel@nongnu.org; Thu, 01 Dec 2016 00:14:40 -0500 Received: by mail-yw0-x241.google.com with SMTP id a10so16751905ywa.1 for ; Wed, 30 Nov 2016 21:14:40 -0800 (PST) From: Pranith Kumar Date: Thu, 1 Dec 2016 00:14:21 -0500 Message-Id: <20161201051433.17168-8-bobby.prani@gmail.com> In-Reply-To: <20161201051433.17168-1-bobby.prani@gmail.com> References: <20161201051433.17168-1-bobby.prani@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 07/19] linux-test: fix set/getitimer returned timer check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: alex.bennee@linaro.org Cc: qemu-devel@nongnu.org, rth@twiddle.net, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-André Lureau The previous value of the timer indicates the time to the next timer expiration, which is likely not the same as when the timer was set. Signed-off-by: Marc-André Lureau Signed-off-by: Pranith Kumar --- tests/tcg/linux-test.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c index 65fca30..24fce2b 100644 --- a/tests/tcg/linux-test.c +++ b/tests/tcg/linux-test.c @@ -482,9 +482,12 @@ static void test_signal(void) it.it_value.tv_usec = 10 * 1000; chk_error(setitimer(ITIMER_REAL, &it, NULL)); chk_error(getitimer(ITIMER_REAL, &oit)); - if (oit.it_value.tv_sec != it.it_value.tv_sec || - oit.it_value.tv_usec != it.it_value.tv_usec) + if (oit.it_value.tv_sec != it.it_interval.tv_sec || + oit.it_value.tv_usec > it.it_interval.tv_usec || + oit.it_interval.tv_sec != it.it_interval.tv_sec || + oit.it_interval.tv_usec != it.it_interval.tv_usec) { error("itimer"); + } while (alarm_count < 5) { usleep(10 * 1000); @@ -497,8 +500,11 @@ static void test_signal(void) memset(&oit, 0xff, sizeof(oit)); chk_error(setitimer(ITIMER_REAL, &it, &oit)); if (oit.it_value.tv_sec != 0 || - oit.it_value.tv_usec != 10 * 1000) + oit.it_value.tv_usec > 10 * 1000 || + oit.it_interval.tv_sec != 0 || + oit.it_interval.tv_usec != 10 * 1000) { error("setitimer"); + } /* SIGSEGV test */ act.sa_sigaction = sig_segv; -- 2.10.2