OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [boards/] [or32-linux-sim.exp] - Diff between revs 554 and 555

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 554 Rev 555
Line 42... Line 42...
# Custom proc to check if we have had too many failures
# Custom proc to check if we have had too many failures
 
 
# @param[in] boardname  The board being closed.
# @param[in] boardname  The board being closed.
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
proc telnet_failure_check { connhost errmess } {
proc telnet_failure_check { connhost errmess } {
 
    global board_info
 
 
    # Get the maximum failure count
    # Get the maximum failure count
    set max_fc 10
    set max_fc 10
 
 
    if [board_info $connhost exists max_failure_count] {
    if [board_info $connhost exists max_failure_count] {
Line 59... Line 60...
        verbose "telnet_failure_check: Incrementing failure count"
        verbose "telnet_failure_check: Incrementing failure count"
        set fc [expr [board_info $connhost failure_count] + 1]
        set fc [expr [board_info $connhost failure_count] + 1]
    }
    }
    set board_info($connhost,failure_count) $fc
    set board_info($connhost,failure_count) $fc
    verbose "telnet_failure_check: current failure count is $fc"
    verbose "telnet_failure_check: current failure count is $fc"
    verbose "telnet_failure_check: board_info is [board_info $connhost failure_count]"
 
 
 
    # Die if we are over the limit
    # Die if we are over the limit
    if {$fc >= $max_fc} {
    if {$fc >= $max_fc} {
        error "Too many failures: $errmess"
        error "Too many failures: $errmess"
    }
    }
Line 74... Line 74...
# Custom proc to exec programs using telnet
# Custom proc to exec programs using telnet
 
 
# We seem to only pass in the first of the arguments supplied to the command.
# We seem to only pass in the first of the arguments supplied to the command.
 
 
# The timeout is a mess. It seems to always be 10, not the timeout needed to
# The timeout is a mess. It seems to always be 10, not the timeout needed to
# execute a regression test (typicall 300 seconds). Fixed by using our own
# execute a regression test (typicall 300 seconds). Fixed by not making it
# timeout data.
# global and using our own timeout data.
 
 
# It also seems that only the first argument is passed.
# It also seems that only the first argument is passed.
 
 
# @param[in] hostname  The board we are telnetting to
# @param[in] hostname  The board we are telnetting to
# @param[in] cmd        The command to run
# @param[in] cmd        The command to run
Line 87... Line 87...
 
 
# @return  A list of the return code (-1 on failure) and any error message.
# @return  A list of the return code (-1 on failure) and any error message.
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
proc telnet_exec {hostname cmd args} {
proc telnet_exec {hostname cmd args} {
    global timeout
    global timeout
 
    global board_info
    global verbose
    global verbose
    global spawn_id
    global spawn_id
 
 
    # Get the connected host name, if it exists. This code matches
    # Get the connected host name, if it exists. This code matches
    # telnet_open.
    # telnet_open.
Line 141... Line 142...
        if {[telnet_open $connhost] == -1} {
        if {[telnet_open $connhost] == -1} {
            return [list -1 "telnet to $hostname failed for $cmd, couldn't begin telnet session"]
            return [list -1 "telnet to $hostname failed for $cmd, couldn't begin telnet session"]
        }
        }
    }
    }
 
 
 
    # Save the timeout. It's a global, which we shall mess about with, and
 
    # restore on exit.
 
    set timeout_orig timeout
 
 
    # Make the telnet session the current process. Short timeout for this.
    # Make the telnet session the current process. Short timeout for this.
    set spawn_id [board_info $connhost fileid]
    set spawn_id [board_info $connhost fileid]
    set timeout 30
    set timeout 30
 
 
    #Hit enter to make sure you get a shell prompt
    #Hit enter to make sure you get a shell prompt
Line 165... Line 170...
                set spawn_id [board_info $connhost fileid]
                set spawn_id [board_info $connhost fileid]
                verbose "telnet_exec: new telnet session, spawn_id: $spawn_id"
                verbose "telnet_exec: new telnet session, spawn_id: $spawn_id"
                send "\r"
                send "\r"
                exp_continue
                exp_continue
            } else {
            } else {
 
                set timeout timeout_orig
                return [list -1 "telnet to $hostname failed for $cmd, couldn't get a shell prompt"]
                return [list -1 "telnet to $hostname failed for $cmd, couldn't get a shell prompt"]
            }
            }
        }
        }
    }
    }
 
 
