Enable all tests.
Adding more iterations for UDP stream test. Fixed bugs in TCP stream.
This commit is contained in:
parent
d0b88b939d
commit
d28e4d0c49
|
@ -21,3 +21,7 @@ task test, "Run all tests":
|
||||||
exec "nim c -r -d:useSysAssert -d:useGcAssert tests/testdatagram"
|
exec "nim c -r -d:useSysAssert -d:useGcAssert tests/testdatagram"
|
||||||
exec "nim c -r tests/testdatagram"
|
exec "nim c -r tests/testdatagram"
|
||||||
exec "nim c -r -d:release 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"
|
||||||
|
|
|
@ -456,12 +456,18 @@ when defined(windows):
|
||||||
wserver.domain = server.local.address.getDomain()
|
wserver.domain = server.local.address.getDomain()
|
||||||
await server.actEvent.wait()
|
await server.actEvent.wait()
|
||||||
server.actEvent.clear()
|
server.actEvent.clear()
|
||||||
|
var acceptFut: Future[AsyncFD]
|
||||||
if server.action == ServerCommand.Start:
|
if server.action == ServerCommand.Start:
|
||||||
var eventFut = server.actEvent.wait()
|
var eventFut = server.actEvent.wait()
|
||||||
while true:
|
while true:
|
||||||
var acceptFut = acceptAddr(wserver)
|
if server.status in {Paused}:
|
||||||
await eventFut or acceptFut
|
await eventFut
|
||||||
|
else:
|
||||||
|
acceptFut = acceptAddr(wserver)
|
||||||
|
await eventFut or acceptFut
|
||||||
if eventFut.finished:
|
if eventFut.finished:
|
||||||
|
server.actEvent.clear()
|
||||||
|
eventFut = server.actEvent.wait()
|
||||||
if server.action == ServerCommand.Start:
|
if server.action == ServerCommand.Start:
|
||||||
if server.status in {Stopped, Paused}:
|
if server.status in {Stopped, Paused}:
|
||||||
server.status = Running
|
server.status = Running
|
||||||
|
@ -475,6 +481,7 @@ when defined(windows):
|
||||||
elif server.action == ServerCommand.Pause:
|
elif server.action == ServerCommand.Pause:
|
||||||
if server.status in {Running}:
|
if server.status in {Running}:
|
||||||
server.status = Paused
|
server.status = Paused
|
||||||
|
|
||||||
if acceptFut.finished:
|
if acceptFut.finished:
|
||||||
if not acceptFut.failed:
|
if not acceptFut.failed:
|
||||||
var sock = acceptFut.read()
|
var sock = acceptFut.read()
|
||||||
|
|
|
@ -10,9 +10,9 @@ import strutils, net, unittest
|
||||||
import ../asyncdispatch2
|
import ../asyncdispatch2
|
||||||
|
|
||||||
const
|
const
|
||||||
TestsCount = 10000
|
TestsCount = 100000
|
||||||
ClientsCount = 100
|
ClientsCount = 100
|
||||||
MessagesCount = 100
|
MessagesCount = 1000
|
||||||
|
|
||||||
proc client1(transp: DatagramTransport, pbytes: pointer, nbytes: int,
|
proc client1(transp: DatagramTransport, pbytes: pointer, nbytes: int,
|
||||||
raddr: TransportAddress, udata: pointer): Future[void] {.async.} =
|
raddr: TransportAddress, udata: pointer): Future[void] {.async.} =
|
||||||
|
@ -46,9 +46,7 @@ proc client2(transp: DatagramTransport, pbytes: pointer, nbytes: int,
|
||||||
if counterPtr[] == TestsCount:
|
if counterPtr[] == TestsCount:
|
||||||
transp.close()
|
transp.close()
|
||||||
else:
|
else:
|
||||||
var ta: TransportAddress
|
var ta = strAddress("127.0.0.1:33336")
|
||||||
ta.address = parseIpAddress("127.0.0.1")
|
|
||||||
ta.port = Port(33336)
|
|
||||||
var req = "REQUEST" & $counterPtr[]
|
var req = "REQUEST" & $counterPtr[]
|
||||||
await transp.sendTo(addr req[0], len(req), ta)
|
await transp.sendTo(addr req[0], len(req), ta)
|
||||||
else:
|
else:
|
||||||
|
@ -121,9 +119,7 @@ proc client5(transp: DatagramTransport, pbytes: pointer, nbytes: int,
|
||||||
if counterPtr[] == MessagesCount:
|
if counterPtr[] == MessagesCount:
|
||||||
transp.close()
|
transp.close()
|
||||||
else:
|
else:
|
||||||
var ta: TransportAddress
|
var ta = strAddress("127.0.0.1:33337")
|
||||||
ta.address = parseIpAddress("127.0.0.1")
|
|
||||||
ta.port = Port(33337)
|
|
||||||
var req = "REQUEST" & $counterPtr[]
|
var req = "REQUEST" & $counterPtr[]
|
||||||
await transp.sendTo(addr req[0], len(req), ta)
|
await transp.sendTo(addr req[0], len(req), ta)
|
||||||
else:
|
else:
|
||||||
|
@ -137,10 +133,8 @@ proc client5(transp: DatagramTransport, pbytes: pointer, nbytes: int,
|
||||||
transp.close()
|
transp.close()
|
||||||
|
|
||||||
proc test1(): Future[int] {.async.} =
|
proc test1(): Future[int] {.async.} =
|
||||||
var ta: TransportAddress
|
var ta = strAddress("127.0.0.1:33336")
|
||||||
var counter = 0
|
var counter = 0
|
||||||
ta.address = parseIpAddress("127.0.0.1")
|
|
||||||
ta.port = Port(33336)
|
|
||||||
var dgram1 = newDatagramTransport(client1, udata = addr counter, local = ta)
|
var dgram1 = newDatagramTransport(client1, udata = addr counter, local = ta)
|
||||||
var dgram2 = newDatagramTransport(client2, udata = addr counter)
|
var dgram2 = newDatagramTransport(client2, udata = addr counter)
|
||||||
var data = "REQUEST0"
|
var data = "REQUEST0"
|
||||||
|
@ -150,10 +144,8 @@ proc test1(): Future[int] {.async.} =
|
||||||
result = counter
|
result = counter
|
||||||
|
|
||||||
proc test2(): Future[int] {.async.} =
|
proc test2(): Future[int] {.async.} =
|
||||||
var ta: TransportAddress
|
var ta = strAddress("127.0.0.1:33337")
|
||||||
var counter = 0
|
var counter = 0
|
||||||
ta.address = parseIpAddress("127.0.0.1")
|
|
||||||
ta.port = Port(33337)
|
|
||||||
var dgram1 = newDatagramTransport(client1, udata = addr counter, local = ta)
|
var dgram1 = newDatagramTransport(client1, udata = addr counter, local = ta)
|
||||||
var dgram2 = newDatagramTransport(client3, udata = addr counter, remote = ta)
|
var dgram2 = newDatagramTransport(client3, udata = addr counter, remote = ta)
|
||||||
var data = "REQUEST0"
|
var data = "REQUEST0"
|
||||||
|
@ -174,9 +166,7 @@ proc waitAll(futs: seq[Future[void]]): Future[void] =
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc test3(bounded: bool): Future[int] {.async.} =
|
proc test3(bounded: bool): Future[int] {.async.} =
|
||||||
var ta: TransportAddress
|
var ta = strAddress("127.0.0.1:33337")
|
||||||
ta.address = parseIpAddress("127.0.0.1")
|
|
||||||
ta.port = Port(33337)
|
|
||||||
var counter = 0
|
var counter = 0
|
||||||
var dgram1 = newDatagramTransport(client1, udata = addr counter, local = ta)
|
var dgram1 = newDatagramTransport(client1, udata = addr counter, local = ta)
|
||||||
var clients = newSeq[Future[void]](ClientsCount)
|
var clients = newSeq[Future[void]](ClientsCount)
|
||||||
|
|
|
@ -15,8 +15,8 @@ else:
|
||||||
import posix
|
import posix
|
||||||
|
|
||||||
const
|
const
|
||||||
ClientsCount = 50
|
ClientsCount = 100
|
||||||
MessagesCount = 50
|
MessagesCount = 100
|
||||||
MessageSize = 20
|
MessageSize = 20
|
||||||
FilesCount = 50
|
FilesCount = 50
|
||||||
FilesTestName = "tests/teststream.nim"
|
FilesTestName = "tests/teststream.nim"
|
||||||
|
|
Loading…
Reference in New Issue