check leaks after every test (#487)
This commit is contained in:
parent
92acf68b04
commit
1021a7d294
|
@ -26,6 +26,7 @@ template checkLeaks*(name: string): untyped =
|
|||
", closed = " & $ counter.closed
|
||||
check counter.opened == counter.closed
|
||||
|
||||
template checkLeaks*(): untyped =
|
||||
proc checkLeaks*() =
|
||||
for key in getThreadDispatcher().trackerCounterKeys():
|
||||
checkLeaks(key)
|
||||
GC_fullCollect()
|
||||
|
|
|
@ -84,6 +84,9 @@ proc createBigMessage(message: string, size: int): seq[byte] =
|
|||
res
|
||||
|
||||
suite "AsyncStream test suite":
|
||||
teardown:
|
||||
checkLeaks()
|
||||
|
||||
test "AsyncStream(StreamTransport) readExactly() test":
|
||||
proc testReadExactly(): Future[bool] {.async.} =
|
||||
proc serveClient(server: StreamServer,
|
||||
|
@ -256,9 +259,6 @@ suite "AsyncStream test suite":
|
|||
result = true
|
||||
check waitFor(testConsume()) == true
|
||||
|
||||
test "AsyncStream(StreamTransport) leaks test":
|
||||
checkLeaks()
|
||||
|
||||
test "AsyncStream(AsyncStream) readExactly() test":
|
||||
proc testReadExactly2(): Future[bool] {.async.} =
|
||||
proc serveClient(server: StreamServer,
|
||||
|
@ -581,10 +581,10 @@ suite "AsyncStream test suite":
|
|||
|
||||
check waitFor(testWriteEof()) == true
|
||||
|
||||
test "AsyncStream(AsyncStream) leaks test":
|
||||
suite "ChunkedStream test suite":
|
||||
teardown:
|
||||
checkLeaks()
|
||||
|
||||
suite "ChunkedStream test suite":
|
||||
test "ChunkedStream test vectors":
|
||||
const ChunkedVectors = [
|
||||
["4\r\nWiki\r\n5\r\npedia\r\nE\r\n in\r\n\r\nchunks.\r\n0\r\n\r\n",
|
||||
|
@ -890,10 +890,10 @@ suite "ChunkedStream test suite":
|
|||
check waitFor(testSmallChunk(262400, 4096, 61)) == true
|
||||
check waitFor(testSmallChunk(767309, 4457, 173)) == true
|
||||
|
||||
test "ChunkedStream leaks test":
|
||||
suite "TLSStream test suite":
|
||||
teardown:
|
||||
checkLeaks()
|
||||
|
||||
suite "TLSStream test suite":
|
||||
const HttpHeadersMark = @[byte(0x0D), byte(0x0A), byte(0x0D), byte(0x0A)]
|
||||
test "Simple HTTPS connection":
|
||||
proc headerClient(address: TransportAddress,
|
||||
|
@ -1023,10 +1023,9 @@ suite "TLSStream test suite":
|
|||
let res = waitFor checkTrustAnchors("Some message")
|
||||
check res == "Some message\r\n"
|
||||
|
||||
test "TLSStream leaks test":
|
||||
checkLeaks()
|
||||
|
||||
suite "BoundedStream test suite":
|
||||
teardown:
|
||||
checkLeaks()
|
||||
|
||||
type
|
||||
BoundarySizeTest = enum
|
||||
|
@ -1402,6 +1401,3 @@ suite "BoundedStream test suite":
|
|||
return (writer1Res and writer2Res and readerRes)
|
||||
|
||||
check waitFor(checkEmptyStreams()) == true
|
||||
|
||||
test "BoundedStream leaks test":
|
||||
checkLeaks()
|
||||
|
|
|
@ -13,6 +13,9 @@ import ".."/chronos
|
|||
{.used.}
|
||||
|
||||
suite "Datagram Transport test suite":
|
||||
teardown:
|
||||
checkLeaks()
|
||||
|
||||
const
|
||||
TestsCount = 2000
|
||||
ClientsCount = 20
|
||||
|
@ -727,5 +730,3 @@ suite "Datagram Transport test suite":
|
|||
DualStackType.Auto, initTAddress("[::1]:0"))) == true
|
||||
else:
|
||||
skip()
|
||||
test "Transports leak test":
|
||||
checkLeaks()
|
||||
|
|
|
@ -74,6 +74,8 @@ N8r5CwGcIX/XPC3lKazzbZ8baA==
|
|||
"""
|
||||
|
||||
suite "HTTP client testing suite":
|
||||
teardown:
|
||||
checkLeaks()
|
||||
|
||||
type
|
||||
TestResponseTuple = tuple[status: int, data: string, count: int]
|
||||
|
@ -1516,6 +1518,3 @@ suite "HTTP client testing suite":
|
|||
res.isErr() and res.error == HttpAddressErrorType.NameLookupFailed
|
||||
res.error.isRecoverableError()
|
||||
not(res.error.isCriticalError())
|
||||
|
||||
test "Leaks test":
|
||||
checkLeaks()
|
||||
|
|
|
@ -14,6 +14,9 @@ import stew/base10
|
|||
{.used.}
|
||||
|
||||
suite "HTTP server testing suite":
|
||||
teardown:
|
||||
checkLeaks()
|
||||
|
||||
type
|
||||
TooBigTest = enum
|
||||
GetBodyTest, ConsumeBodyTest, PostUrlTest, PostMultipartTest
|
||||
|
@ -1782,6 +1785,3 @@ suite "HTTP server testing suite":
|
|||
|
||||
await server.stop()
|
||||
await server.closeWait()
|
||||
|
||||
test "Leaks test":
|
||||
checkLeaks()
|
||||
|
|
|
@ -16,6 +16,9 @@ when defined(posix):
|
|||
when defined(nimHasUsed): {.used.}
|
||||
|
||||
suite "Asynchronous process management test suite":
|
||||
teardown:
|
||||
checkLeaks()
|
||||
|
||||
const OutputTests =
|
||||
when defined(windows):
|
||||
[
|
||||
|
@ -463,6 +466,3 @@ suite "Asynchronous process management test suite":
|
|||
skip()
|
||||
else:
|
||||
check getCurrentFD() == markFD
|
||||
|
||||
test "Leaks test":
|
||||
checkLeaks()
|
||||
|
|
|
@ -75,6 +75,8 @@ N8r5CwGcIX/XPC3lKazzbZ8baA==
|
|||
|
||||
|
||||
suite "Secure HTTP server testing suite":
|
||||
teardown:
|
||||
checkLeaks()
|
||||
|
||||
proc httpsClient(address: TransportAddress,
|
||||
data: string, flags = {NoVerifyHost, NoVerifyServerName}
|
||||
|
@ -184,6 +186,3 @@ suite "Secure HTTP server testing suite":
|
|||
return serverRes and data == "EXCEPTION"
|
||||
|
||||
check waitFor(testHTTPS2(initTAddress("127.0.0.1:30080"))) == true
|
||||
|
||||
test "Leaks test":
|
||||
checkLeaks()
|
||||
|
|
|
@ -16,6 +16,9 @@ when defined(windows):
|
|||
importc: "_get_osfhandle", header:"<io.h>".}
|
||||
|
||||
suite "Stream Transport test suite":
|
||||
teardown:
|
||||
checkLeaks()
|
||||
|
||||
const
|
||||
ConstantMessage = "SOMEDATA"
|
||||
BigMessagePattern = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
@ -1555,12 +1558,6 @@ suite "Stream Transport test suite":
|
|||
check waitFor(testAccept(addresses[i])) == true
|
||||
test prefixes[i] & "close() while in accept() waiting test":
|
||||
check waitFor(testAcceptClose(addresses[i])) == true
|
||||
test prefixes[i] & "Intermediate transports leak test #1":
|
||||
checkLeaks()
|
||||
when defined(windows):
|
||||
skip()
|
||||
else:
|
||||
checkLeaks(StreamTransportTrackerName)
|
||||
test prefixes[i] & "accept() too many file descriptors test":
|
||||
when defined(windows):
|
||||
skip()
|
||||
|
@ -1671,8 +1668,6 @@ suite "Stream Transport test suite":
|
|||
DualStackType.Disabled, initTAddress("[::1]:0"))) == true
|
||||
else:
|
||||
skip()
|
||||
test "Leaks test":
|
||||
checkLeaks()
|
||||
test "File descriptors leak test":
|
||||
when defined(windows):
|
||||
# Windows handle numbers depends on many conditions, so we can't use
|
||||
|
|
Loading…
Reference in New Issue