From 8da0e01769231d795300c7ce6894178cf6025e19 Mon Sep 17 00:00:00 2001 From: n5m <72841454+n5m@users.noreply.github.com> Date: Thu, 22 Oct 2020 09:25:11 +0000 Subject: expect valgrind test failure on memory leak (#15669) * expect valgrind test failure on memory leak * alloc 1 instead of 0 --- testament/tests/shouldfail/tvalgrind.nim | 17 +++++++++++++++++ tests/testament/tshould_not_work.nim | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 testament/tests/shouldfail/tvalgrind.nim diff --git a/testament/tests/shouldfail/tvalgrind.nim b/testament/tests/shouldfail/tvalgrind.nim new file mode 100644 index 000000000..4f699fd3b --- /dev/null +++ b/testament/tests/shouldfail/tvalgrind.nim @@ -0,0 +1,17 @@ +discard """ +valgrind: true +cmd: "nim $target --gc:arc -d:useMalloc $options $file" +""" + +# this is the same check used by testament/specs.nim whether or not valgrind +# tests are supported +when defined(linux) and sizeof(int) == 8: + # discarding this allocation will cause valgrind to fail (which is what we + # want), but valgrind only runs on 64-bit Linux machines... + discard alloc(1) +else: + # ...so on all other OS/architectures, simulate any non-zero exit code to + # mimic how valgrind would have failed on this test. We cannot use things like + # `disabled: "freebsd"` in the Testament configs above or else the tests will + # be SKIP-ed rather than FAIL-ed + quit(1) # choose 1 to match valgrind's `--error-exit=1`, but could be anything diff --git a/tests/testament/tshould_not_work.nim b/tests/testament/tshould_not_work.nim index e7790a4df..501e2c32f 100644 --- a/tests/testament/tshould_not_work.nim +++ b/tests/testament/tshould_not_work.nim @@ -29,6 +29,8 @@ FAIL: tests/shouldfail/tsortoutput.nim C Failure: reOutputsDiffer FAIL: tests/shouldfail/ttimeout.nim C Failure: reTimeout +FAIL: tests/shouldfail/tvalgrind.nim C +Failure: reExitcodesDiffer ''' """ -- cgit 1.4.1-2-gfad0