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 490 and 522

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

Rev 490 Rev 522
Line 47... Line 47...
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# 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.
 
 
# We seem to set the timeout to 30, no matter what. Not sure that is right
# The timeout is a mess. It seems to always be 10, not the timeout needed to
# here.
# execute a regression test (typicall 300 seconds). Fixed by using our onw
 
# timeout data.
 
 
# @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
# @param[in] args       Arguments to the command
# @param[in] args       Arguments to the command
 
 
# @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 verbose
    global verbos
    set output "(no output)"
    set output "(no output)"
 
 
 
    # Save the old timeout, since its global, and we'll want to restore it.
 
    set old_timeout $timeout
 
 
    verbose "Executing $hostname $cmd $args"
    verbose "Executing $hostname $cmd $args"
 
 
    # Get the first argument, if any.
    # Get the first argument, if any.
    if { [llength $args] > 0 } {
    if { [llength $args] > 0 } {
        set pargs [lindex $args 0];
        set pargs [lindex $args 0];
Line 89... Line 93...
            return [list -1
            return [list -1
                    "telnet to $hostname failed for $cmd, couldn't begin telnet session"]
                    "telnet to $hostname failed for $cmd, couldn't begin telnet session"]
        }
        }
    }
    }
 
 
    # Make the telnet session the current process.
    # Make the telnet session the current process. Short timeout for this.
    set spawn_id [board_info $hostname fileid]
    set spawn_id [board_info $hostname fileid]
    set old_timeout $timeout
    set timeout 10
    set timeout 30
 
 
 
    #Hit enter to make sure you get a shell prompt
    #Hit enter to make sure you get a shell prompt
    send -- "\r"
    send -- "\r"
 
 
    expect {
    expect {
Line 124... Line 127...
            set timeout $old_timeout
            set timeout $old_timeout
            error "Problem reconnecting to telnet."
            error "Problem reconnecting to telnet."
        }
        }
    }
    }
 
 
    # Restore timeout for commands. Not sure why we only use the first of the
    # JPB to set custom timeout. Old timeout saved, so we can restore it,
    # arguments.
    # since it's global. Not sure why we only use the first of the arguments.
    set timeout $old_timeout
    if [board_info $hostname exists telnet_exec_timeout] {
 
        set timeout [board_info $hostname telnet_exec_timeout]
 
        verbose "Telnet exec timeout set to $timeout"
 
    } else {
 
        # Appropriate default
 
        set timeout 300
 
        verbose "Telnet exec timeout set to default value $timeout"
 
    }
 
 
    send "$cmd $pargs\r"
    send "$cmd $pargs\r"
 
 
    expect {
    expect {
        -re "$shell_prompt.*$" {
        -re "$shell_prompt.*$" {
        }
        }
        timeout {
        timeout {
            if [info exists expect_out(buffer)] {
            if [info exists expect_out(buffer)] {
                set execute_output_string $expect_out(buffer)
                set execute_output_string $expect_out(buffer)
            }
            }
 
            set timeout $old_timeout
            telnet_close $hostname
            telnet_close $hostname
            return [list -1 "telnet to $hostname for $cmd $pargs failed (timeout)"]
            return [list -1 "telnet to $hostname for $cmd $pargs failed (timeout)"]
        }
        }
    }
    }
 
 
Line 181... Line 193...
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# For FTP we need to redefine some existing functions to add additional
# For FTP we need to redefine some existing functions to add additional
# features.
# features.
 
 
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
 
# Upload REMOTEFILE from HOST as LOCALFILE by FTP
 
 
 
# This version swaps the argument order, which is what the regression test
 
# seems to expect.
 
 
 
# Also allows a custom timeout to be set.
 
 
 
# @param[in] host        The host we are connected to.
 
# @param[in] localfile   The local file to send
 
# @param[in] remotefile  Name of file at remote end.
 
# -----------------------------------------------------------------------------
 
proc ftp_upload {host localfile remotefile} {
 
    set prompt "ftp>"
 
 
 
    verbose "ftping $remotefile from $host to $localfile"
 
 
 
    # JPB to set custom timeout (not marked global, so we don't need to save
 
    # and restore)
 
    if [board_info $host exists ftp_upload_timeout] {
 
        set timeout [board_info $host ftp_upload_timeout]
 
        verbose "FTP upload timeout set to $timeout"
 
    } else {
 
        # Appropriate default
 
        set timeout 15
 
        verbose "FTP upload timeout set to default value $timeout"
 
    }
 
 
 
    set spawn_id [ftp_open $host]
 
    if {$spawn_id < 0} {
 
        return ""
 
    }
 
    set loop 1
 
 
 
    while {$loop} {
 
        send -i $spawn_id "get $remotefile $localfile\n"
 
        expect {
 
            -i $spawn_id -re ".*Too many open files.*$prompt" {
 
                ftp_close $host
 
            }
 
            -i $spawn_id -re ".*No such file or directory.*$prompt" {
 
                set loop 0
 
                set remotefile ""
 
            }
 
            -i $spawn_id -re "(^|\[\r\n\])226.*$prompt" {set loop 0}
 
            -i $spawn_id -re "(^|\[\r\n\])\[0-9\]\[0-9\]\[0-9\].*$prompt" {
 
                set loop 0
 
                set remotefile ""
 
            }
 
            -i $spawn_id default {
 
                ftp_close $host
 
            }
 
        }
 
        if {$loop} {
 
            set spawn_id [ftp_open $host]
 
            if {$spawn_id < 0} {
 
                return ""
 
            }
 
        }
 
    }
 
    return $localfile
 
}
 
 
 
 
 
