~ubuntu-branches/ubuntu/feisty/dejagnu/feisty

« back to all changes in this revision

Viewing changes to config/udi.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
 
 
19
# When using the simulator (-n iss) and running nice'd, things can naturally
 
20
# take a little longer, so increase the timeout.
 
21
 
 
22
#
 
23
# udi_load -- load the program and execute it
 
24
#
 
25
# See default.exp for explanation of arguments and results.
 
26
#
 
27
 
 
28
proc udi_load { dest prog args } {
 
29
    set shell_prompt [board_info $dest shell_prompt]
 
30
    set output ""
 
31
 
 
32
    if ![file exists $prog] then {
 
33
        perror "$prog does not exist."
 
34
        verbose -log "$prog does not exist." 3
 
35
        return [list "untested" ""]
 
36
    }
 
37
 
 
38
    # Load the program.
 
39
    if ![board_info $dest exists fileid] then {
 
40
        remote_open $dest
 
41
        if ![board_info $dest exists fileid] then {
 
42
            verbose -log "$prog not executed, couldn't connect to $dest." 3
 
43
            return "untested"
 
44
        }
 
45
    }
 
46
 
 
47
    if { [remote_ld $dest $prog] == "" } {
 
48
        verbose -log "$prog not executed, load failed." 3
 
49
        return [list "unresolved" ""]
 
50
    }
 
51
 
 
52
    # Execute it.
 
53
    set result -1
 
54
    set output ""
 
55
    set noappend 0
 
56
 
 
57
    verbose "Executing $prog." 2
 
58
    remote_send $dest "g\n"
 
59
    # FIXME: The value 300 below should be a parameter.
 
60
    remote_expect $dest 300 {
 
61
        -re "(.*)Process exited with 0x0\[^\r\n\]*\[\r\n\]" {
 
62
            append output $expect_out(1,string)
 
63
            verbose "$prog executed successfully" 2
 
64
            set noappend 1
 
65
            set result 0
 
66
            exp_continue
 
67
        }
 
68
        -re "(.*)Halt instruction encountered" {
 
69
            append output $expect_out(1,string)
 
70
            verbose "$prog got a HALT instruction" 2
 
71
            set result 1
 
72
            set noappend 1
 
73
            exp_continue
 
74
        }
 
75
        -re "(^|\[\r\n\])$shell_prompt" {
 
76
            if { $result == -1 } {
 
77
                exp_continue
 
78
            }
 
79
        }
 
80
        -re "(^|\[\r\n\]+)g\[\r\n\]+" {
 
81
            exp_continue
 
82
        }
 
83
        -re "\[\r\n\]+" {
 
84
            if { ! $noappend } {
 
85
                append output $expect_out(buffer)
 
86
                if { [string length $output] < 512000 } {
 
87
                    exp_continue
 
88
                } else {
 
89
                    set result 1
 
90
                }
 
91
            } else {
 
92
                exp_continue
 
93
            }
 
94
        }
 
95
        timeout {
 
96
            warning "$prog timed out."
 
97
        }
 
98
    }
 
99
 
 
100
    # See what happened.
 
101
    switch -- $result {
 
102
        0 {
 
103
            set status [check_for_board_status output]
 
104
            if { $status < 0 } {
 
105
                blammo
 
106
            }
 
107
            if { $status > 0 } {
 
108
                set result "fail"
 
109
            } else {
 
110
                set result "pass"
 
111
            }
 
112
        }
 
113
        1 - -1 {
 
114
            warning "Resetting $dest."
 
115
            remote_send $dest "r\n"
 
116
            remote_expect $dest 5 {
 
117
                -re "r.*$shell_prompt.*" {
 
118
                    verbose "Target reset." 2
 
119
                }
 
120
                timeout {
 
121
                    # Get nastier.  We want to leave the system in a state
 
122
                    # ready to run the next testcase.
 
123
                    remote_send $dest "q\n"
 
124
                    remote_close $dest
 
125
                    set udi_shell_id [remote_open $dest]
 
126
                    if { $udi_shell_id < 0 } {
 
127
                        perror "Couldn't reset $dest."
 
128
                    }
 
129
                }
 
130
            }
 
131
            if { $result == 1 } {
 
132
                set result "fail"
 
133
            } else {
 
134
                set result "unresolved"
 
135
            }
 
136
        }
 
137
        default {
 
138
            set result "unresolved"
 
139
        }
 
140
    }
 
141
    return [list $result $output]
 
142
}
 
143
 
 
144
#
 
145
# udi_exit -- shutdown the connection (or simulator)
 
146
#
 
147
 
 
148
proc udi_exit {} {
 
149
    remote_close target
 
150
}
 
151
 
 
152
set_board_info protocol "udi"
 
153
set_board_info connect "mondfe"
 
154
set_board_info shell_prompt "mondfe>"