Eliot Miranda uploaded a new version of NetworkTests to project The Trunk:
http://source.squeak.org/trunk/NetworkTests-eem.41.mcz ==================== Summary ==================== Name: NetworkTests-eem.41 Author: eem Time: 28 March 2016, 3:28:59.175834 pm UUID: edf75dc3-4a00-4751-9db5-427ba6e5687a Ancestors: NetworkTests-ul.40 Improve testSocketReuse. It seems correct that the SocketPlugin answers whatever bit things like SO_REUSEADDR set in underlying socket fields, not the 1 that the test expects. e.g. on Mac OS X Socket newUDP setOption: 'SO_REUSEADDR' value: 1; getOption: 'SO_REUSEADDR' answers #(0 4), not #(0 1) =============== Diff against NetworkTests-ul.40 =============== Item was changed: ----- Method: SocketTest>>testSocketReuse (in category 'tests') ----- testSocketReuse "Test for SO_REUSEADDR/SO_REUSEPORT" | udp1 udp2 sendProc recvProc | [ + | address port opt send1 recv2 received sent | - | 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'. + opt := udp1 getOption: 'SO_REUSEADDR'. + self assert: opt first isZero & opt last isZero not description: 'SO_REUSEADDR couldn''t be set'. - 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'. + opt := udp1 getOption: 'SO_REUSEPORT'. + self assert: opt first isZero & opt last isZero not description: 'SO_REUSEPORT couldn''t be set'. - 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 ]. sendProc ifNotNil: [ sendProc terminate ]. recvProc ifNotNil: [ recvProc terminate ] ]. ! |
Free forum by Nabble | Edit this page |