# -----------------------------------------------------------------------------
# Download LOCALFILE to HOST as REMOTEFILE by FTP
# Download LOCALFILE to HOST as REMOTEFILE by FTP
#
 
# This version takes a user specified timeout, which we need for our slow
# This version takes a user specified timeout, which we need for our slow
# simulated connection.
# simulated connection.
 
 
# @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
Line 212... Line 288...
    # 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_download_timeout] {
    if [board_info $host exists ftp_download_timeout] {
        set timeout [board_info $host ftp_download_timeout]
        set timeout [board_info $host ftp_download_timeout]
        verbose "FTP download timeout set to $timeout"
        verbose "FTP download timeout set to $timeout"
 
    } else {
 
        # Appropriate default
 
        set timeout 15
 
        verbose "FTP download timeout set to default value $timeout"
    }
    }
 
 
    while {$loop} {
    while {$loop} {
        send -i $spawn_id "put $localfile $remotefile\n"
        send -i $spawn_id "put $localfile $remotefile\n"
        expect {
        expect {
Line 265... Line 345...
# of routines needed by the tool to communicate with the board.
# of routines needed by the tool to communicate with the board.
load_generic_config "unix"
load_generic_config "unix"
 
 
# Set up remote target info. We select the IP address using an external
# Set up remote target info. We select the IP address using an external
# program which knows about all available Linuxes.
# program which knows about all available Linuxes.
set linux_hostname [exec [file dirname $env(DEJAGNU)]/get-ip.sh]
set linux_hostname [exec [file dirname $env(DEJAGNU)]/get-ip.sh --rotate]
set_board_info hostname $linux_hostname
set_board_info hostname $linux_hostname
send_user "OR32 target hostname is $linux_hostname"
send_user "OR32 target hostname is $linux_hostname\n"
 
 
set_board_info username root
set_board_info username root
 
 
# Use the installed compilers to ensure we get search paths that will find
# Use the installed compilers to ensure we get search paths that will find
# uClibc.
# uClibc.
Line 286... Line 366...
 
 
set_board_info connect telnet
set_board_info connect telnet
set_board_info shell_prompt    "# "
set_board_info shell_prompt    "# "
set_board_info telnet_username "root"
set_board_info telnet_username "root"
set_board_info telnet_password ""
set_board_info telnet_password ""
 
set_board_info telnet_exec_timeout   300
 
 
set_board_info file_transfer         ftp
set_board_info file_transfer         ftp
set_board_info ftp_username          root
set_board_info ftp_username          root
set_board_info ftp_password          ""
set_board_info ftp_password          ""
set_board_info ftp_download_timeout  120
set_board_info ftp_download_timeout  120
 
set_board_info ftp_upload_timeout    120
 
 
# Options for the simulator
# Options for the simulator
# set cfg_file [lookfor_file ${srcdir} libgloss/or32/sim.cfg]
# set cfg_file [lookfor_file ${srcdir} libgloss/or32/sim.cfg]
#set_board_info sim,options "-a \"-f ${cfg_file}\""
#set_board_info sim,options "-a \"-f ${cfg_file}\""
 
 
# We only support uClibc on this target.  We assume that all multilib options
# We only support uClibc on this target.  We assume that all multilib options
# have been specified before we get here.
# have been specified before we get here.
#set_board_info compiler  "[find_gcc]"
#set_board_info compiler  "[find_gcc]"
 
 
# We need to define the right flags if pthreads is to work.
# We need to define this flag to generate default .gcda files if we are using
# set_board_info cflags    "-D_XOPEN_SOURCE=600"
# a stock compiler, without the profopt.exp changes. No problem with doubling
# set_board_info cxxflags  "-D_XOPEN_SOURCE=600"
# up the argument in normal circumstances.
 
set_board_info cflags    "-fprofile-dir=."
 
set_board_info cxxflags  "-fprofile-dir=."
 
 
# No linker script needed.
# No linker script needed.
set_board_info ldscript ""
set_board_info ldscript ""
 
 
# This simulator isn't slow.
# This simulator isn't slow.

powered by: WebSVN 2.1.0

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