Line 178... Line 184...
 
 
    # We really should get the command echoed back immediately. This is a good
    # We really should get the command echoed back immediately. This is a good
    # way of slurping up unexpected prompts. We first swap out any characters
    # way of slurping up unexpected prompts. We first swap out any characters
    # from the command and args that might cause us grief.
    # from the command and args that might cause us grief.
    regsub -all "\\+" "$cmd $pargs" "." cmdpargs
    regsub -all "\\+" "$cmd $pargs" "." cmdpargs
 
    verbose "telnet_exec: command match string is \"$cmdpargs\""
 
 
    expect {
    expect {
        "$cmdpargs" {
        -re "$cmdpargs" {
            verbose "telnet_exec: got command echoed back"
            verbose "telnet_exec: got command echoed back"
        }
        }
 
        default {
 
            verbose "telnet_exec: command not echoed: command expect_out(buffer): \"$expect_out(buffer)\""
 
        }
    }
    }
 
 
    # Set the telnet command custom timeout to wait for the command
    # Set the telnet command custom timeout to wait for the command to
    # prompt. Old timeout saved, so we can restore it, since it's global.
    # complete executing.
    set old_timeout $timeout
 
 
 
    if [board_info $connhost exists telnet_exec_timeout] {
    if [board_info $connhost exists telnet_exec_timeout] {
        set timeout [board_info $connhost telnet_exec_timeout]
        set timeout [board_info $connhost telnet_exec_timeout]
        verbose "telnet_exec: command timeout set to $timeout"
        verbose "telnet_exec: command timeout set to $timeout"
    } else {
    } else {
        # Appropriate default
        # Appropriate default
Line 204... Line 212...
        -re "$shell_prompt" {
        -re "$shell_prompt" {
            verbose "telnet_exec: got prompt after command"
            verbose "telnet_exec: got prompt after command"
        }
        }
        default {
        default {
            # Give up on timeout or EOF
            # Give up on timeout or EOF
            set timeout $old_timeout
 
            telnet_close $connhost
            telnet_close $connhost
 
            set timeout timeout_orig
            return [list -1 "telnet to $hostname for $cmd $pargs failed (timeout)"]
            return [list -1 "telnet to $hostname for $cmd $pargs failed (timeout)"]
        }
        }
    }
    }
 
 
    # Restore the old timeout
 
    set timeout $old_timeout
 
 
 
    # Remove unnecessary strings from the output string
    # Remove unnecessary strings from the output string
    verbose "telnet_exec: command expect_out(buffer): \"$expect_out(buffer)\""
    verbose "telnet_exec: command expect_out(buffer): \"$expect_out(buffer)\""
    regsub -all $cmdpargs "$expect_out(buffer)" {} output
    regsub -all $cmdpargs "$expect_out(buffer)" {} output
    regsub "$shell_prompt" $output {} output
    regsub "$shell_prompt" $output {} output
    regsub -all "\[\r\n\]" $output {} output
    regsub -all "\[\r\n\]" $output {} output
