2022-06-16 11:35:24 +00:00
|
|
|
#
|
|
|
|
# Chronos Unittest2 Helpers
|
|
|
|
# (c) Copyright 2022-Present
|
|
|
|
# Status Research & Development GmbH
|
|
|
|
#
|
|
|
|
# Licensed under either of
|
|
|
|
# Apache License, version 2.0, (LICENSE-APACHEv2)
|
|
|
|
# MIT license (LICENSE-MIT)
|
2023-07-14 10:35:08 +00:00
|
|
|
import std/tables
|
2022-06-16 11:35:24 +00:00
|
|
|
import unittest2
|
|
|
|
import ../../chronos
|
|
|
|
|
|
|
|
export unittest2, chronos
|
|
|
|
|
|
|
|
template asyncTest*(name: string, body: untyped): untyped =
|
|
|
|
test name:
|
|
|
|
waitFor((
|
|
|
|
proc() {.async, gcsafe.} =
|
|
|
|
body
|
|
|
|
)())
|
2023-07-14 10:35:08 +00:00
|
|
|
|
|
|
|
template checkLeaks*(name: string): untyped =
|
|
|
|
let counter = getTrackerCounter(name)
|
2023-09-05 10:41:52 +00:00
|
|
|
checkpoint:
|
|
|
|
"[" & name & "] opened = " & $counter.opened &
|
|
|
|
", closed = " & $ counter.closed
|
2023-07-14 10:35:08 +00:00
|
|
|
check counter.opened == counter.closed
|
|
|
|
|
|
|
|
template checkLeaks*(): untyped =
|
|
|
|
for key in getThreadDispatcher().trackerCounterKeys():
|
|
|
|
checkLeaks(key)
|