30 |
# |
# |
31 |
|
|
32 |
proc udi_load { dest prog args } { |
proc udi_load { dest prog args } { |
33 |
set shell_prompt [board_info $dest shell_prompt]; |
set shell_prompt [board_info $dest shell_prompt] |
34 |
set output ""; |
set output "" |
35 |
|
|
36 |
if ![file exists $prog] then { |
if ![file exists $prog] then { |
37 |
perror "$prog does not exist." |
perror "$prog does not exist." |
38 |
verbose -log "$prog does not exist." 3 |
verbose -log "$prog does not exist." 3 |
39 |
return [list "untested" ""]; |
return [list "untested" ""] |
40 |
} |
} |
41 |
|
|
42 |
# Load the program. |
# Load the program. |
43 |
if ![board_info $dest exists fileid] then { |
if ![board_info $dest exists fileid] then { |
44 |
remote_open $dest; |
remote_open $dest |
45 |
if ![board_info $dest exists fileid] then { |
if ![board_info $dest exists fileid] then { |
46 |
verbose -log "$prog not executed, couldn't connect to $dest." 3 |
verbose -log "$prog not executed, couldn't connect to $dest." 3 |
47 |
return "untested" |
return "untested" |
50 |
|
|
51 |
if { [remote_ld $dest $prog] == "" } { |
if { [remote_ld $dest $prog] == "" } { |
52 |
verbose -log "$prog not executed, load failed." 3 |
verbose -log "$prog not executed, load failed." 3 |
53 |
return [list "unresolved" ""]; |
return [list "unresolved" ""] |
54 |
} |
} |
55 |
|
|
56 |
# Execute it. |
# Execute it. |
57 |
set result -1 |
set result -1 |
58 |
set output ""; |
set output "" |
59 |
set noappend 0; |
set noappend 0 |
60 |
|
|
61 |
verbose "Executing $prog." 2 |
verbose "Executing $prog." 2 |
62 |
remote_send $dest "g\n" |
remote_send $dest "g\n" |
63 |
# FIXME: The value 300 below should be a parameter. |
# FIXME: The value 300 below should be a parameter. |
64 |
remote_expect $dest 300 { |
remote_expect $dest 300 { |
65 |
-re "(.*)Process exited with 0x0\[^\r\n\]*\[\r\n\]" { |
-re "(.*)Process exited with 0x0\[^\r\n\]*\[\r\n\]" { |
66 |
append output $expect_out(1,string); |
append output $expect_out(1,string) |
67 |
verbose "$prog executed successfully" 2 |
verbose "$prog executed successfully" 2 |
68 |
set noappend 1; |
set noappend 1 |
69 |
set result 0; |
set result 0 |
70 |
exp_continue; |
exp_continue |
71 |
} |
} |
72 |
-re "(.*)Halt instruction encountered" { |
-re "(.*)Halt instruction encountered" { |
73 |
append output $expect_out(1,string); |
append output $expect_out(1,string) |
74 |
verbose "$prog got a HALT instruction" 2 |
verbose "$prog got a HALT instruction" 2 |
75 |
set result 1; |
set result 1 |
76 |
set noappend 1; |
set noappend 1 |
77 |
exp_continue; |
exp_continue |
78 |
} |
} |
79 |
-re "(^|\[\r\n\])$shell_prompt" { |
-re "(^|\[\r\n\])$shell_prompt" { |
80 |
if { $result == -1 } { |
if { $result == -1 } { |
81 |
exp_continue; |
exp_continue |
82 |
} |
} |
83 |
} |
} |
84 |
-re "(^|\[\r\n\]+)g\[\r\n\]+" { |
-re "(^|\[\r\n\]+)g\[\r\n\]+" { |
85 |
exp_continue; |
exp_continue |
86 |
} |
} |
87 |
-re "\[\r\n\]+" { |
-re "\[\r\n\]+" { |
88 |
if { ! $noappend } { |
if { ! $noappend } { |
89 |
append output $expect_out(buffer); |
append output $expect_out(buffer) |
90 |
if { [string length $output] < 512000 } { |
if { [string length $output] < 512000 } { |
91 |
exp_continue; |
exp_continue |
92 |
} else { |
} else { |
93 |
set result 1; |
set result 1 |
94 |
} |
} |
95 |
} else { |
} else { |
96 |
exp_continue; |
exp_continue |
97 |
} |
} |
98 |
} |
} |
99 |
timeout { |
timeout { |
104 |
# See what happened. |
# See what happened. |
105 |
switch -- $result { |
switch -- $result { |
106 |
0 { |
0 { |
107 |
set status [check_for_board_status output]; |
set status [check_for_board_status output] |
108 |
if { $status < 0 } { |
if { $status < 0 } { |
109 |
blammo |
blammo |
110 |
} |
} |
111 |
if { $status > 0 } { |
if { $status > 0 } { |
112 |
set result "fail"; |
set result "fail" |
113 |
} else { |
} else { |
114 |
set result "pass" |
set result "pass" |
115 |
} |
} |
125 |
# Get nastier. We want to leave the system in a state |
# Get nastier. We want to leave the system in a state |
126 |
# ready to run the next testcase. |
# ready to run the next testcase. |
127 |
remote_send $dest "q\n" |
remote_send $dest "q\n" |
128 |
remote_close $dest; |
remote_close $dest |
129 |
set udi_shell_id [remote_open $dest] |
set udi_shell_id [remote_open $dest] |
130 |
if { $udi_shell_id < 0 } { |
if { $udi_shell_id < 0 } { |
131 |
perror "Couldn't reset $dest." |
perror "Couldn't reset $dest." |
142 |
set result "unresolved" |
set result "unresolved" |
143 |
} |
} |
144 |
} |
} |
145 |
return [list $result $output]; |
return [list $result $output] |
146 |
} |
} |
147 |
|
|
148 |
# |
# |
150 |
# |
# |
151 |
|
|
152 |
proc udi_exit {} { |
proc udi_exit {} { |
153 |
remote_close target; |
remote_close target |
154 |
} |
} |
155 |
|
|
156 |
set_board_info protocol "udi"; |
set_board_info protocol "udi" |
157 |
set_board_info connect "mondfe"; |
set_board_info connect "mondfe" |
158 |
set_board_info shell_prompt "mondfe>"; |
set_board_info shell_prompt "mondfe>" |