diff options
Diffstat (limited to 'gprofng/testsuite/lib/display-lib.exp')
-rw-r--r-- | gprofng/testsuite/lib/display-lib.exp | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/gprofng/testsuite/lib/display-lib.exp b/gprofng/testsuite/lib/display-lib.exp new file mode 100644 index 00000000000..38ecb8d258e --- /dev/null +++ b/gprofng/testsuite/lib/display-lib.exp @@ -0,0 +1,105 @@ +# Support routines for display-testing machinery in gprofng testsuite. +# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. + +# Run the COMMAND on the host and return a list of the form +# { exit-status OUTPUT }. +proc run_native_host_cmd { command } { + global link_output + global ld + + verbose -log "$command" + set run_output "" + try { + set run_output [exec "sh" "-c" "$command" "2>@1"] + set status 0 + } trap CHILDSTATUS {results options} { + set status [lindex [dict get $options -errorcode] 2] + set run_output $results + } + regsub "\n$" $run_output "" run_output + if { [lindex $status 0] != 0 && [string match "" $run_output] } then { + append run_output "child process exited abnormally" + } + + if [string match "" $run_output] then { + return "" + } + + return [list [lindex $status 0] $run_output] +} + +# Run a display test in DIR. +# Unanswered questions: do we want to cycle through compilation flags, +# display options, collect flags, app options? Do we want these to be +# set on a per-app basis? (If so, they should probably be driven by a +# file in the test dir.) +proc run_display_test { dir cflags gprofflags } { + global srcdir MAKE CC CFLAGS LDFLAGS LIBS BUILDDIR + set stripped [string map {" " ""} $dir] + set testdir [string map {" " ""} "$dir.$cflags,$gprofflags"] + set sdir "$srcdir/gprofng.display/$dir" + set tdir "tmpdir/$testdir" + send_log "create dir: $tdir\n" + set output [run_native_host_cmd "mkdir -p $tdir"] + set gprofng [exec find $BUILDDIR/tmpdir -type f -name gprofng -perm -u+x | head -1] + + set fd [open "$tdir/rules.txt" "w"] + switch -regexp -- $testdir { + {-p,on.*-h,on} { + set DISPLAY_FLAGS "-metrics i.totalcpu:i.cycles -func" + puts $fd "Cpu, 2, 0\n" + puts $fd "Cycles, 2, 1\n" + } + {-h,on} { + set DISPLAY_FLAGS "-metrics i.cycles -func" + puts $fd "Cycles, 2, 0\n" + } + default { + set DISPLAY_FLAGS "-metrics i.totalcpu -func" + puts $fd "Cpu, 2, 0\n" + } + } + close $fd + + set make_args "-f $sdir/Makefile srcdir=\"$sdir\" builddir=\"$BUILDDIR\" \ + VPATH=\"$dir\" CC=\"$CC\" CFLAGS=\"$cflags\" LDFLAGS=\"$LDFLAGS\" \ + DISPLAY_FLAGS=\"$DISPLAY_FLAGS\" \ + COLLECT_FLAGS=\"$gprofflags\" GPROFNG=\"$gprofng\" MAKE=\"$MAKE\"" + set output [run_native_host_cmd "cd $tdir && $MAKE $make_args all"] +# send_log "run_native_host_cmd output:\n$output\n" + if { [lindex $output 0] != 0 } then { + set out [lindex $output 1] + if {[file exists "$tdir/diff.out"]} then { + send_log "comparison of results in $dir failed:\n$out\n" + set pltf [exec uname -i] + if { $pltf == "aarch64" } { + xfail $dir + return 0 + } + perror "comparison of results in $dir failed" + } else { + send_log "compilation of test program in $dir failed:\n$out\n" + perror "compilation of test program in $dir failed" + } + fail $dir + return 0 + } + pass $dir +} |