* trigger valgrind failure on memory leak * remove non-malloc tests * remove ORC test is redundant because we already have an ARC test * only run valgrind tests on 64-bit Linux * disable freebsd and openbsd * Remove tleak_refc As to not test implementation details (or bug) * Fix test failures by removing redundant test Since this tests/shoulfail/tvalgrind.nim was specified here to fail this test itself fails since it will be skipped on non-linux CI * Remove test, reason detailed in the previous commit * Remove redundant disables * Revert removing disables * Add and use valgrind: leaks * Fix Co-authored-by: Clyybber <darkmine956@gmail.com> Co-authored-by: n5m
This commit is contained in:
parent
833035bacd
commit
436e1fa5b1
6 changed files with 35 additions and 9 deletions
|
|
@ -103,6 +103,11 @@ Example "template" **to edit** and write a Testament unittest:
|
||||||
target: "c js" # Targets to run the test into (C, C++, JavaScript, etc).
|
target: "c js" # Targets to run the test into (C, C++, JavaScript, etc).
|
||||||
|
|
||||||
disabled: "bsd" # Disable the test by condition, here BSD is disabled just as an example.
|
disabled: "bsd" # Disable the test by condition, here BSD is disabled just as an example.
|
||||||
|
disabled: "win" # Can disable multiple OSes at once
|
||||||
|
disabled: "32bit" # ...or architectures
|
||||||
|
disabled: "i386"
|
||||||
|
disabled: "azure" # ...or pipeline runners
|
||||||
|
disabled: true # ...or can disable the test entirely
|
||||||
|
|
||||||
"""
|
"""
|
||||||
assert true
|
assert true
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ type
|
||||||
reFilesDiffer, # expected and given filenames differ
|
reFilesDiffer, # expected and given filenames differ
|
||||||
reLinesDiffer, # expected and given line numbers differ
|
reLinesDiffer, # expected and given line numbers differ
|
||||||
reOutputsDiffer,
|
reOutputsDiffer,
|
||||||
reExitcodesDiffer,
|
reExitcodesDiffer, # exit codes of program or of valgrind differ
|
||||||
reTimeout,
|
reTimeout,
|
||||||
reInvalidPeg,
|
reInvalidPeg,
|
||||||
reCodegenFailure,
|
reCodegenFailure,
|
||||||
|
|
@ -67,6 +67,9 @@ type
|
||||||
msg*: string
|
msg*: string
|
||||||
line*, col*: int
|
line*, col*: int
|
||||||
|
|
||||||
|
ValgrindSpec* = enum
|
||||||
|
disabled, enabled, leaking
|
||||||
|
|
||||||
TSpec* = object
|
TSpec* = object
|
||||||
action*: TTestAction
|
action*: TTestAction
|
||||||
file*, cmd*: string
|
file*, cmd*: string
|
||||||
|
|
@ -92,7 +95,7 @@ type
|
||||||
# whether this test can be batchable via `NIM_TESTAMENT_BATCH`; only very
|
# whether this test can be batchable via `NIM_TESTAMENT_BATCH`; only very
|
||||||
# few tests are not batchable; the ones that are not could be turned batchable
|
# few tests are not batchable; the ones that are not could be turned batchable
|
||||||
# by making the dependencies explicit
|
# by making the dependencies explicit
|
||||||
useValgrind*: bool
|
useValgrind*: ValgrindSpec
|
||||||
timeout*: float # in seconds, fractions possible,
|
timeout*: float # in seconds, fractions possible,
|
||||||
# but don't rely on much precision
|
# but don't rely on much precision
|
||||||
inlineErrors*: seq[InlineError] # line information to error message
|
inlineErrors*: seq[InlineError] # line information to error message
|
||||||
|
|
@ -306,14 +309,15 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
result.unjoinable = not parseCfgBool(e.value)
|
result.unjoinable = not parseCfgBool(e.value)
|
||||||
of "valgrind":
|
of "valgrind":
|
||||||
when defined(linux) and sizeof(int) == 8:
|
when defined(linux) and sizeof(int) == 8:
|
||||||
result.useValgrind = parseCfgBool(e.value)
|
result.useValgrind = if e.value.normalize == "leaks": leaking
|
||||||
|
else: ValgrindSpec(parseCfgBool(e.value))
|
||||||
result.unjoinable = true
|
result.unjoinable = true
|
||||||
if result.useValgrind:
|
if result.useValgrind != disabled:
|
||||||
result.outputCheck = ocSubstr
|
result.outputCheck = ocSubstr
|
||||||
else:
|
else:
|
||||||
# Windows lacks valgrind. Silly OS.
|
# Windows lacks valgrind. Silly OS.
|
||||||
# Valgrind only supports OSX <= 17.x
|
# Valgrind only supports OSX <= 17.x
|
||||||
result.useValgrind = false
|
result.useValgrind = disabled
|
||||||
of "disabled":
|
of "disabled":
|
||||||
case e.value.normalize
|
case e.value.normalize
|
||||||
of "y", "yes", "true", "1", "on": result.err = reDisabled
|
of "y", "yes", "true", "1", "on": result.err = reDisabled
|
||||||
|
|
|
||||||
|
|
@ -501,8 +501,11 @@ proc testSpecHelper(r: var TResults, test: var TTest, expected: TSpec,
|
||||||
args = concat(@[exeFile], args)
|
args = concat(@[exeFile], args)
|
||||||
else:
|
else:
|
||||||
exeCmd = exeFile.dup(normalizeExe)
|
exeCmd = exeFile.dup(normalizeExe)
|
||||||
if expected.useValgrind:
|
if expected.useValgrind != disabled:
|
||||||
args = @["--error-exitcode=1"] & exeCmd & args
|
var valgrindOptions = @["--error-exitcode=1"]
|
||||||
|
if expected.useValgrind != leaking:
|
||||||
|
valgrindOptions.add "--leak-check=yes"
|
||||||
|
args = valgrindOptions & exeCmd & args
|
||||||
exeCmd = "valgrind"
|
exeCmd = "valgrind"
|
||||||
var (_, buf, exitCode) = execCmdEx2(exeCmd, args, input = expected.input)
|
var (_, buf, exitCode) = execCmdEx2(exeCmd, args, input = expected.input)
|
||||||
# Treat all failure codes from nodejs as 1. Older versions of nodejs used
|
# Treat all failure codes from nodejs as 1. Older versions of nodejs used
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''230000'''
|
output: '''230000'''
|
||||||
cmd: '''nim c --gc:orc -d:useMalloc $file'''
|
cmd: '''nim c --gc:orc -d:useMalloc $file'''
|
||||||
valgrind: "true"
|
valgrind: "leaks"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# bug #14402
|
# bug #14402
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim c --gc:orc -d:useMalloc -d:nimStressOrc $file"
|
cmd: "nim c --gc:orc -d:useMalloc -d:nimStressOrc $file"
|
||||||
valgrind: "true"
|
valgrind: "leaks"
|
||||||
output: "done"
|
output: "done"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
14
tests/valgrind/tleak_arc.nim
Normal file
14
tests/valgrind/tleak_arc.nim
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
discard """
|
||||||
|
valgrind: true
|
||||||
|
cmd: "nim $target --gc:arc -d:useMalloc $options $file"
|
||||||
|
exitcode: 1
|
||||||
|
outputsub: " definitely lost: 7 bytes in 2 blocks"
|
||||||
|
disabled: "freebsd"
|
||||||
|
disabled: "macosx"
|
||||||
|
disabled: "openbsd"
|
||||||
|
disabled: "windows"
|
||||||
|
disabled: "32bit"
|
||||||
|
"""
|
||||||
|
|
||||||
|
discard alloc(3)
|
||||||
|
discard alloc(4)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue