io.sockets.secure.unix: Stop these tests from hanging on errors.

Specifically, the server writes its port to a mailbox. On Mac 10.11.6, the last macOS for my old computers, TLS1.0 is the last supported SSL protocol, and there is a yet-undebugged error. This patch at least exposes the error for debugging.
factor-shell
Doug Coleman 2017-12-17 18:49:52 -06:00
parent 02a9bbefe7
commit 7d8fe2b54c
1 changed files with 19 additions and 12 deletions

View File

@ -1,15 +1,16 @@
USING: accessors calendar classes
concurrency.promises destructors io io.backend.unix
io.encodings.ascii io.sockets io.sockets.secure
io.sockets.secure.debug io.streams.duplex io.timeouts kernel
locals namespaces threads tools.test ;
IN: io.sockets.secure.tests
USING: accessors kernel namespaces io io.sockets
io.sockets.secure io.encodings.ascii io.streams.duplex
io.backend.unix classes words destructors threads tools.test
concurrency.promises byte-arrays locals calendar io.timeouts
io.sockets.secure.debug ;
QUALIFIED-WITH: concurrency.messaging qm
{ 1 0 } [ [ ] with-secure-context ] must-infer-as
{ } [ <promise> "port" set ] unit-test
:: server-test ( quot -- )
:: server-test ( quot -- obj/f )
[
[
"127.0.0.1" 0 <inet4> f <secure> ascii <server> [
@ -19,13 +20,19 @@ io.sockets.secure.debug ;
] curry with-stream
] with-disposal
] with-test-context
] "SSL server test" spawn drop ;
] "SSL server test" qm:spawn-linked drop qm:receive ;
: ?promise-test ( mailbox -- obj )
340 milliseconds ?promise-timeout ;
: client-test ( -- string )
<secure-config> [
"127.0.0.1" "port" get ?promise <inet4> f <secure> ascii <client> drop stream-contents
"127.0.0.1" "port" get ?promise-test <inet4> f <secure> ascii <client> drop
1 seconds
[ stream-contents ] with-timeout*
] with-secure-context ;
! { } [ [ class-of name>> write "done" my-mailbox mailbox-put ] server-test ] unit-test
{ } [ [ class-of name>> write ] server-test ] unit-test
{ "secure" } [ client-test ] unit-test
@ -55,7 +62,7 @@ io.sockets.secure.debug ;
[
<secure-config> [
"localhost" "port" get ?promise <inet> f <secure> ascii
"localhost" "port" get ?promise-test <inet> f <secure> ascii
<client> drop dispose
] with-secure-context
] [ certificate-verify-error? ] must-fail-with
@ -85,7 +92,7 @@ io.sockets.secure.debug ;
{ } [
[
[
"127.0.0.1" "port" get ?promise
"127.0.0.1" "port" get ?promise-test
<inet4> ascii <client> drop &dispose 1 minutes sleep
] with-destructors
] "Silly client" spawn drop
@ -126,7 +133,7 @@ io.sockets.secure.debug ;
[
1 seconds secure-socket-timeout [
<secure-config> [
"127.0.0.1" "port" get ?promise <inet4> f <secure>
"127.0.0.1" "port" get ?promise-test <inet4> f <secure>
ascii <client> drop dispose
] with-secure-context
] with-variable
@ -139,7 +146,7 @@ io.sockets.secure.debug ;
[
[
[
"127.0.0.1" "port" get ?promise
"127.0.0.1" "port" get ?promise-test
<inet4> f <secure> ascii <client> drop &dispose 1 minutes sleep
] with-test-context
] with-destructors