diff options
author | Kay Zheng <l04m33@gmail.com> | 2015-04-17 22:40:53 +0800 |
---|---|---|
committer | Kay Zheng <l04m33@gmail.com> | 2015-04-17 22:40:53 +0800 |
commit | 3125058b6ab4bd9c3ad2cb103bb326463af0a7ff (patch) | |
tree | 52e0dec9782954fd25c3ec539b89fe932a9e7e9b | |
parent | 371d2739249ad33267e0b330e582a04d7d28fd98 (diff) | |
download | Nim-3125058b6ab4bd9c3ad2cb103bb326463af0a7ff.tar.gz |
Only run the test for the fixed version of poll(...)
-rw-r--r-- | tests/async/tasynceverror.nim | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/tests/async/tasynceverror.nim b/tests/async/tasynceverror.nim index 564df569e..3b81680cb 100644 --- a/tests/async/tasynceverror.nim +++ b/tests/async/tasynceverror.nim @@ -16,47 +16,50 @@ const testPort = Port(17357) -proc createListenSocket(host: string, port: Port): TAsyncFD = - result = newAsyncRawSocket() +when defined(windows) or defined(nimdoc): + discard +else: + proc createListenSocket(host: string, port: Port): TAsyncFD = + result = newAsyncRawSocket() - SocketHandle(result).setSockOptInt(SOL_SOCKET, SO_REUSEADDR, 1) + SocketHandle(result).setSockOptInt(SOL_SOCKET, SO_REUSEADDR, 1) - var aiList = getAddrInfo(host, port, AF_INET) - if SocketHandle(result).bindAddr(aiList.ai_addr, aiList.ai_addrlen.Socklen) < 0'i32: - dealloc(aiList) - raiseOSError(osLastError()) - dealloc(aiList) + var aiList = getAddrInfo(host, port, AF_INET) + if SocketHandle(result).bindAddr(aiList.ai_addr, aiList.ai_addrlen.Socklen) < 0'i32: + dealloc(aiList) + raiseOSError(osLastError()) + dealloc(aiList) - if SocketHandle(result).listen(1) < 0'i32: - raiseOSError(osLastError()) + if SocketHandle(result).listen(1) < 0'i32: + raiseOSError(osLastError()) -proc testAsyncSend() {.async.} = - var - ls = createListenSocket(testHost, testPort) - s = newAsyncSocket() + proc testAsyncSend() {.async.} = + var + ls = createListenSocket(testHost, testPort) + s = newAsyncSocket() - await s.connect(testHost, testPort) - - var ps = await ls.accept() - SocketHandle(ls).close() + await s.connect(testHost, testPort) + + var ps = await ls.accept() + SocketHandle(ls).close() - await ps.send("test 1", flags={}) - s.close() - # This send should raise EPIPE - await ps.send("test 2", flags={}) - SocketHandle(ps).close() + await ps.send("test 1", flags={}) + s.close() + # This send should raise EPIPE + await ps.send("test 2", flags={}) + SocketHandle(ps).close() -# The bug was, when the poll function handled EvError for us, -# our callbacks may never get executed, thus making the event -# loop block indefinitely. This is a timer to keep everything -# rolling. 400 ms is an arbitrary value, should be enough though. -proc timer() {.async.} = - await sleepAsync(400) - echo("Timer expired.") - quit(2) + # The bug was, when the poll function handled EvError for us, + # our callbacks may never get executed, thus making the event + # loop block indefinitely. This is a timer to keep everything + # rolling. 400 ms is an arbitrary value, should be enough though. + proc timer() {.async.} = + await sleepAsync(400) + echo("Timer expired.") + quit(2) -asyncCheck(testAsyncSend()) -waitFor(timer()) + asyncCheck(testAsyncSend()) + waitFor(timer()) |