~ubuntu-branches/ubuntu/warty/dejagnu/warty

« back to all changes in this revision

Viewing changes to config/ddb-ether.exp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Jacobowitz
  • Date: 2004-02-09 15:07:58 UTC
  • Revision ID: james.westby@ubuntu.com-20040209150758-oaj7r5zrop60v8sb
Tags: upstream-1.4.4
ImportĀ upstreamĀ versionĀ 1.4.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
 
2
# Foundation, Inc.
 
3
#
 
4
# This file is part of DejaGnu.
 
5
#
 
6
# DejaGnu is free software; you can redistribute it and/or modify it
 
7
# under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation; either version 2 of the License, or
 
9
# (at your option) any later version.
 
10
#
 
11
# DejaGnu is distributed in the hope that it will be useful, but
 
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
# General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with DejaGnu; if not, write to the Free Software Foundation,
 
18
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
19
 
 
20
# This file was written by Bob Manson (manson@cygnus.com)
 
21
 
 
22
# Reset the prompt to what GDB needs.
 
23
proc ${board}_init { dest } {
 
24
    global doing_ddb_init
 
25
 
 
26
    if ![info exists doing_ddb_init] {
 
27
        set doing_ddb_init 1
 
28
 
 
29
        remote_close $dest
 
30
        for { set x 0 } { $x < 3 } { incr x } {
 
31
            set shell_id [remote_open $dest]
 
32
            if { $shell_id == "" || $shell_id < 0 } {
 
33
                remote_reboot $dest
 
34
            } else {
 
35
                break
 
36
            }
 
37
        }
 
38
 
 
39
        set shell_prompt [board_info $dest shell_prompt]
 
40
 
 
41
        remote_send $dest "\n"
 
42
        remote_expect $dest 10 {
 
43
            -re ".*PMON> $" {
 
44
                remote_send $dest "set prompt \"$shell_prompt\"\n"
 
45
                exp_continue
 
46
            }
 
47
            -re ".*${shell_prompt}$" { }
 
48
        }
 
49
        remote_close $dest
 
50
        unset doing_ddb_init
 
51
    } else {
 
52
        return
 
53
    }
 
54
}
 
55
 
 
56
proc ddb_ether_load { dest prog args } {
 
57
    for { set x 0 } { $x < 3 } { incr x } {
 
58
        set result [eval remote_spawn \{$dest\} \{$prog\} $args]
 
59
        if { $result < 0 } {
 
60
            remote_reboot $dest
 
61
        } else {
 
62
            set result [remote_wait $dest 300]
 
63
            set status [lindex $result 0]
 
64
            set output [lindex $result 1]
 
65
            if { $status >= 0 } {
 
66
                if { $status > 0 } {
 
67
                    return [list "fail" $output]
 
68
                } else {
 
69
                    return [list "pass" $output]
 
70
                }
 
71
            }
 
72
        }
 
73
    }
 
74
    return [list "fail" ""]
 
75
}
 
76
 
 
77
proc ddb_ether_ld { dest prog } {
 
78
    if ![board_info $dest exists tftpdir] {
 
79
        perror "Must set_board_info tftpdir for [board_info $dest name]"
 
80
        return "fail"
 
81
    }
 
82
 
 
83
    if ![board_info $dest exists fileid] {
 
84
        set spawn_id [remote_open $dest]
 
85
        if { $spawn_id == "" || $spawn_id < 0 } {
 
86
            return "retry"
 
87
        }
 
88
        remote_binary $dest
 
89
    }
 
90
 
 
91
    set shell_prompt [board_info $dest shell_prompt]
 
92
 
 
93
    remote_send $dest "\n"
 
94
    remote_expect $dest 10 {
 
95
        -re ".*${shell_prompt}$" { }
 
96
        default {
 
97
            return "retry"
 
98
        }
 
99
    }
 
100
    set basename "a.out.[pid]"
 
101
    set file "[board_info $dest tftpdir]/$basename"
 
102
    set file [remote_download build $prog $file]
 
103
    if { $file == "" } {
 
104
        perror "download to tftp area failed"
 
105
        return "fail"
 
106
    }
 
107
    set state "pass"
 
108
 
 
109
    remote_send $dest "boot /$basename\n"
 
110
    set tries 0
 
111
    remote_expect $dest 30 {
 
112
        -re "Loading.*Entry address is.*${shell_prompt}$" { }
 
113
        -re "invalid executable.*${shell_prompt}$" {
 
114
            incr tries
 
115
            if { $tries < 3 } {
 
116
                sleep 2
 
117
                remote_send $dest "boot /$basename\n"
 
118
                exp_continue
 
119
            }
 
120
        }
 
121
        -re ".*${shell_prompt}$" {
 
122
            set state "fail"
 
123
        }
 
124
        default {
 
125
            set state "fail"
 
126
        }
 
127
    }
 
128
    remote_file build delete $file
 
129
    if { $state == "fail" } {
 
130
        return $state
 
131
    }
 
132
    return "pass"
 
133
}
 
134
 
 
135
proc ddb_ether_spawn { dest prog args } {
 
136
    set state [ddb_ether_ld $dest $prog]
 
137
 
 
138
    if { $state != "pass" } {
 
139
        return -1
 
140
    }
 
141
    remote_send $dest "g\n"
 
142
    remote_expect $dest 5 {
 
143
        -re "g\[\r\n\]\[\r\n\]?" { }
 
144
        default { }
 
145
    }
 
146
 
 
147
    return [board_info $dest fileid]
 
148
}
 
149
 
 
150
proc ddb_ether_wait { dest timeout } {
 
151
    set output ""
 
152
    set shell_prompt [board_info $dest shell_prompt]
 
153
 
 
154
    remote_expect $dest $timeout {
 
155
        -re "^g\[\r\n\]\[\r\n\]?" {
 
156
            if { $output != "" } {
 
157
                append output $expect_out(buffer)
 
158
            }
 
159
            exp_continue
 
160
        }
 
161
        -re "(.*)$shell_prompt" {
 
162
            append output $expect_out(1,string)
 
163
            set status [check_for_board_status output]
 
164
            if { $status > 0 } {
 
165
                return [list $status $output]
 
166
            } else {
 
167
                if [regexp "Exception Cause=" $output] {
 
168
                    remote_reboot $dest
 
169
                    return [list -1 $output]
 
170
                }
 
171
                return [list 0 $output]
 
172
            }
 
173
        }
 
174
        -re "\[\r\n\]+" {
 
175
            append output $expect_out(buffer)
 
176
            if { [string length $output] < 512000 } {
 
177
                exp_continue
 
178
            } else {
 
179
                return [list -1 ""]
 
180
            }
 
181
        }
 
182
        default {
 
183
            return [list -1 ""]
 
184
        }
 
185
    }
 
186
}
 
187
 
 
188
set_board_info send_initial_cr 1
 
189
set_board_info protocol "ddb_ether"
 
190
set_board_info shell_prompt "NEC010> "