Enable all tests.

Adding more iterations for UDP stream test.
Fixed bugs in TCP stream.
This commit is contained in:
cheatfate 2018-05-22 18:21:58 +03:00
parent d0b88b939d
commit d28e4d0c49
4 changed files with 22 additions and 21 deletions

View File

@ -21,3 +21,7 @@ task test, "Run all tests":
exec "nim c -r -d:useSysAssert -d:useGcAssert tests/testdatagram"
exec "nim c -r tests/testdatagram"
exec "nim c -r -d:release tests/testdatagram"
exec "nim c -r -d:useSysAssert -d:useGcAssert tests/teststream"
exec "nim c -r tests/teststream"
exec "nim c -r -d:release tests/teststream"

View File

@ -456,12 +456,18 @@ when defined(windows):
wserver.domain = server.local.address.getDomain()
await server.actEvent.wait()
server.actEvent.clear()
var acceptFut: Future[AsyncFD]
if server.action == ServerCommand.Start:
var eventFut = server.actEvent.wait()
while true:
var acceptFut = acceptAddr(wserver)
await eventFut or acceptFut
if server.status in {Paused}:
await eventFut
else:
acceptFut = acceptAddr(wserver)
await eventFut or acceptFut
if eventFut.finished:
server.actEvent.clear()
eventFut = server.actEvent.wait()
if server.action == ServerCommand.Start:
if server.status in {Stopped, Paused}:
server.status = Running
@ -475,6 +481,7 @@ when defined(windows):
elif server.action == ServerCommand.Pause:
if server.status in {Running}:
server.status = Paused
if acceptFut.finished:
if not acceptFut.failed:
var sock = acceptFut.read()

View File

@ -10,9 +10,9 @@ import strutils, net, unittest
import ../asyncdispatch2
const
TestsCount = 10000
TestsCount = 100000
ClientsCount = 100
MessagesCount = 100
MessagesCount = 1000
proc client1(transp: DatagramTransport, pbytes: pointer, nbytes: int,
raddr: TransportAddress, udata: pointer): Future[void] {.async.} =
@ -46,9 +46,7 @@ proc client2(transp: DatagramTransport, pbytes: pointer, nbytes: int,
if counterPtr[] == TestsCount:
transp.close()
else:
var ta: TransportAddress
ta.address = parseIpAddress("127.0.0.1")
ta.port = Port(33336)
var ta = strAddress("127.0.0.1:33336")
var req = "REQUEST" & $counterPtr[]
await transp.sendTo(addr req[0], len(req), ta)
else:
@ -121,9 +119,7 @@ proc client5(transp: DatagramTransport, pbytes: pointer, nbytes: int,
if counterPtr[] == MessagesCount:
transp.close()
else:
var ta: TransportAddress
ta.address = parseIpAddress("127.0.0.1")
ta.port = Port(33337)
var ta = strAddress("127.0.0.1:33337")
var req = "REQUEST" & $counterPtr[]
await transp.sendTo(addr req[0], len(req), ta)
else:
@ -137,10 +133,8 @@ proc client5(transp: DatagramTransport, pbytes: pointer, nbytes: int,
transp.close()
proc test1(): Future[int] {.async.} =
var ta: TransportAddress
var ta = strAddress("127.0.0.1:33336")
var counter = 0
ta.address = parseIpAddress("127.0.0.1")
ta.port = Port(33336)
var dgram1 = newDatagramTransport(client1, udata = addr counter, local = ta)
var dgram2 = newDatagramTransport(client2, udata = addr counter)
var data = "REQUEST0"
@ -150,10 +144,8 @@ proc test1(): Future[int] {.async.} =
result = counter
proc test2(): Future[int] {.async.} =
var ta: TransportAddress
var ta = strAddress("127.0.0.1:33337")
var counter = 0
ta.address = parseIpAddress("127.0.0.1")
ta.port = Port(33337)
var dgram1 = newDatagramTransport(client1, udata = addr counter, local = ta)
var dgram2 = newDatagramTransport(client3, udata = addr counter, remote = ta)
var data = "REQUEST0"
@ -174,9 +166,7 @@ proc waitAll(futs: seq[Future[void]]): Future[void] =
return retFuture
proc test3(bounded: bool): Future[int] {.async.} =
var ta: TransportAddress
ta.address = parseIpAddress("127.0.0.1")
ta.port = Port(33337)
var ta = strAddress("127.0.0.1:33337")
var counter = 0
var dgram1 = newDatagramTransport(client1, udata = addr counter, local = ta)
var clients = newSeq[Future[void]](ClientsCount)

View File

@ -15,8 +15,8 @@ else:
import posix
const
ClientsCount = 50
MessagesCount = 50
ClientsCount = 100
MessagesCount = 100
MessageSize = 20
FilesCount = 50
FilesTestName = "tests/teststream.nim"