www.pudn.com > uboot_tftp_test.rar > uboot_tftp_test.exp
#!/usr/bin/expect
set LOG_FILE "/home/gxu/logs/test1-log"
set TFTP_LOAD_ADDR "0x1000000"
set KERNEL_FLASH_LOC "0x20100000"
set KERNEL_FLASH_END "0x201FFFFF"
set KERNEL_FLASH_SIZE "0x110000"
# run the test for this many seconds (86400 is 24 hours)
set EXECUTE_TIME 86400
set UBOOT_PROMPT "BOOT> "
set KERNEL_PROMPT "Sash command shell"
set timeout 30
set SUCCESS "success"
set FAILURE "failure"
set WARNING "warning"
#
# We have a temp log file and a summary log file. The temp log
# is overwritten on every execution. The summary is appended.
#
log_file $LOG_FILE
set argc [llength $argv]
if { $argc != 2} {
puts "TEST1 Program:"
puts " repeat for 24 hours"
puts " reset board"
puts " watch for countdown"
puts " stop count if count detected, skip to top of loop if timeout"
puts " download uImage using tftp"
puts " do a bootm"
puts " wait for uClinux prompt or timeout"
puts " at the end of 24 hours, print the results"
puts " "
puts "Usage: $argv0 output_pin uImage"
puts " where output_pin in the parallel port pin number to reset board"
puts " where uImage is a valid uImage"
puts " "
puts "NOTE: The board must be set up with the correct environment vars"
puts " for networking. Also, minicom must be set up correctly."
exit
}
# grab the user selections.
set output_pin [lindex $argv 0]
set uImage [lindex $argv 1]
send_log "{test1 started on [exec date]}"
send_log "output_pin=$output_pin"
send_log "uImage=$uImage"
puts "start up minicom"
log_user 0
spawn minicom
set minicom_spawn_id $spawn_id
puts $minicom_spawn_id
while 1 {
expect {
"Welcome to minicom" {
log_user 1
break
}
timeout {
puts "\nFATAL ERROR: Failed to start up minicom"
exit
}
}
}
set total_count 0
set reset_timeout_count 0
set no_countdown_count 0
set uboot_lost_count 0
set tftp_lost_count 0
set tftp_timeout_count 0
set kernel_prompt_timeout_count 0
set start_time [timestamp]
set end_time [expr $start_time + $EXECUTE_TIME]
while {[timestamp] < $end_time} {
incr total_count
puts "Next iteration: time is [exec date]"
send_log "\n\nNEXT ITERATION: time is [exec date]\n"
puts "\nReset board"
send_log "Reset board\n"
set timeout 30
spawn ./reset_board $output_pin
set temp_status $FAILURE
while 1 {
expect {
timeout {
puts "\nERROR: Failed to reset target board, reset script didn't work"
send_log "FATAL ERROR: reset_board program failed"
set temp_status $FAILURE
incr reset_timeout_count
break
}
eof {
set temp_status $SUCCESS
break
}
}
}
if { $temp_status == $FAILURE } {
continue
}
# Now go back to the minicom session
set spawn_id $minicom_spawn_id
puts "Wait for uboot countdown"
send_log "Wait for uboot countdown\n"
set temp_status $FAILURE
while 1 {
expect {
"Hit any key to stop" {
send "\r"
log_user 1
set temp_status $SUCCESS
break
}
timeout {
break
}
}
}
if { $temp_status == $FAILURE } {
puts "\nERROR: Failed to reset target board, no response"
send_log "Failed to see uboot prompt, start next iteration\n"
incr no_countdown_count
continue
}
puts "wait for uboot prompt"
send_log "wait for uboot prompt"
set temp_status $FAILURE
while 1 {
expect {
$UBOOT_PROMPT {
set temp_status $SUCCESS
break
}
timeout {
break
}
}
}
if { $temp_status == $FAILURE } {
puts "\nBIZZARE ERROR: Uboot got lost when starting up"
send_log "Bizzare error: uboot got lost when starting up, next iteration\n"
incr uboot_lost_count
continue
}
puts "tftp $uImage"
send_log "tftp uImage\n"
set timeout 30
send "tftp $TFTP_LOAD_ADDR $uImage\r"
set temp_status_flag $FAILURE
while 1 {
expect {
"Bytes transferred" {
set temp_status_flag $SUCCESS
break
}
timeout {
puts "\nERROR: tftp timed out, transferring kernel"
send_log "ERROR: tftp timed out\n"
incr tftp_timeout_count
break
}
}
}
if { $temp_status_flag == $FAILURE } {
continue
}
set temp_status_flag $FAILURE
while 1 {
expect {
$UBOOT_PROMPT {
set temp_status_flag $SUCCESS
break
}
timeout {
puts "\nERROR: tftp got lost transferring kernel"
send_log "ERROR: tftp got lost\n"
incr tftp_lost_count
}
}
}
if { $temp_status_flag == $FAILURE } {
continue
}
puts "do the bootm, wait for uClinux prompt"
send_log "do the bootm, wait for uClinux prompt\n"
send "bootm $TFTP_LOAD_ADDR\r"
set timeout 60
while 1 {
expect {
$KERNEL_PROMPT {
send_log "*** Found kernel prompt ***\n"
puts "Found kernel prompt\n\n"
break
}
timeout {
puts "\nERROR: Never saw kernel prompt"
send_log "ERROR: Never saw kernel prompt\n"
incr kernel_prompt_timeout_count
break
}
}
}
puts "\n\n\n=== TESTING RESULTS SO FAR ===\n\n"
puts "total count is $total_count"
puts "failures to reset = $reset_timeout_count"
puts "no countdown detected = $no_countdown_count"
puts "uboot got lost = $uboot_lost_count"
puts "tftp got lost = $tftp_lost_count"
puts "tftp timeouts = $tftp_timeout_count"
puts "kernel prompt timeouts = $kernel_prompt_timeout_count\n\n"
send_log "\n\n\n=== TESTING RESULTS SO FAR ===\n\n"
send_log "total count is $total_count\n"
send_log "failures to reset = $reset_timeout_count\n"
send_log "no countdown detected = $no_countdown_count\n"
send_log "uboot got lost = $uboot_lost_count\n"
send_log "tftp got lost = $tftp_lost_count\n"
send_log "tftp timeouts = $tftp_timeout_count\n"
send_log "kernel prompt timeouts = $kernel_prompt_timeout_count\n\n"
}
puts "\n\n\n=== TESTING RESULTS ===\n\n"
puts "total count is $total_count"
puts "failures to reset = $reset_timeout_count"
puts "no countdown detected = $no_countdown_count"
puts "uboot got lost = $uboot_lost_count"
puts "tftp got lost = $tftp_lost_count"
puts "tftp timeouts = $tftp_timeout_count"
puts "kernel prompt timeouts = $kernel_prompt_timeout_count"
send_log "\n\n\n=== TESTING RESULTS ===\n\n"
send_log "total count is $total_count\n"
send_log "failures to reset = $reset_timeout_count\n"
send_log "no countdown detected = $no_countdown_count\n"
send_log "uboot got lost = $uboot_lost_count\n"
send_log "tftp got lost = $tftp_lost_count\n"
send_log "tftp timeouts = $tftp_timeout_count\n"
send_log "kernel prompt timeouts = $kernel_prompt_timeout_count\n"