diff options
| author | Andy Wingo <wingo@pobox.com> | 2016-09-11 11:51:41 +0200 |
|---|---|---|
| committer | Andy Wingo <wingo@pobox.com> | 2016-09-11 11:51:41 +0200 |
| commit | 09a7af89102eedc64e9116dd7994a9b6483ab5f4 (patch) | |
| tree | 88d50525b04fb279f9e29cdd986284d009996010 | |
| parent | Add initial channels tests (diff) | |
| download | guile-fibers-09a7af89102eedc64e9116dd7994a9b6483ab5f4.tar.gz | |
Sleep duration test
* tests/basic.scm (check-sleep): Add sleep duration test.
| -rw-r--r-- | tests/basic.scm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/basic.scm b/tests/basic.scm index 6709b7c..1e1ab24 100644 --- a/tests/basic.scm +++ b/tests/basic.scm @@ -141,7 +141,19 @@ (assert-run-fibers-returns (75025) (rpc-fib 24)) -;; sleep durations +(define (check-sleep timeout) + (spawn-fiber (lambda () + (let ((start (get-internal-real-time))) + (sleep timeout) + (let ((elapsed (/ (- (get-internal-real-time) start) + 1.0 internal-time-units-per-second))) + (format #t "assert sleep ~as < actual ~as: ~a (diff: ~a%)\n" + timeout elapsed (<= timeout elapsed) + (* 100 (/ (- elapsed timeout) timeout))) + (set! failed? (< elapsed timeout))))))) + +(assert-run-fibers-terminates + (do-times 20 (check-sleep (random 1.0)))) ;; timed channel wait |
