9490f704b3974c086462870d39862e2947832711
[nethome.git] / src / runtest-valgrind / boards / valgrind.exp
1 set board_info(localhost,isremote) 0
2 load_generic_config "unix"
3
4 # The default compiler for this target.
5 set_board_info compiler "[find_gcc]"
6
7 global outdir vg_basename
8 set vg_basename "$outdir/valgrind."
9 global vg_count
10 set vg_count "0"
11
12 global GDB
13 set GDB "valgrind --quiet --trace-children=no --child-silent-after-fork=yes --log-file=${vg_basename}%q{VGCOUNT} $GDB"
14
15 # Support for running gdb under valgrind and checking the results.
16
17 rename remote_spawn vg_remote_spawn
18 proc remote_spawn {args} {
19     global env vg_basename vg_count
20
21     incr vg_count
22     set env(VGCOUNT) $vg_count
23
24     file delete -force ${vg_basename}$vg_count
25     set res [uplevel vg_remote_spawn $args]
26
27     return $res
28 }
29
30 rename gdb_exit vg_gdb_exit
31 proc gdb_exit {args} {
32     global vg_basename vg_count vg_reported
33
34     # We can sometimes see multiple consecutive calls to gdb_exit
35     # without an intervening spawn.  In this case we only want to
36     # report the valgrind results once.
37     if {![info exists vg_reported($vg_count)]} {
38         set vg_reported($vg_count) 1
39
40         # FIXME: how can we name this test consistently across
41         # runs?
42         if {[file exists ${vg_basename}$vg_count]
43             && [file size ${vg_basename}$vg_count] > 0} {
44             send_log "Valgrind output:\n"
45             set fd [open ${vg_basename}$vg_count]
46             send_log [read $fd]
47             close $fd
48             send_log "\n"
49             fail "valgrind check $vg_count"
50         } else {
51             pass "valgrind check $vg_count"
52         }
53     }
54
55     return [uplevel vg_gdb_exit $args]
56 }
57
58 # Valgrind slows everything down, so boost the default timeout.
59 global gdb_test_timeout
60 set gdb_test_timeout [expr {20 * $gdb_test_timeout}]