/[dejagnu]/dejagnu/config/vxworks.exp
ViewVC logotype

Diff of /dejagnu/config/vxworks.exp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by rsavoye, Mon Mar 17 02:25:07 2003 UTC revision 1.4 by bje, Thu Aug 7 03:42:43 2003 UTC
# Line 25  Line 25 
25  #  #
26  proc ${board}_init { dest } {  proc ${board}_init { dest } {
27      # This is not the right way to determine the required OS...      # This is not the right way to determine the required OS...
28      global target_os;      global target_os
29      set shell_prompt [board_info $dest shell_prompt];      set shell_prompt [board_info $dest shell_prompt]
30      set do_reboot 0;      set do_reboot 0
31    
32      set desired_kernel [board_info $dest "kernel,$target_os"];      set desired_kernel [board_info $dest "kernel,$target_os"]
33            
34      if { $desired_kernel == "" } {      if { $desired_kernel == "" } {
35          vxworks_final_init $dest;          vxworks_final_init $dest
36          # Nothing to see here, nothing to do. Move along.          # Nothing to see here, nothing to do. Move along.
37          return;          return
38      }      }
39    
40      remote_raw_open $dest raw;      remote_raw_open $dest raw
41      remote_send $dest "\n";      remote_send $dest "\n"
42      remote_expect $dest 5 {      remote_expect $dest 5 {
43          -re "$shell_prompt" {          -re "$shell_prompt" {
44              set do_reboot 1;              set do_reboot 1
45          }          }
46          -re "Press any key to stop auto-boot" {          -re "Press any key to stop auto-boot" {
47              remote_send $dest "\n";              remote_send $dest "\n"
48              exp_continue;              exp_continue
49          }          }
50          -re "VxWorks Boot" {          -re "VxWorks Boot" {
51              set boot_mon 0;              set boot_mon 0
52              set boot_mon_prompt "VxWorks Boot";              set boot_mon_prompt "VxWorks Boot"
53          }          }
54          -re "\[0-9\]\[\r\n\]+ *\[0-9\]\[\r\n\]" {          -re "\[0-9\]\[\r\n\]+ *\[0-9\]\[\r\n\]" {
55              remote_send $dest "\n";              remote_send $dest "\n"
56              exp_continue;              exp_continue
57          }          }
58          timeout {          timeout {
59              set do_reboot 1;              set do_reboot 1
60          }          }
61      }      }
62    
63      if { $do_reboot } {      if { $do_reboot } {
64          remote_close $dest;          remote_close $dest
65          remote_reboot $dest;          remote_reboot $dest
66          return;          return
67      }      }
68      remote_binary $dest;      remote_binary $dest
69      remote_send $dest "\n\n";      remote_send $dest "\n\n"
70      remote_expect $dest 3 {      remote_expect $dest 3 {
71          timeout {}          timeout {}
72          -re ".+" { exp_continue; }          -re ".+" { exp_continue; }
73      }      }
74      remote_send $dest "p\n";      remote_send $dest "p\n"
75      remote_expect $dest 20 {      remote_expect $dest 20 {
76          -re "file name\[ \t\]+: (\[^ \r\n\]+)\[ \r\n\]+" {          -re "file name\[ \t\]+: (\[^ \r\n\]+)\[ \r\n\]+" {
77              set curr_file $expect_out(1,string);              set curr_file $expect_out(1,string)
78              exp_continue;              exp_continue
79          }          }
80          -re "$boot_mon_prompt" { }          -re "$boot_mon_prompt" { }
81      }      }
82      if ![info exists curr_file] {      if ![info exists curr_file] {
83          remote_close $dest;          remote_close $dest
84          remote_reboot $dest;          remote_reboot $dest
85          return;          return
86      }      }
87      if { $curr_file != $desired_kernel } {      if { $curr_file != $desired_kernel } {
88          verbose "$curr_file != '$desired_kernel'";          verbose "$curr_file != '$desired_kernel'"
89          # Oh boy.          # Oh boy.
90          remote_send $dest "c\n";          remote_send $dest "c\n"
91          remote_expect $dest 20 {          remote_expect $dest 20 {
92              -re "file name\[ \t\]+:.*$" {              -re "file name\[ \t\]+:.*$" {
93                  remote_send $dest "$desired_kernel\n";                  remote_send $dest "$desired_kernel\n"
94                  exp_continue;                  exp_continue
95              }              }
96              -re "\[a-z() \t\]+:.*$" {              -re "\[a-z() \t\]+:.*$" {
97                  remote_send $dest "\n";                  remote_send $dest "\n"
98                  exp_continue;                  exp_continue
99              }              }
100              -re "$boot_mon_prompt" {}              -re "$boot_mon_prompt" {}
101          }          }
102      }      }
103      remote_send $dest "@\n";      remote_send $dest "@\n"
104      remote_expect $dest 30 {      remote_expect $dest 30 {
105          -re "(^|\[\r\n\])$shell_prompt" {}          -re "(^|\[\r\n\])$shell_prompt" {}
106          -re ".+" {          -re ".+" {
107              exp_continue;              exp_continue
108          }          }
109      }      }
110      vxworks_final_init $dest;      vxworks_final_init $dest
111      remote_close $dest;      remote_close $dest
112  }  }
113    
114  proc vxworks_final_init { dest } {  proc vxworks_final_init { dest } {
# Line 116  proc vxworks_final_init { dest } { Line 116  proc vxworks_final_init { dest } {
116          if { [target_compile [board_info $dest preload_obj] foo.out object [board_info $dest preload_obj_flags]] == "" } {          if { [target_compile [board_info $dest preload_obj] foo.out object [board_info $dest preload_obj_flags]] == "" } {
117              vxworks_ld $dest foo.out              vxworks_ld $dest foo.out
118          }          }
119          remote_file build delete foo.out;          remote_file build delete foo.out
120      }      }
121  }  }
122  #  #
# Line 124  proc vxworks_final_init { dest } { Line 124  proc vxworks_final_init { dest } {
124  #  #
125    
126  proc vxworks_exec { dest program pargs inp outp } {  proc vxworks_exec { dest program pargs inp outp } {
127      global decimal hex;      global decimal hex
128    
129      set shell_id [vxworks_open $dest];      set shell_id [vxworks_open $dest]
130      if { $shell_id < 0 } {      if { $shell_id < 0 } {
131          return [list -1 "open failure"];          return [list -1 "open failure"]
132      }      }
133    
134      if { $inp != "" } {      if { $inp != "" } {
135          set inp [remote_download $dest $inp];          set inp [remote_download $dest $inp]
136          set suffix " < $inp";          set suffix " < $inp"
137      } else {      } else {
138          set suffix ""          set suffix ""
139      }      }
140    
141      set shell_prompt [board_info $dest shell_prompt];      set shell_prompt [board_info $dest shell_prompt]
142      remote_send $dest "${program} ${pargs}$suffix\n";      remote_send $dest "${program} ${pargs}$suffix\n"
143      # FIXME: The value 300 below should probably be a parameter passed in.      # FIXME: The value 300 below should probably be a parameter passed in.
144      remote_expect $dest 300 {      remote_expect $dest 300 {
145          -re "\\\[VxWorks Boot\\\]:" {          -re "\\\[VxWorks Boot\\\]:" {
146              remote_send $dest "@\n";              remote_send $dest "@\n"
147              sleep 20;              sleep 20
148              exp_continue;              exp_continue
149          }          }
150          -re "(.*)value = (-*$decimal) = $hex\[^\r\n\]*\[\r\n\]+$shell_prompt" {          -re "(.*)value = (-*$decimal) = $hex\[^\r\n\]*\[\r\n\]+$shell_prompt" {
151              set result [list $expect_out(2,string) $expect_out(1,string)];              set result [list $expect_out(2,string) $expect_out(1,string)]
152          }          }
153          -re "undefined symbol: .*$shell_prompt" {          -re "undefined symbol: .*$shell_prompt" {
154              set result [list 1 "unknown command"];              set result [list 1 "unknown command"]
155          }          }
156          -re "syntax error.*$shell_prompt" {          -re "syntax error.*$shell_prompt" {
157              set result [list -1 "syntax error in command"];              set result [list -1 "syntax error in command"]
158          }          }
159          default {          default {
160              set result [list -1 "unable to execute command"];              set result [list -1 "unable to execute command"]
161          }          }
162      }      }
163      if { $suffix != "" } {      if { $suffix != "" } {
164          remote_file $dest delete $inp;          remote_file $dest delete $inp
165      }      }
166      return $result;      return $result
167  }  }
168    
169  proc vxworks_download { dest localfile remotefile } {  proc vxworks_download { dest localfile remotefile } {
170      if [board_info $dest exists vxworks_homedir] {      if [board_info $dest exists vxworks_homedir] {
171          set rfile "[board_info $dest vxworks_homedir]/$remotefile";          set rfile "[board_info $dest vxworks_homedir]/$remotefile"
172          remote_download build $localfile $rfile;          remote_download build $localfile $rfile
173          return $rfile;          return $rfile
174      }      }
175      return [remote_raw_download $dest $localfile $remotefile];      return [remote_raw_download $dest $localfile $remotefile]
176  }  }
177    
178  proc vxworks_file { dest op args } {  proc vxworks_file { dest op args } {
179      set file [lindex $args 0];      set file [lindex $args 0]
180      if [board_info $dest exists vxworks_homedir] {      if [board_info $dest exists vxworks_homedir] {
181          set dir "[board_info $dest vxworks_homedir]";          set dir "[board_info $dest vxworks_homedir]"
182          switch $op {          switch $op {
183              exists {              exists {
184                  set file "${dir}/[file tail $file]";                  set file "${dir}/[file tail $file]"
185                  return [file exists $file];                  return [file exists $file]
186              }              }
187              delete {              delete {
188                  foreach x $args {                  foreach x $args {
189                      set x "${dir}/[file tail $x]";                      set x "${dir}/[file tail $x]"
190                      if { [file exists $x] && [file isfile $x] } {                      if { [file exists $x] && [file isfile $x] } {
191                          exec rm -f $x;                          exec rm -f $x
192                      }                      }
193                  }                  }
194                  return;                  return
195              }              }
196          }          }
197      }      }
198      return [eval remote_raw_file \"$dest\" \"$op\" $args];      return [eval remote_raw_file \"$dest\" \"$op\" $args]
199  }  }
200    
201  proc vxworks_send { dest string } {  proc vxworks_send { dest string } {
202      # Convert LFs to CRs, 'cause that is what VxWorks wants to see.      # Convert LFs to CRs, 'cause that is what VxWorks wants to see.
203      regsub -all "\n" $string "\r" string;      regsub -all "\n" $string "\r" string
204      verbose "Sending '$string' to $dest" 2      verbose "Sending '$string' to $dest" 2
205      return [remote_raw_send $dest "$string"];      return [remote_raw_send $dest "$string"]
206  }  }
207    
208  proc vxworks_open { dest args } {  proc vxworks_open { dest args } {
209      if [board_info $dest exists fileid] {      if [board_info $dest exists fileid] {
210          return [board_info $dest fileid];          return [board_info $dest fileid]
211      }      }
212    
213      set shell_prompt [board_info $dest shell_prompt]      set shell_prompt [board_info $dest shell_prompt]
214    
215      set shell_id [remote_raw_open $dest];      set shell_id [remote_raw_open $dest]
216    
217      if { $shell_id == "" || $shell_id < 0 } {      if { $shell_id == "" || $shell_id < 0 } {
218          return -1;          return -1
219      }      }
220    
221      if [board_info $dest exists logname] {      if [board_info $dest exists logname] {
222          set logname [board_info $dest logname];          set logname [board_info $dest logname]
223          if [board_info $dest exists password] {          if [board_info $dest exists password] {
224              remote_send $dest "iam \"$logname\",\"[board_info $dest passwd]\"\r"              remote_send $dest "iam \"$logname\",\"[board_info $dest passwd]\"\r"
225          } else {          } else {
# Line 235  proc vxworks_open { dest args } { Line 235  proc vxworks_open { dest args } {
235                  # or `warning' should be used here.  There are *lots* of other                  # or `warning' should be used here.  There are *lots* of other
236                  # cases like this.                  # cases like this.
237                  perror "Couldn't set default user."                  perror "Couldn't set default user."
238                  return -1;                  return -1
239              }              }
240          }          }
241      }      }
242    
243      set dir "";      set dir ""
244      if [board_info $dest exists ftp_directory] {      if [board_info $dest exists ftp_directory] {
245          set dir [board_info $dest ftp_directory];          set dir [board_info $dest ftp_directory]
246      }      }
247      if [board_info $dest exists vxworks_homedir] {      if [board_info $dest exists vxworks_homedir] {
248          set dir [board_info $dest vxworks_homedir];          set dir [board_info $dest vxworks_homedir]
249      }      }
250      if { $dir != "" } {      if { $dir != "" } {
251          set status [remote_exec $dest "cd" "\"$dir\""];          set status [remote_exec $dest "cd" "\"$dir\""]
252          if [lindex $status 0] {          if [lindex $status 0] {
253              perror "Error in cd to $dir--[lindex $status 1]";              perror "Error in cd to $dir--[lindex $status 1]"
254              return 1;              return 1
255          }          }
256      }      }
257      return $shell_id;      return $shell_id
258  }  }
259  #  #
260  # Load a file into vxworks  # Load a file into vxworks
# Line 269  proc vxworks_ld { dest prog } { Line 269  proc vxworks_ld { dest prog } {
269      global board_info      global board_info
270    
271      if { $prog == "" } {      if { $prog == "" } {
272          return 1;          return 1
273      }      }
274    
275      set shell_id [remote_open $dest];      set shell_id [remote_open $dest]
276    
277      if { $shell_id < 0 } {      if { $shell_id < 0 } {
278          return -1;          return -1
279      }      }
280    
281      set prog [remote_download $dest $prog];      set prog [remote_download $dest $prog]
282    
283      set shell_prompt [board_info $dest shell_prompt];      set shell_prompt [board_info $dest shell_prompt]
284    
285      # We always want to exit the program via the code at the end.      # We always want to exit the program via the code at the end.
286      # If the load fails we want `expect_out' stored in the log and this      # If the load fails we want `expect_out' stored in the log and this
287      # saves duplicating that code.      # saves duplicating that code.
288    
289      for { set x 0 ; } { $x < 3 } {incr x; } {      for { set x 0 ; } { $x < 3 } {incr x; } {
290          remote_send $dest "\n";          remote_send $dest "\n"
291          remote_expect $dest 30 {          remote_expect $dest 30 {
292              -re ".*$shell_prompt $" { set x 20; }              -re ".*$shell_prompt $" { set x 20; }
293              -re "\\\[VxWorks Boot\\\]:" {              -re "\\\[VxWorks Boot\\\]:" {
294                  remote_send $dest "@\n";                  remote_send $dest "@\n"
295                  sleep 20;                  sleep 20
296                  exp_continue;                  exp_continue
297              }              }
298              timeout { return -1; }              timeout { return -1; }
299          }          }
# Line 305  proc vxworks_ld { dest prog } { Line 305  proc vxworks_ld { dest prog } {
305    
306      while { $result == -7 && $tries < $maxtries } {      while { $result == -7 && $tries < $maxtries } {
307          verbose "Loading $prog into vxworks."          verbose "Loading $prog into vxworks."
308          remote_send $dest "ld < $prog\n";          remote_send $dest "ld < $prog\n"
309          incr tries          incr tries
310          remote_expect $dest 300 {          remote_expect $dest 300 {
311              -re "USER.*command not understood" {              -re "USER.*command not understood" {
# Line 330  proc vxworks_ld { dest prog } { Line 330  proc vxworks_ld { dest prog } {
330              }              }
331              -re "value = (-*${decimal}) = ${hex}.*$shell_prompt $" {              -re "value = (-*${decimal}) = ${hex}.*$shell_prompt $" {
332                  verbose "Loaded $prog into vxworks."                  verbose "Loaded $prog into vxworks."
333                  set board_info([board_info $dest name],vx_module) $expect_out(1,string);                  set board_info([board_info $dest name],vx_module) $expect_out(1,string)
334                  set result 0                  set result 0
335              }              }
336              -re "(.*)$shell_prompt $" {              -re "(.*)$shell_prompt $" {
# Line 347  proc vxworks_ld { dest prog } { Line 347  proc vxworks_ld { dest prog } {
347          send_log "$expect_out(buffer)"          send_log "$expect_out(buffer)"
348      }      }
349    
350      remote_file $dest delete $prog;      remote_file $dest delete $prog
351      return $result      return $result
352  }  }
353    
# Line 360  proc vxworks_ld { dest prog } { Line 360  proc vxworks_ld { dest prog } {
360  # -1 - unresolved, may be fixed by rebooting  # -1 - unresolved, may be fixed by rebooting
361  #  #
362  proc vxworks_run { dest function pargs inp outp } {  proc vxworks_run { dest function pargs inp outp } {
363      global hex decimal;      global hex decimal
364    
365      set shell_prompt [board_info $dest shell_prompt];      set shell_prompt [board_info $dest shell_prompt]
366      set output "";      set output ""
367    
368      # There isn't a command to wait for a thread to finish, so we have to keep      # There isn't a command to wait for a thread to finish, so we have to keep
369      # polling. Instead, we expect the status wrapper to return an exit      # polling. Instead, we expect the status wrapper to return an exit
370      # status.      # status.
371    
372      set status [remote_exec $dest "sp" "$function $pargs" $inp $outp];      set status [remote_exec $dest "sp" "$function $pargs" $inp $outp]
373    
374      set tid [lindex $status 0];      set tid [lindex $status 0]
375    
376      # Bad task id, reboot and try again.      # Bad task id, reboot and try again.
377      if { $tid == -1 || $tid == 0 } {      if { $tid == -1 || $tid == 0 } {
378          return -1;          return -1
379      }      }
380    
381      set result 1;      set result 1
382      # FIXME: The value 300 below should be a parameter.      # FIXME: The value 300 below should be a parameter.
383      remote_expect $dest 300 {      remote_expect $dest 300 {
384          -re "task ${hex} - aborted.*$shell_prompt $" {          -re "task ${hex} - aborted.*$shell_prompt $" {
# Line 388  proc vxworks_run { dest function pargs i Line 388  proc vxworks_run { dest function pargs i
388          }          }
389          -re "\[\r\n\]syntax error\[\r\n\]" {          -re "\[\r\n\]syntax error\[\r\n\]" {
390              verbose "weirdness after task started"              verbose "weirdness after task started"
391              set result -1;              set result -1
392          }          }
393          -re "(.*)\\*\\*\\* EXIT code ($decimal)\[\r\n\]" {          -re "(.*)\\*\\*\\* EXIT code ($decimal)\[\r\n\]" {
394              set output "$expect_out(1,string)";              set output "$expect_out(1,string)"
395              set exit_code "$expect_out(2,string)";              set exit_code "$expect_out(2,string)"
396              if { ($exit_code + 0) != 0 } {              if { ($exit_code + 0) != 0 } {
397                  set result 1;                  set result 1
398              } else {              } else {
399                  set result 0;                  set result 0
400              }              }
401          }          }
402          -re "Operation Fault.*fault type:" {          -re "Operation Fault.*fault type:" {
403              set result 1;              set result 1
404          }          }
405          -re "Bus Error" {          -re "Bus Error" {
406              # This is here to try to cope with apparently flaky h/w.              # This is here to try to cope with apparently flaky h/w.
407              # This is potentially an error in the testcase, but we don't              # This is potentially an error in the testcase, but we don't
408              # really know, do we?              # really know, do we?
409              warning "Bus Error."              warning "Bus Error."
410              set result 1;              set result 1
411              set output "Bus Error";              set output "Bus Error"
412              remote_reboot $dest;              remote_reboot $dest
413          }          }
414          timeout {          timeout {
415              # Infinite loop? probably.              # Infinite loop? probably.
416              remote_exec $dest "td" "$tid";              remote_exec $dest "td" "$tid"
417              set result 1;              set result 1
418          }          }
419      }      }
420    
421      return [list $result $output];      return [list $result $output]
422  }  }
423    
424  #  #
425  # Unload the last executable that we loaded, so we can free up its memory.  # Unload the last executable that we loaded, so we can free up its memory.
426  #  #
427  proc vxworks_unld { dest } {  proc vxworks_unld { dest } {
428      global board_info;      global board_info
429    
430      if [board_info $dest exists vx_module] {      if [board_info $dest exists vx_module] {
431          # Vxworks5.0 does not have the unld command.          # Vxworks5.0 does not have the unld command.
432          if { [board_info $dest os] != "vxworks5.0" } {          if { [board_info $dest os] != "vxworks5.0" } {
433              remote_exec $dest "unld" "[board_info $dest vx_module]";              remote_exec $dest "unld" "[board_info $dest vx_module]"
434          }          }
435          unset board_info([board_info $dest name],vx_module);          unset board_info([board_info $dest name],vx_module)
436      }      }
437  }  }
438    
# Line 441  proc vxworks_unld { dest } { Line 441  proc vxworks_unld { dest } {
441  # "work" or we give up.  # "work" or we give up.
442  #  #
443  proc vxworks_load {dest prog args} {  proc vxworks_load {dest prog args} {
444      set result "";      set result ""
445      set output "";      set output ""
446    
447      if { [llength $args] > 0 } {      if { [llength $args] > 0 } {
448          set pargs "[lindex $args 0]";          set pargs "[lindex $args 0]"
449      } else {      } else {
450          set pargs ""          set pargs ""
451      }      }
452    
453      if { [llength $args] > 1 } {      if { [llength $args] > 1 } {
454          set inp "[lindex $args 1]";          set inp "[lindex $args 1]"
455      } else {      } else {
456          set inp ""          set inp ""
457      }      }
458    
459      if { [llength $args] > 2 } {      if { [llength $args] > 2 } {
460          set outp "[lindex $args 2]";          set outp "[lindex $args 2]"
461      } else {      } else {
462          set outp ""          set outp ""
463      }      }
464    
465      for { set x 0; } { $x < 3 } { incr x } {      for { set x 0; } { $x < 3 } { incr x } {
466          set status [vxworks_ld $dest $prog];          set status [vxworks_ld $dest $prog]
467          if { $status >= 0 } {          if { $status >= 0 } {
468              if { $status > 0 } {              if { $status > 0 } {
469                  set result "fail";                  set result "fail"
470              } else {              } else {
471                  set out [vxworks_run $dest __wrap_main $pargs $inp $outp];                  set out [vxworks_run $dest __wrap_main $pargs $inp $outp]
472                  set status [lindex $out 0];                  set status [lindex $out 0]
473                  set output [lindex $out 1];                  set output [lindex $out 1]
474                  # Get rid of the carriage returns, because they confuse                  # Get rid of the carriage returns, because they confuse
475                  # callers that try to parse the result.                  # callers that try to parse the result.
476                  regsub -all "\r" $output "" output                  regsub -all "\r" $output "" output
477                  if { $status != 0 } {                  if { $status != 0 } {
478                      if { $status > 0 } {                      if { $status > 0 } {
479                          set result "fail";                          set result "fail"
480                      }                      }
481                  } else {                  } else {
482                      set result "pass";                      set result "pass"
483                  }                  }
484              }              }
485          }          }
486          if { $result != "" } {          if { $result != "" } {
487              vxworks_unld $dest;              vxworks_unld $dest
488              return [list $result $output];              return [list $result $output]
489          }          }
490          remote_reboot $dest;          remote_reboot $dest
491      }      }
492      return [list "fail" ""];      return [list "fail" ""]
493  }  }
494    
495  set_board_info protocol "vxworks"  set_board_info protocol "vxworks"
# Line 507  set_board_info wrap_compile_flags "-DNO_ Line 507  set_board_info wrap_compile_flags "-DNO_
507    
508  set_board_info gdb_prompt "\[(\]vxgdb\[)\]"  set_board_info gdb_prompt "\[(\]vxgdb\[)\]"
509    
510  set_board_info is_vxworks 1;  set_board_info is_vxworks 1
511  set_board_info gdb,nosignals 1;  set_board_info gdb,nosignals 1

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26