]> gitweb.factorcode.org Git - factor.git/blob - basis/concurrency/distributed/distributed-tests.factor
Squashed commit of the following:
[factor.git] / basis / concurrency / distributed / distributed-tests.factor
1 USING: tools.test concurrency.distributed kernel io.files
2 io.files.temp io.directories arrays io.sockets system calendar
3 combinators threads math sequences concurrency.messaging
4 continuations accessors prettyprint io.servers ;
5 FROM: concurrency.messaging => receive send ;
6 IN: concurrency.distributed.tests
7
8 CONSTANT: test-ip "127.0.0.1"
9
10 : test-node-server ( -- threaded-server )
11     {
12         { [ os unix? ] [ "distributed-concurrency-test" temp-file <local> ] }
13         { [ os windows? ] [ test-ip 0 <inet4> ] }
14     } cond <node-server> ;
15
16 : test-node-client ( -- addrspec )
17     {
18         { [ os unix? ] [ "distributed-concurrency-test" temp-file <local> ] }
19         { [ os windows? ] [ test-ip insecure-port <inet4> ] }
20     } cond ;
21
22     
23 [ ] [ [ "distributed-concurrency-test" temp-file delete-file ] ignore-errors ] unit-test
24
25 test-node-server [
26     [ ] [
27         [
28             receive first2 [ 3 + ] dip send
29             "thread-a" unregister-remote-thread
30         ] "Thread A" spawn
31         "thread-a" register-remote-thread
32     ] unit-test
33
34     [ 8 ] [
35         5 self 2array
36         test-node-client "thread-a" <remote-thread> send
37         100 seconds receive-timeout
38     ] unit-test
39 ] with-threaded-server