1 ;;;; arbiters.test --- test arbiters functions -*- scheme -*-
3 ;;;; Copyright (C) 2004, 2006 Free Software Foundation, Inc.
5 ;;;; This library is free software; you can redistribute it and/or
6 ;;;; modify it under the terms of the GNU Lesser General Public
7 ;;;; License as published by the Free Software Foundation; either
8 ;;;; version 2.1 of the License, or (at your option) any later version.
10 ;;;; This library is distributed in the hope that it will be useful,
11 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ;;;; Lesser General Public License for more details.
15 ;;;; You should have received a copy of the GNU Lesser General Public
16 ;;;; License along with this library; if not, write to the Free Software
17 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 (define-module (test-suite test-arbiters)
20 #:use-module (test-suite lib))
26 (with-test-prefix "arbiter display"
27 ;; nothing fancy, just exercise the printing code
29 (pass-if "never locked"
30 (let ((arb (make-arbiter "foo"))
31 (port (open-output-string)))
36 (let ((arb (make-arbiter "foo"))
37 (port (open-output-string)))
43 (let ((arb (make-arbiter "foo"))
44 (port (open-output-string)))
54 (with-test-prefix "try-arbiter"
57 (let ((arb (make-arbiter "foo")))
60 (pass-if "already locked"
61 (let ((arb (make-arbiter "foo")))
63 (not (try-arbiter arb))))
65 (pass-if "already locked twice"
66 (let ((arb (make-arbiter "foo")))
69 (not (try-arbiter arb)))))
75 (with-test-prefix "release-arbiter"
78 (let ((arb (make-arbiter "foo")))
80 (release-arbiter arb)))
82 (pass-if "never locked"
83 (let ((arb (make-arbiter "foo")))
84 (not (release-arbiter arb))))
86 (pass-if "never locked twice"
87 (let ((arb (make-arbiter "foo")))
89 (not (release-arbiter arb))))
91 (pass-if "already unlocked"
92 (let ((arb (make-arbiter "foo")))
95 (not (release-arbiter arb))))
97 (pass-if "already unlocked twice"
98 (let ((arb (make-arbiter "foo")))
100 (release-arbiter arb)
101 (release-arbiter arb)
102 (not (release-arbiter arb)))))