OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [testsuite/] [gdb.gdb/] [xfullpath.exp] - Blame information for rev 394

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
# Copyright 2002, 2003, 2004, 2007, 2008, 2009, 2010
2
# Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see .
16
 
17
# This file was written by Joel Brobecker. (brobecker@gnat.com), derived
18
# from selftest.exp, written by Rob Savoye.
19
 
20
if $tracelevel then {
21
    strace $tracelevel
22
}
23
 
24
 
25
# are we on a target board
26
if { [is_remote target] || ![isnative] } then {
27
    return
28
}
29
 
30
proc setup_test { executable } {
31
    global gdb_prompt
32
    global timeout
33
 
34
    # load yourself into the debugger
35
    # This can take a relatively long time, particularly for testing where
36
    # the executable is being accessed over a network, or where gdb does not
37
    # support partial symbols for a particular target and has to load the
38
    # entire symbol table.  Set the timeout to 10 minutes, which should be
39
    # adequate for most environments (it *has* timed out with 5 min on a
40
    # SPARCstation SLC under moderate load, so this isn't unreasonable).
41
    # After gdb is started, set the timeout to 30 seconds for the duration
42
    # of this test, and then back to the original value.
43
 
44
    set oldtimeout $timeout
45
    set timeout 600
46
    verbose "Timeout is now $timeout seconds" 2
47
 
48
    global gdb_file_cmd_debug_info
49
    set gdb_file_cmd_debug_info "unset"
50
 
51
    set result [gdb_load $executable]
52
    set timeout $oldtimeout
53
    verbose "Timeout is now $timeout seconds" 2
54
 
55
    if { $result != 0 } then {
56
        return -1
57
    }
58
 
59
    if { $gdb_file_cmd_debug_info != "debug" } then {
60
        untested "No debug information, skipping testcase."
61
        return -1
62
    }
63
 
64
    # Set a breakpoint at main
65
    gdb_test "break captured_main" \
66
            "Breakpoint.*at.* file.*, line.*" \
67
            "breakpoint in captured_main"
68
 
69
    # run yourself
70
    # It may take a very long time for the inferior gdb to start (lynx),
71
    # so we bump it back up for the duration of this command.
72
    set timeout 600
73
 
74
    set description "run until breakpoint at captured_main"
75
    gdb_test_multiple "run -nw" "$description" {
76
        -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" {
77
            pass "$description"
78
        }
79
        -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.*$gdb_prompt $" {
80
            xfail "$description (line numbers scrambled?)"
81
        }
82
        -re "vfork: No more processes.*$gdb_prompt $" {
83
            fail "$description (out of virtual memory)"
84
            set timeout $oldtimeout
85
            verbose "Timeout is now $timeout seconds" 2
86
            return -1
87
        }
88
        -re ".*$gdb_prompt $" {
89
            fail "$description"
90
            set timeout $oldtimeout
91
            verbose "Timeout is now $timeout seconds" 2
92
            return -1
93
        }
94
    }
95
 
96
    set timeout $oldtimeout
97
    verbose "Timeout is now $timeout seconds" 2
98
 
99
    return 0
100
}
101
 
102
proc test_with_self { executable } {
103
 
104
    set setup_result [setup_test $executable]
105
    if {$setup_result <0} then {
106
        return -1
107
    }
108
 
109
    # A file which contains a directory prefix
110
    gdb_test "print xfullpath (\"./xfullpath.exp\")" \
111
             ".\[0-9\]+ =.*\".*/xfullpath.exp\"" \
112
             "A filename with ./ as the directory prefix"
113
 
114
    # A file which contains a directory prefix
115
    gdb_test "print xfullpath (\"../../defs.h\")" \
116
             ".\[0-9\]+ =.*\".*/defs.h\"" \
117
             "A filename with ../ in the directory prefix"
118
 
119
    # A one-character filename
120
    gdb_test "print xfullpath (\"./a\")" \
121
             ".\[0-9\]+ =.*\".*/a\"" \
122
             "A one-char filename in the current directory"
123
 
124
    # A file in the root directory
125
    gdb_test "print xfullpath (\"/root_file_which_should_exist\")" \
126
             ".\[0-9\]+ =.*\"/root_file_which_should_exist\"" \
127
             "A filename in the root directory"
128
 
129
    # A file which does not have a directory prefix
130
    gdb_test "print xfullpath (\"xfullpath.exp\")" \
131
             ".\[0-9\]+ =.*\"xfullpath.exp\"" \
132
             "A filename without any directory prefix"
133
 
134
    # A one-char filename without any directory prefix
135
    gdb_test "print xfullpath (\"a\")" \
136
             ".\[0-9\]+ =.*\"a\"" \
137
             "A one-char filename without any directory prefix"
138
 
139
    # An empty filename
140
    gdb_test "print xfullpath (\"\")" \
141
             ".\[0-9\]+ =.*\"\"" \
142
             "An empty filename"
143
 
144
    return 0
145
}
146
 
147
# Find a pathname to a file that we would execute if the shell was asked
148
# to run $arg using the current PATH.
149
 
150
proc find_gdb { arg } {
151
 
152
    # If the arg directly specifies an existing executable file, then
153
    # simply use it.
154
 
155
    if [file executable $arg] then {
156
        return $arg
157
    }
158
 
159
    set result [which $arg]
160
    if [string match "/" [ string range $result 0 0 ]] then {
161
        return $result
162
    }
163
 
164
    # If everything fails, just return the unqualified pathname as default
165
    # and hope for best.
166
 
167
    return $arg
168
}
169
 
170
# Run the test with self.
171
# Copy the file executable file in case this OS doesn't like to edit its own
172
# text space.
173
 
174
set GDB_FULLPATH [find_gdb $GDB]
175
 
176
# Remove any old copy lying around.
177
remote_file host delete x$tool
178
 
179
gdb_start
180
set file [remote_download host $GDB_FULLPATH x$tool]
181
set result [test_with_self $file];
182
gdb_exit;
183
catch "remote_file host delete $file";
184
 
185
if {$result <0} then {
186
    warning "Couldn't test self"
187
    return -1
188
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.