From ecc7987427a32fb0748de05bcca0b65fb16a3b26 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 26 Mar 2014 10:47:40 +0100 Subject: [PATCH] Sloppier matching in setitimer tests * test-suite/tests/signals.test: Update setitimer tests to sloppily match both times -- it seems that the interval can also be sloppy on some platforms, sadly. --- test-suite/tests/signals.test | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/test-suite/tests/signals.test b/test-suite/tests/signals.test index ec1c4152d..ef61aaa83 100644 --- a/test-suite/tests/signals.test +++ b/test-suite/tests/signals.test @@ -29,6 +29,11 @@ ) +(define (time-pair->secs secs-usecs-pair) + (match secs-usecs-pair + ((secs . usecs) + (+ secs (/ usecs 1e6))))) + (when (defined? 'setitimer) (with-test-prefix "setitimer" (with-test-prefix "current itimers are 0" @@ -48,12 +53,13 @@ '((0 . 0) (0 . 0)))) (pass-if "reset to zero" (match (setitimer ITIMER_PROF 0 0 0 0) - (((1 . 0) (val-secs . val-usecs)) + ((interval value) ;; We don't presume that the timer is strictly lower than the ;; value at which we set it, given its limited internal ;; precision. Assert instead that the timer is between 2 and ;; 3.5 seconds. - (<= #e2e6 (+ (* val-secs #e1e6) val-usecs) #e3.5e6))))) + (and (<= 0.9 (time-pair->secs interval) 1.1) + (<= 2.0 (time-pair->secs value) 3.5)))))) (with-test-prefix "usecs > 1e6" (pass-if "initial setting" @@ -61,10 +67,13 @@ '((0 . 0) (0 . 0)))) (pass-if "reset to zero" (match (setitimer ITIMER_PROF 0 0 0 0) - (((1 . 0) (val-secs . val-usecs)) + ((interval value) ;; We don't presume that the timer is strictly lower than the ;; value at which we set it, given its limited internal ;; precision. Assert instead that the timer is between 2 and ;; 3.5 seconds. - (and (<= #e2e6 (+ (* val-secs #e1e6) val-usecs) #e3.5e6) - (<= 0 val-usecs 999999)))))))) + (and (<= 0.9 (time-pair->secs interval) 1.1) + (<= 2.0 (time-pair->secs value) 3.5) + (match value + ((secs . usecs) + (<= 0 usecs 999999))))))))))