valgrind: nicer output
parent
1ad417734e
commit
53a9329ab6
|
@ -1,41 +1,56 @@
|
||||||
import os
|
import os
|
||||||
import term
|
import term
|
||||||
|
import benchmark
|
||||||
|
|
||||||
fn test_all() {
|
fn test_all() {
|
||||||
$if !linux {
|
if os.user_os() != 'linux' && os.getenv('FORCE_VALGRIND_TEST').len == 0 {
|
||||||
println('Valgrind tests can only be run on Linux.')
|
eprintln('Valgrind tests can only be run reliably on Linux for now.')
|
||||||
|
eprintln('You can still do it by setting FORCE_VALGRIND_TEST=1 .')
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
exe := os.executable()
|
bench_message := 'memory leak checking with valgrind'
|
||||||
dir := os.dir(exe)
|
mut bench := benchmark.new_benchmark()
|
||||||
vexe := os.dir(os.dir(os.dir(os.dir(dir)))) + '/v'
|
eprintln(term.header(bench_message,'-'))
|
||||||
println(vexe)
|
dir := os.resource_abs_path('')
|
||||||
println(dir)
|
vexe := os.getenv('VEXE')
|
||||||
println(111)
|
|
||||||
// files := os.ls('$dir/vlib/v/tests/valgrind/') or {
|
|
||||||
files := os.ls(dir) or {
|
files := os.ls(dir) or {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
tests := files.filter(it.ends_with('.vv'))
|
tests := files.filter(it.ends_with('.vv'))
|
||||||
|
bench.set_total_expected_steps(tests.len)
|
||||||
for test in tests {
|
for test in tests {
|
||||||
os.system('cp $dir/$test x.v') // cant run .vv file
|
bench.step()
|
||||||
println(test)
|
full_test_path := os.real_path(test)
|
||||||
res := os.exec('$vexe x.v') or {
|
os.system('cp ${dir}/${test} x.v') // cant run .vv file
|
||||||
println('valgrind $test failed')
|
res := os.exec('$vexe -b v2 x.v') or {
|
||||||
assert false
|
bench.fail()
|
||||||
|
eprintln(bench.step_message_fail('valgrind $test failed'))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
println(res.output)
|
|
||||||
os.exec('valgrind ./x') or {
|
|
||||||
println('valgrind $test failed')
|
|
||||||
assert false
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
println(res.output)
|
|
||||||
if res.exit_code != 0 {
|
if res.exit_code != 0 {
|
||||||
println('valgrind $test failed')
|
bench.fail()
|
||||||
assert false
|
eprintln(bench.step_message_fail('file: $full_test_path could not be compiled.'))
|
||||||
|
eprintln(res.output)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
valgrind_res := os.exec('valgrind --error-exitcode=1 --leak-check=full ./x') or {
|
||||||
|
bench.fail()
|
||||||
|
eprintln(bench.step_message_fail('valgrind could not be executed'))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if valgrind_res.exit_code != 0 {
|
||||||
|
bench.fail()
|
||||||
|
eprintln(bench.step_message_fail('failed valgrind check for $test'))
|
||||||
|
eprintln(valgrind_res.output)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
bench.ok()
|
||||||
|
eprintln(bench.step_message_ok('testing file: $test'))
|
||||||
|
}
|
||||||
|
bench.stop()
|
||||||
|
eprintln(term.h_divider('-'))
|
||||||
|
eprintln(bench.total_message(bench_message))
|
||||||
|
if bench.nfail > 0 {
|
||||||
|
exit(1)
|
||||||
}
|
}
|
||||||
println(tests)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue