aboutsummaryrefslogtreecommitdiff
blob: 3828514c0b068bb15d0df5c0ca6b0276de91a6ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Basic expect script for gprofng tests
#   Copyright (C) 2021-2023 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.
#


# The "make check" target in the Makefile passes in
# "CC=$(CC_FOR_TARGET)".  But, if the user invokes runtest directly,
# these flags may not be set.
if {![info exists CC]} {
    set CC [find_gcc]
}
if {![info exists CC_FOR_TARGET]} {
    set CC_FOR_TARGET $CC
}
if {![info exists CFLAGS]} {
    set CFLAGS "-g -O2"
}

remote_exec host "sh -c \"rm -rf tmpdir; mkdir -p tmpdir\""
if { "$CHECK_TARGET" == "check-install" } {
    set ::env(GPROFNG) "$PREFIX/bin/gprofng"
} else {
    set ld_library_path "${BUILDDIR}/src/.libs:${BUILDDIR}/libcollector/.libs"
    set orig_ld_library_path ""
    catch { set orig_ld_library_path $::env(LD_LIBRARY_PATH) }
    if [file exists "${BUILDDIR}/../bfd/.libs/libbfd.a"] {
        append ld_library_path ":${BUILDDIR}/../bfd/.libs"
    }
    if [file exists "${BUILDDIR}/../opcodes/.libs/libopcodes.a"] {
        append ld_library_path ":${BUILDDIR}/../opcodes/.libs"
    }
    if [file exists "${BUILDDIR}/../libsframe/.libs/libsframe.a"] {
        append ld_library_path ":${BUILDDIR}/../libsframe/.libs"
    }
    if [file exists "${BUILDDIR}/../libiberty/libiberty.a"] {
        append ld_library_path ":${BUILDDIR}/../libiberty"
    }

    set f [open "gprofng_wraper" w+]
    puts $f "#!/usr/bin/bash"
    puts $f "LD_LIBRARY_PATH=$ld_library_path:$orig_ld_library_path"
    puts $f "GPROFNG_SYSCONFDIR=$env(srcroot)/src"
    puts $f "GPROFNG_PRELOAD_LIBDIRS=$BUILDDIR/libcollector/.libs"
    puts $f "export LD_LIBRARY_PATH GPROFNG_SYSCONFDIR GPROFNG_PRELOAD_LIBDIRS"
    puts $f "${BUILDDIR}/src/gprofng \"\$@\""
    close $f
    file attributes gprofng_wraper -permissions +rx
    set ::env(GPROFNG) "$BUILDDIR/gprofng_wraper"
}
puts "### GPROFNG: $env(GPROFNG)"

set TEST_TIMEOUT 300

load_lib display-lib.exp