tfdleak_multiple.nim 859 B

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