From 4ad746ddc291e672b918e7b3ddeb5ca3fe2bfad1 Mon Sep 17 00:00:00 2001 From: jkratoch <> Date: Wed, 15 Sep 2010 17:35:00 +0000 Subject: [PATCH] +runtest-valgrind --- src/runtest-valgrind/boards/valgrind.exp | 60 ++++++++++++++++++++++++++++++++ src/runtest-valgrind/runtest-valgrind | 2 ++ src/runtest-valgrind/site.exp | 0 3 files changed, 62 insertions(+) create mode 100644 src/runtest-valgrind/boards/valgrind.exp create mode 100755 src/runtest-valgrind/runtest-valgrind create mode 100644 src/runtest-valgrind/site.exp diff --git a/src/runtest-valgrind/boards/valgrind.exp b/src/runtest-valgrind/boards/valgrind.exp new file mode 100644 index 0000000..9490f70 --- /dev/null +++ b/src/runtest-valgrind/boards/valgrind.exp @@ -0,0 +1,60 @@ +set board_info(localhost,isremote) 0 +load_generic_config "unix" + +# The default compiler for this target. +set_board_info compiler "[find_gcc]" + +global outdir vg_basename +set vg_basename "$outdir/valgrind." +global vg_count +set vg_count "0" + +global GDB +set GDB "valgrind --quiet --trace-children=no --child-silent-after-fork=yes --log-file=${vg_basename}%q{VGCOUNT} $GDB" + +# Support for running gdb under valgrind and checking the results. + +rename remote_spawn vg_remote_spawn +proc remote_spawn {args} { + global env vg_basename vg_count + + incr vg_count + set env(VGCOUNT) $vg_count + + file delete -force ${vg_basename}$vg_count + set res [uplevel vg_remote_spawn $args] + + return $res +} + +rename gdb_exit vg_gdb_exit +proc gdb_exit {args} { + global vg_basename vg_count vg_reported + + # We can sometimes see multiple consecutive calls to gdb_exit + # without an intervening spawn. In this case we only want to + # report the valgrind results once. + if {![info exists vg_reported($vg_count)]} { + set vg_reported($vg_count) 1 + + # FIXME: how can we name this test consistently across + # runs? + if {[file exists ${vg_basename}$vg_count] + && [file size ${vg_basename}$vg_count] > 0} { + send_log "Valgrind output:\n" + set fd [open ${vg_basename}$vg_count] + send_log [read $fd] + close $fd + send_log "\n" + fail "valgrind check $vg_count" + } else { + pass "valgrind check $vg_count" + } + } + + return [uplevel vg_gdb_exit $args] +} + +# Valgrind slows everything down, so boost the default timeout. +global gdb_test_timeout +set gdb_test_timeout [expr {20 * $gdb_test_timeout}] diff --git a/src/runtest-valgrind/runtest-valgrind b/src/runtest-valgrind/runtest-valgrind new file mode 100755 index 0000000..3e96650 --- /dev/null +++ b/src/runtest-valgrind/runtest-valgrind @@ -0,0 +1,2 @@ +#! /bin/sh +DEJAGNU=$HOME/src/runtest-valgrind/site.exp runtest --target_board valgrind "$@" diff --git a/src/runtest-valgrind/site.exp b/src/runtest-valgrind/site.exp new file mode 100644 index 0000000..e69de29 -- 1.8.3.1