1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-29 08:20:20 +02:00

Disable statprof tests on platforms that lack `ITIMER_PROF' support.

* test-suite/tests/statprof.test (when-implemented): New macro.
  ("statistical sample counts within expected range", "accurate call
  counting"): Use it.
This commit is contained in:
Ludovic Courtès 2012-01-10 21:44:32 +01:00
parent f41ef41680
commit ea3cef045a

View file

@ -31,8 +31,22 @@
#:use-module (srfi srfi-1)
#:use-module (statprof))
;; Throw `unresolved' upon ENOSYS. This is used to skip tests on
;; platforms such as GNU/Hurd where `ITIMER_PROF' is is currently
;; unimplemented.
(define-syntax-rule (when-implemented body ...)
(catch 'system-error
(lambda ()
body ...)
(lambda args
(let ((errno (system-error-errno args)))
(false-if-exception (statprof-stop))
(if (= errno ENOSYS)
(throw 'unresolved)
(apply throw args))))))
(pass-if "statistical sample counts within expected range"
(let ()
(when-implemented
;; test to see that if we call 3 identical functions equally, they
;; show up equally in the call count, +/- 30%. it's a big range, and
;; I tried to do something more statistically valid, but failed (for
@ -80,7 +94,7 @@
(throw 'unresolved (pk average drift-fraction))))))))
(pass-if "accurate call counting"
(let ()
(when-implemented
;; Test to see that if we call a function N times while the profiler
;; is active, it shows up N times.
(let ((num-calls 200))