The Trunk: NetworkTests-ul.39.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: NetworkTests-ul.39.mcz

commits-2
Levente Uzonyi uploaded a new version of NetworkTests to project The Trunk:
http://source.squeak.org/trunk/NetworkTests-ul.39.mcz

==================== Summary ====================

Name: NetworkTests-ul.39
Author: ul
Time: 3 March 2016, 11:23:05.81344 pm
UUID: 37f73354-d341-4957-99f8-a50f6891afb5
Ancestors: NetworkTests-topa.38

Hopefully fixed #testSocketReuse:
- no more image lockups
- no more lingering processes

Also added a few more asserts and descriptions to the potential failures.

=============== Diff against NetworkTests-topa.38 ===============

Item was changed:
  ----- Method: SocketTest>>testSocketReuse (in category 'tests') -----
  testSocketReuse
  "Test for SO_REUSEADDR/SO_REUSEPORT"
 
+ | udp1 udp2 sendProc recvProc  |
- | address port udp1 send1 udp2 recv2 sendProc recvProc received |
- address := #[255 255 255 255]. "broadcast"
- port := 31259.
  [
+ | 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.
- received := received + (udp2 receiveDataInto: recv2 startingAt: received + 1).
- ]
- ] fork.
  sendProc := [
  udp1 setPeer: address port: port.
+ sent := (udp1 sendSomeData: send1 startIndex: 1 count: 16 for: 1).
+ ] newProcess.
+ recvProc resume.
+ sendProc resume.
- udp1 sendData: send1 count: 16.
- ] fork.
  (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:[
- self should: [recvProc isTerminated].
- self should: [sendProc isTerminated].
- self should: [send1 = recv2].
- ] ensure:[
  udp1 destroy.
  udp2 destroy.
+ sendProc ifNotNil: [ sendProc terminate ].
+ recvProc ifNotNil: [ recvProc terminate ]
  ].
  !