Line 227... Line 232...
        set output "\"$output\""
        set output "\"$output\""
    }
    }
 
 
    verbose "telnet_exec: command output $output"
    verbose "telnet_exec: command output $output"
 
 
    # Check the return status. Use a short timeout for this.
    # Check the return status. Use a short timeout for this and following
 
    # commands.
    set timeout 30
    set timeout 30
    send "echo \$?\r"
    send "echo \$?\r"
 
 
    # Once again, look for the "echo" reflected back as a way of slurping up
    # Once again, look for the "echo" reflected back as a way of slurping up
    # unexpected prompts. We don't worry about timeout here - we'll sort that
    # unexpected prompts. We don't worry about timeout here - we'll sort that
    # out on the next one.
    # out later.
    expect {
    expect {
        -re "echo \\$\\?" {
        -re "echo \\$\\?" {
            verbose "telnet_exec: got \"echo\" echoed back"
            verbose "telnet_exec: got \"echo\" echoed back"
        }
        }
 
        default {
 
            verbose "telnet_exec: echo not echoed: command expect_out(buffer): \"$expect_out(buffer)\""
 
        }
    }
    }
 
 
 
    # Look for the shell prompt. Don't worry about timeout for now. It only
 
    # really matters if we don't get a valid status, which we'll discover
 
    # below.
    expect {
    expect {
        -re "$shell_prompt" {
        -re "$shell_prompt" {
            verbose "telnet_exec: got status shell prompt"
            verbose "telnet_exec: got status shell prompt"
        }
        }
        default {
        default {
            warning "No response to status request"
            verbose "telnet_exec: no status shell prompt: command expect_out(buffer): \"$expect_out(buffer)\""
 
 
            # Die if we have had too many failures like this.
 
            telnet_failure_check $connhost "no shell prompt from status"
 
 
 
            # See if another carriage return will prompt a response
 
            send "\r"
 
            exp_continue
 
        }
        }
    }
    }
 
 
    # Regsub the output to get the status number
    # Regsub the output to get the status number
    verbose "telnet_exec: status expect_out(buffer): \"$expect_out(buffer)\""
    verbose "telnet_exec: status expect_out(buffer): \"$expect_out(buffer)\""
Line 273... Line 278...
 
 
        # Die if we have had too many failures like this.
        # Die if we have had too many failures like this.
        telnet_failure_check $connhost "bad status"
        telnet_failure_check $connhost "bad status"
    }
    }
 
 
    # Restore timeout
    set timeout timeout_orig
    set timeout $old_timeout
 
    if {$status == 0} {
    if {$status == 0} {
        return [list "0" "$output"]
        return [list "0" "$output"]
    } else {
    } else {
        return [list "1" "$output"]
        return [list "1" "$output"]
    }
    }
Line 300... Line 304...
# @param[in] host        The host we are connected to.
# @param[in] host        The host we are connected to.
# @param[in] localfile   The local file to send
# @param[in] localfile   The local file to send
# @param[in] remotefile  Name of file at remote end.
# @param[in] remotefile  Name of file at remote end.
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
proc ftp_upload {host localfile remotefile} {
proc ftp_upload {host localfile remotefile} {
    set prompt "ftp>"
    global board_info
 
 
 
    set prompt "ftp>"
    verbose "ftping $remotefile from $host to $localfile"
    verbose "ftping $remotefile from $host to $localfile"
 
 
    # JPB to set custom timeout (not marked global, so we don't need to save
    # JPB to set custom timeout (not marked global, so we don't need to save
    # and restore)
    # and restore)
    if [board_info $host exists ftp_upload_timeout] {
    if [board_info $host exists ftp_upload_timeout] {
Line 362... Line 367...
# @param[in] host        The host we are connected to.
# @param[in] host        The host we are connected to.
# @param[in] localfile   The local file to send
# @param[in] localfile   The local file to send
# @param[in] remotefile  Name of file at remote end.
# @param[in] remotefile  Name of file at remote end.
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
proc ftp_download {host localfile remotefile} {
proc ftp_download {host localfile remotefile} {
 
    global board_info
 
 
    set prompt "ftp>"
    set prompt "ftp>"
 
 
    verbose "putting $localfile $remotefile"
    verbose "putting $localfile $remotefile"
 
 
    if [board_info $host exists hostname] {
    if [board_info $host exists hostname] {

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.