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

« back to all changes in this revision

Viewing changes to config/netware.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 J.T. Conklin. (jtc@cygnus.com)
 
21
 
 
22
#
 
23
# load support libraries
 
24
#
 
25
load_lib remote.exp
 
26
 
 
27
# set target variables only if needed
 
28
 
 
29
proc ${board}_init { args } {
 
30
    global NLMCONV
 
31
    if ![info exists NLMCONV] then {
 
32
        set NLMCONV [findfile "$rootme/../binutils/nlmconv"]
 
33
    }
 
34
    global LD
 
35
    if ![info exists LD] then {
 
36
        set LD [findfile "$rootme/../ld/ld-new" "$rootme/../ld/ld-new" [transform "ld"]]
 
37
    }
 
38
 
 
39
    set shell_prompt "Password:"
 
40
    set shell_id [remote_open target]
 
41
    if [target_info exists passwd] {
 
42
        set passwd [target_info passwd]
 
43
    } else {
 
44
        set passwd ""
 
45
    }
 
46
    if $shell_id<0 then {
 
47
        warning "Couldn't connect to target"
 
48
        return -1
 
49
    }
 
50
 
 
51
    if [string match "" $passwd] then {
 
52
        stty -echo
 
53
        send_user "Password: "
 
54
        expect_user -re "(.*)\n"
 
55
        send_user "\n"
 
56
        set passwd "$expect_out(1,string)"
 
57
        stty echo
 
58
    }
 
59
 
 
60
    send -i $shell_id "$passwd\n"
 
61
    expect {
 
62
        -i $shell_id ":" {
 
63
            verbose "Got termtype prompt" 0
 
64
        }
 
65
 
 
66
        -i $shell_id timeout {
 
67
            warning "Connection timed out"
 
68
            return -1
 
69
        }
 
70
    }
 
71
 
 
72
    # FIXME
 
73
    set shell_prompt "[string toupper [target_info name]]:"
 
74
    send -i $shell_id "1\n"
 
75
 
 
76
    expect {
 
77
        -i $shell_id -re "$shell_prompt" {}
 
78
        -i $shell_id timeout {
 
79
            warning "Connection timed out"
 
80
            return -1
 
81
        }
 
82
    }
 
83
}
 
84
 
 
85
 
 
86
#
 
87
# ${board}_load -- load the program and execute it
 
88
#
 
89
# See default.exp for explanation of arguments and results.
 
90
#
 
91
 
 
92
proc ${board}_load { dest prog args } {
 
93
    global LD NLMCONV
 
94
    global tmpdir
 
95
    global errorCode
 
96
 
 
97
    if [board_info $dest exists fileid] {
 
98
        set shell_id [board_info $dest fileid]
 
99
    } else {
 
100
        set shell_id -1
 
101
    }
 
102
 
 
103
    set output ""
 
104
 
 
105
    if $shell_id<0 then {
 
106
        verbose -log "$prog not executed because there is no target" 3
 
107
        return "untested"
 
108
    }
 
109
 
 
110
    #
 
111
    set exe [file tail $prog]
 
112
 
 
113
    # We can't blindly append a suffix to the object name, because the
 
114
    # result may not be valid on netware's 8.3 filesystem.
 
115
    set nlm "$tmpdir/x.nlm"
 
116
    set lnk "$tmpdir/x.lnk"
 
117
 
 
118
    # build *.lnk file
 
119
    set fd [open $lnk w]
 
120
    puts $fd "description \"$exe\""
 
121
    puts $fd "screenname \"System Console\""
 
122
    puts $fd "module clib.nlm"
 
123
    puts $fd "module mathlib.nlm"
 
124
    puts $fd "stack 65536"
 
125
    puts $fd "debug"
 
126
    # FIXME: don't hardcode location of prelude.o
 
127
    puts $fd "input /s1/cygnus/dejagnu/i386-netware/lib/prelude.o"
 
128
    puts $fd "input $prog"
 
129
    puts $fd "output $nlm"
 
130
    close $fd
 
131
 
 
132
    # run nlmconv
 
133
    verbose "Executing: $NLMCONV -l$LD -T$lnk" 1
 
134
    catch "exec $NLMCONV -l$LD -T$lnk" output
 
135
    if ![string match "" $output] then {
 
136
        verbose $output 1
 
137
    }
 
138
    if ![string match "NONE" $errorCode] {
 
139
        verbose -log "Can't link $prog" 3
 
140
        return "fail"
 
141
    }
 
142
 
 
143
    # download
 
144
    verbose "Downloading $nlm" 1
 
145
    catch "exec cp $nlm /.NetWare/[board_info $dest name].nws/sys.nwv/tmp/x.nlm" output
 
146
    if ![string match "" $output] then {
 
147
        verbose $output 1
 
148
        verbose -log "cp failed for $nlm" 3
 
149
        return "unresolved"
 
150
    }
 
151
 
 
152
    # Wait a second for the file to "settle" on the NetWare server.
 
153
    # I've encountered unexplained failures without this delay.
 
154
    #    sleep 1
 
155
 
 
156
 
 
157
    # The NetWare remote console expects to be connected to a vt100
 
158
    # compatible terminal.  It isn't very efficent, and it seems to
 
159
    # send screen repaints for no reason.  So we have to clear the
 
160
    # screen as we run each test, otherwise a shell prompt or abort
 
161
    # message from a previous test could cause incorrect results.
 
162
    send -i $shell_id "CLS\r\n"
 
163
    set timeout 1
 
164
    expect {
 
165
        -i $shell_id -re "$shell_prompt" {
 
166
            exp_continue
 
167
        }
 
168
    }
 
169
    set timeout 10
 
170
 
 
171
 
 
172
    # Netware does not support exit status.  The best we can do to
 
173
    # detect failures is to look for the "ABNORMAL NLM TERMINATION"
 
174
    # message printed by abort().
 
175
    set ret 0
 
176
    send -i $shell_id "LOAD X.NLM\r\n"
 
177
    expect {
 
178
        -i $shell_id "ABNORMAL NLM TERMINATION" {
 
179
            set ret 1
 
180
            exp_continue
 
181
        }
 
182
        -i $shell_id "Unable to find load file" {
 
183
            perror "Couldn't execute program"
 
184
            verbose -log "Couldn't execute program" 3
 
185
            return "unresolved"
 
186
        }
 
187
        -i $shell_id timeout {
 
188
            perror "Couldn't execute program (timed out)"
 
189
            verbose -log "Couldn't execute program (timed out)" 3
 
190
            return "unresolved"
 
191
        }
 
192
        -i $shell_id -re "[format "%sLOAD" $shell_prompt]" {
 
193
            exp_continue
 
194
        }
 
195
        -i $shell_id -re "$shell_prompt" {}
 
196
    }
 
197
 
 
198
    catch [exec rm -f $lnk]
 
199
    catch [exec rm -f $nlm]
 
200
 
 
201
    if { $ret == 0 } {
 
202
        return "pass"
 
203
    } else {
 
204
        return "fail"
 
205
    }
 
206
}
 
207
 
 
208
#
 
209
# ${tool}_exit -- shutdown the connection
 
210
#
 
211
 
 
212
proc ${board}_exit {} {
 
213
    remote_close target
 
214
}