diff mbox

[07/19] linux-test: fix set/getitimer returned timer check

Message ID 20161201051433.17168-8-bobby.prani@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Pranith Kumar Dec. 1, 2016, 5:14 a.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

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 <marcandre.lureau@redhat.com>
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
 tests/tcg/linux-test.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
diff mbox

Patch

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;