tfdleak_multiple.nim 881 B

1234567891011121314151617181920212223242526272829303132
  1. discard """
  2. joinable: false
  3. """
  4. import os, osproc, strutils
  5. import std/assertions
  6. const Iterations = 200
  7. proc testFdLeak() =
  8. var count = 0
  9. let
  10. test = getAppDir() / "tfdleak"
  11. exe = test.addFileExt(ExeExt).quoteShell
  12. options = ["", "-d:nimInheritHandles"]
  13. for opt in options:
  14. let
  15. run = "nim c $1 $2" % [opt, quoteShell test]
  16. (output, status) = execCmdEx run
  17. doAssert status == 0, "Test complination failed:\n$1\n$2" % [run, output]
  18. for i in 1..Iterations:
  19. let (output, status) = execCmdEx exe
  20. doAssert status == 0, "Execution of " & exe & " failed"
  21. if "leaked" in output:
  22. count.inc
  23. doAssert count == 0, "Leaked " & $count & " times"
  24. when defined(windows):
  25. # tfdleak was only flaky for windows (and for netbsd, there is still a bug)
  26. # note that this test is quite slow, 87 sec on windows.
  27. testFdLeak()