2008-04-02 19:25:33 -04:00
|
|
|
USING: tools.test concurrency.distributed kernel io.files
|
2010-09-19 22:39:14 -04:00
|
|
|
io.files.temp io.directories arrays io.sockets system calendar
|
2008-12-15 04:33:04 -05:00
|
|
|
combinators threads math sequences concurrency.messaging
|
2010-09-27 20:12:33 -04:00
|
|
|
continuations accessors prettyprint io.servers ;
|
2009-05-16 01:29:21 -04:00
|
|
|
FROM: concurrency.messaging => receive send ;
|
2009-08-13 20:21:44 -04:00
|
|
|
IN: concurrency.distributed.tests
|
2008-04-02 19:25:33 -04:00
|
|
|
|
2010-09-19 22:39:14 -04:00
|
|
|
CONSTANT: test-ip "127.0.0.1"
|
|
|
|
|
|
|
|
: test-node-server ( -- threaded-server )
|
|
|
|
{
|
|
|
|
{ [ os unix? ] [ "distributed-concurrency-test" temp-file <local> ] }
|
|
|
|
{ [ os windows? ] [ test-ip 0 <inet4> ] }
|
|
|
|
} cond <node-server> ;
|
|
|
|
|
|
|
|
: test-node-client ( -- addrspec )
|
2008-04-02 19:25:33 -04:00
|
|
|
{
|
|
|
|
{ [ os unix? ] [ "distributed-concurrency-test" temp-file <local> ] }
|
2010-10-03 04:39:30 -04:00
|
|
|
{ [ os windows? ] [ insecure-addr ] }
|
2008-04-02 19:25:33 -04:00
|
|
|
} cond ;
|
|
|
|
|
2010-09-19 22:39:14 -04:00
|
|
|
|
2008-04-02 19:25:33 -04:00
|
|
|
[ ] [ [ "distributed-concurrency-test" temp-file delete-file ] ignore-errors ] unit-test
|
|
|
|
|
2010-09-19 22:39:14 -04:00
|
|
|
test-node-server [
|
|
|
|
[ ] [
|
|
|
|
[
|
|
|
|
receive first2 [ 3 + ] dip send
|
|
|
|
"thread-a" unregister-remote-thread
|
|
|
|
] "Thread A" spawn
|
|
|
|
"thread-a" register-remote-thread
|
|
|
|
] unit-test
|
2008-04-02 19:25:33 -04:00
|
|
|
|
2010-09-19 22:39:14 -04:00
|
|
|
[ 8 ] [
|
|
|
|
5 self 2array
|
|
|
|
test-node-client "thread-a" <remote-thread> send
|
|
|
|
100 seconds receive-timeout
|
|
|
|
] unit-test
|
2010-09-27 20:12:33 -04:00
|
|
|
] with-threaded-server
|