[Pkg] The Trunk: NetworkTests-ul.40.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Mar 4 19:17:38 UTC 2016
Levente Uzonyi uploaded a new version of NetworkTests to project The Trunk:
http://source.squeak.org/trunk/NetworkTests-ul.40.mcz
==================== Summary ====================
Name: NetworkTests-ul.40
Author: ul
Time: 4 March 2016, 8:17:26.370392 pm
UUID: caffaf06-2201-4e88-8873-3c3337820a8b
Ancestors: NetworkTests-ul.39
- those extra assertions in#testSocketReuse might fail before the sockets are properly initialized, so check that in the argument block of #ensure:
=============== Diff against NetworkTests-ul.39 ===============
Item was changed:
----- Method: SocketTest>>testSocketReuse (in category 'tests') -----
testSocketReuse
"Test for SO_REUSEADDR/SO_REUSEPORT"
| udp1 udp2 sendProc recvProc |
[
| address port send1 recv2 received sent |
address := #[255 255 255 255]. "broadcast"
port := 31259.
udp1 := Socket newUDP.
udp1 setOption: 'SO_REUSEADDR' value: 1.
self assert: 0 equals: udp1 socketError description: 'Error occured while setting SO_REUSEADDR'.
self assert: #(0 1) equals: (udp1 getOption: 'SO_REUSEADDR') description: 'SO_REUSEADDR couldn''t be set'.
udp1 setOption: 'SO_REUSEPORT' value: 1.
self assert: 0 equals: udp1 socketError description: 'Error occured while setting SO_REUSEPORT'.
self assert: #(0 1) equals: (udp1 getOption: 'SO_REUSEPORT') description: 'SO_REUSEPORT couldn''t be set'.
udp1 setPort: port.
self assert: port equals: udp1 localPort.
udp1 setOption: 'SO_BROADCAST' value: 1.
send1 := UUID new.
udp2 := Socket newUDP.
udp2 setOption: 'SO_REUSEADDR' value: 1.
self assert: 0 equals: udp2 socketError.
udp2 setOption: 'SO_REUSEPORT' value: 1.
self assert: 0 equals: udp2 socketError.
udp2 setPort: port.
self assert: port equals: udp2 localPort.
udp2 setOption: 'SO_BROADCAST' value: 1.
recv2 := UUID new.
received := 0.
recvProc := [
[received < 16] whileTrue:[
received := received + (udp2 receiveDataInto: recv2 startingAt: received + 1)
"No need to yield here, because #receiveDataInto:startingAt: will either wait on the readSemaphore of the socket or signal an error." ]
] newProcess.
sendProc := [
udp1 setPeer: address port: port.
sent := (udp1 sendSomeData: send1 startIndex: 1 count: 16 for: 1).
] newProcess.
recvProc resume.
sendProc resume.
(Delay forMilliseconds: 200) wait.
self
assert: sendProc isTerminated description: 'sendProc hasn''t terminated till the deadline';
assert: recvProc isTerminated description: 'recvProc hasn''t terminated till the deadline';
assert: 16 equals: sent description: ('{1} bytes were sent instead of 16' format: { sent });
assert: send1 equals: recv2 description: 'sent and received bytes differ'
] ensure:[
+ udp1 ifNotNil: [ udp1 destroy ].
+ udp2 ifNotNil: [ udp2 destroy ].
- udp1 destroy.
- udp2 destroy.
sendProc ifNotNil: [ sendProc terminate ].
recvProc ifNotNil: [ recvProc terminate ]
].
!
More information about the Packages
mailing list