Skip to content

Commit

Permalink
Refactor dejagnu scripts to fix all stylistic and functional errors
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeny Semenov <[email protected]>
  • Loading branch information
qwersem committed Apr 5, 2024
1 parent 5fe6ce0 commit 3e010a6
Show file tree
Hide file tree
Showing 16 changed files with 286 additions and 275 deletions.
47 changes: 24 additions & 23 deletions dejagnu/arc-common.exp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
proc arc_get_multilib_options {} {
global env

if { [info exists env(ARC_MULTILIB_OPTIONS)] } {
if { [regexp "^-m" $env(ARC_MULTILIB_OPTIONS)] || \
[string length [string trim $env(ARC_MULTILIB_OPTIONS)]] == 0 } {
return $env(ARC_MULTILIB_OPTIONS)
} else {
return "-m$env(ARC_MULTILIB_OPTIONS)"
}
if {[info exists env(ARC_MULTILIB_OPTIONS)]} {
if {[regexp "^-m" $env(ARC_MULTILIB_OPTIONS)] || \
[string length [string trim $env(ARC_MULTILIB_OPTIONS)]] == 0} {
return $env(ARC_MULTILIB_OPTIONS)
} else {
return "-m$env(ARC_MULTILIB_OPTIONS)"
}
} else {
return ""
return ""
}
}

Expand All @@ -40,9 +40,9 @@ proc arc_get_cflags {} {
# that will cause compilation errors in Metaware due to unknown options.
# Instead all options should be specified via COMPAT_OPTIONS varibles in
# site.exp.
if { [board_info $board exists arc,is_gcc_compat_suite] &&
[string is true -strict [board_info $board arc,is_gcc_compat_suite]] } {
return ""
if {[board_info $board exists arc,is_gcc_compat_suite] &&
[string is true -strict [board_info $board arc,is_gcc_compat_suite]]} {
return ""
}

set cflags {}
Expand Down Expand Up @@ -74,8 +74,8 @@ proc arc_get_cflags {} {
# some watchpoint tests fail, because they get an extra watchpoint value
# change even though it is not a variable that has changed, by a FP
# register in epilogue.
if { $tool == "gdb" } {
lappend cflags -fomit-frame-pointer
if {$tool == "gdb"} {
lappend cflags -fomit-frame-pointer
}

return [join $cflags]
Expand All @@ -89,17 +89,17 @@ proc arc_gdbserver_close {} {

verbose "arc: arc_gdbserver_close"

if ![board_info $board exists gdbserver_id] {
return
if {![board_info $board exists gdbserver_id]} {
return
}

set gdbserver_id [board_info $board gdbserver_id]
if [catch {close -i $gdbserver_id}] {
verbose "openocd_close: failed to close $gdbserver_id: $errorInfo"
if {[catch {close -i $gdbserver_id}]} {
verbose "openocd_close: failed to close $gdbserver_id: $errorInfo"
}

if [catch {wait -i $gdbserver_id}] {
verbose "openocd_close: failed to wait for $gdbserver_id: $errorInfo"
if {[catch {wait -i $gdbserver_id}]} {
verbose "openocd_close: failed to wait for $gdbserver_id: $errorInfo"
}

unset_board_info gdbserver_id
Expand All @@ -120,6 +120,7 @@ proc arc_gdbserver_start { } {
# a single arguments instead of an argument list. I haven't found a way to
# explode $args into a list in a way that would work with spawn. Using
# [split $args] didn't helped.
# tclint-disable-next-line command-args
eval "spawn $bin $args"

set_board_info gdbserver_id $spawn_id
Expand All @@ -138,11 +139,11 @@ proc arc_openocd_start { } {
set_board_info arc,gdbserver_prog [board_info $board arc,openocd_prog]

set args "-f [board_info $board arc,openocd_cfg]"
if [board_info $board exists arc,openocd_log] {
append args " -l [board_info $board arc,openocd_log]"
if {[board_info $board exists arc,openocd_log]} {
append args " -l [board_info $board arc,openocd_log]"
}
if [board_info $board exists arc,openocd_log_level] {
append args " -d[board_info $board arc,openocd_log_level]"
if {[board_info $board exists arc,openocd_log_level]} {
append args " -d[board_info $board arc,openocd_log_level]"
}

set_board_info arc,gdbserver_args $args
Expand Down
8 changes: 4 additions & 4 deletions dejagnu/baseboards/arc-ashling-gdbserver.exp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ search_and_load_file "library file" "arc-elf32-generic.exp" $boards_dir
set opella_dir "[file dirname $env(DEJAGNU)]/extras/opella-xd"

# Select XML tdesc based on processor family.
if { [check_target_arc700] } {
if {[check_target_arc700]} {
set tdesc_file "opella-arc700-tdesc.xml"
set reg_file "arc700-cpu.xml"
} elseif { [check_target_arc600] || [check_target_arc601] } {
} elseif {[check_target_arc600] || [check_target_arc601]} {
set tdesc_file "opella-arc600-tdesc.xml"
set reg_file "arc600-cpu.xml"
} elseif { [check_target_archs] } {
} elseif {[check_target_archs]} {
set tdesc_file "opella-archs-tdesc.xml"
set reg_file "arc-hs-cpu.xml"
} elseif { [check_target_arcem] || [check_target_quarkse_em] } {
} elseif {[check_target_arcem] || [check_target_quarkse_em]} {
set tdesc_file "opella-arcem-tdesc.xml"
set reg_file "arc-em-cpu.xml"
} else {
Expand Down
43 changes: 22 additions & 21 deletions dejagnu/baseboards/arc-elf32-generic.exp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ search_and_load_file "library file" "arc-common.exp" ${boards_dir}

# GDB tests require special treatment, they ignore "gdb-comm" configuration
# unless "monitor" GDB test suite configuration is loaded.
if { $tool == "gdb" } {
load_lib "../config/monitor.exp"
if {$tool == "gdb"} {
load_lib "../config/monitor.exp"
}

# Don't use any hostlink (--specs=nosys.specs).
Expand All @@ -48,9 +48,10 @@ append xldflags " -Wl,-marcv2elfx -L$::env(PWD)"

# We only support newlib on this target. We assume that all multilib
# options have been specified before we get here.
set_board_info compiler "[find_gcc]"
set_board_info cflags "[libgloss_include_flags] [newlib_include_flags] [arc_get_cflags]"
set_board_info ldflags "[libgloss_link_flags] ${xldflags} [newlib_link_flags]"
set_board_info compiler "[find_gcc]"
set_board_info cflags \
"[libgloss_include_flags] [newlib_include_flags] [arc_get_cflags]"
set_board_info ldflags "[libgloss_link_flags] ${xldflags} [newlib_link_flags]"

# No linker script needed.
set_board_info ldscript ""
Expand All @@ -69,22 +70,22 @@ set_board_info gdb,noresults 1
set_board_info gdb,noinferiorio 1
set_board_info needs_status_wrapper ""

if { $tool == "gdb" } {
# We use gdbserver to run applications
set_board_info use_gdb_stub 1
# GDB jumps to start_symbols after loading. Default value is `start'.
set_board_info gdb,start_symbol "__start"
set_board_info gdb,do_reload_on_run 1
# Hardware watchpoint are not precies on ARC - they may fire few
# instructions after ST instruction and this may skew testing when
# there is several ST to same address consequently, as first stores may
# get missed. Unfortunately it seems that GDB testsuite configuration
# doesn't distinguish between hardware watchpoints and breakpoint, the
# latter ones should work fine on ARC.
set_board_info gdb,no_hardware_watchpoints 1
# This duplicates the ones without 'gdb,'
set_board_info gdb,noargs 1
set_board_info gdb,nofileio 1
if {$tool == "gdb"} {
# We use gdbserver to run applications
set_board_info use_gdb_stub 1
# GDB jumps to start_symbols after loading. Default value is `start'.
set_board_info gdb,start_symbol "__start"
set_board_info gdb,do_reload_on_run 1
# Hardware watchpoint are not precies on ARC - they may fire few
# instructions after ST instruction and this may skew testing when
# there is several ST to same address consequently, as first stores may
# get missed. Unfortunately it seems that GDB testsuite configuration
# doesn't distinguish between hardware watchpoints and breakpoint, the
# latter ones should work fine on ARC.
set_board_info gdb,no_hardware_watchpoints 1
# This duplicates the ones without 'gdb,'
set_board_info gdb,noargs 1
set_board_info gdb,nofileio 1
}

# vim: noexpandtab sts=4 ts=8:
18 changes: 9 additions & 9 deletions dejagnu/baseboards/arc-linux-aa4.exp
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ set_board_info username root
set_board_info password ""

# Set up telnet connection details.
set_board_info shell_prompt "\[^\r\n\]*# "
set_board_info telnet_username "root"
set_board_info telnet_password ""
set_board_info telnet_exec_timeout 120
set_board_info shell_prompt "\[^\r\n\]*# "
set_board_info telnet_username "root"
set_board_info telnet_password ""
set_board_info telnet_exec_timeout 120

# Set up FTP connection details.
set_board_info ftp_username root
set_board_info ftp_password "\'\'"
set_board_info ftp_download_timeout 10
set_board_info ftp_upload_timeout 10
set_board_info ftp_username root
set_board_info ftp_password "\'\'"
set_board_info ftp_download_timeout 10
set_board_info ftp_upload_timeout 10

# This simulator isn't slow.
set_board_info slow_simulator 0

if { $tool == "gdb" } {
if {$tool == "gdb"} {
# IP address of target
set_board_info sockethost "$env(ARC_TEST_ADDR_UCLIBC):"
}
Expand Down
34 changes: 18 additions & 16 deletions dejagnu/baseboards/arc-linux-generic.exp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set_board_info target_install ${target_triplet}
# Load the generic configuration for this board. This will define a basic set
# of routines needed by the tool to communicate with the board. Depends on the
# tool.
if { $tool == "gdb" } {
if {$tool == "gdb"} {
load_generic_config "gdbserver"
} else {
load_generic_config "unix"
Expand All @@ -54,8 +54,8 @@ set_board_info compiler [find_gcc]

# Set up connection using telnet and FTP. Hostname, prompts, usernames and
# passwords are in the board specific files.
set_board_info connect telnet
set_board_info file_transfer ftp
set_board_info connect telnet
set_board_info file_transfer ftp

# We only support newlib on this target. We assume that all multilib
# options have been specified before we get here.
Expand All @@ -64,7 +64,7 @@ set_board_info file_transfer ftp
set_board_info ldscript ""

# Can't pass arguments to programs on this target..
set_board_info noargs 1
set_board_info noargs 1

# Used by a few gcc.c-torture testcases to delimit how large the stack can
# be.
Expand All @@ -75,13 +75,13 @@ set_board_info gcc,stack_size 65536
# We can't do input in GDB (yet! HA!). It *will* do output, hurrah.
set_board_info gdb,noinferiorio 1
# Or pass arguments.
set_board_info gdb,noargs 1
set_board_info gdb,noargs 1
# And there's no support for signals.
set_board_info gdb,nosignals 1
set_board_info gdb,nosignals 1
# GDB can't return results
set_board_info gdb,noresults 1

if { $tool == "gdb" } {
if {$tool == "gdb"} {
# GDB specific setup to enable gdbserver on the target.

# Use telnet as protocol to spawn gdbserver
Expand All @@ -93,23 +93,25 @@ if { $tool == "gdb" } {
# No hardware watchpoints
set_board_info gdb,no_hardware_watchpoints 1
# The command to use
if { [info exists gdb_server_prog] } {
set_board_info gdb_server_prog $gdb_server_prog
if {[info exists gdb_server_prog]} {
set_board_info gdb_server_prog $gdb_server_prog
} else {
set_board_info gdb_server_prog /bin/gdbserver
set_board_info gdb_server_prog /bin/gdbserver
}
# Use a GDB stub
set_board_info use_gdb_stub 1

# Set up sysroot. This is an option relating to the host running GDB, not
# the board, hence the contortion.
if { [info exists env(ARC_GDB_COMMFILE)] } {
set board_info([get_local_hostname],gdb_opts) "-x $env(ARC_GDB_COMMFILE)"
} elseif { [info exists ::toolchain_sysroot_dir] } {
set board_info([get_local_hostname],gdb_opts) "-ex 'set sysroot $::toolchain_sysroot_dir'"
if {[info exists env(ARC_GDB_COMMFILE)]} {
set board_info([get_local_hostname],gdb_opts) \
"-x $env(ARC_GDB_COMMFILE)"
} elseif {[info exists ::toolchain_sysroot_dir]} {
set board_info([get_local_hostname],gdb_opts) \
"-ex 'set sysroot $::toolchain_sysroot_dir'"
} else {
puts "Neither ARC_GDB_COMMFILE, not toolchain_sysroot_dir environment
variables are specified. Some tests are likely to fail."
puts "Neither ARC_GDB_COMMFILE, not toolchain_sysroot_dir environment \
variables are specified. Some tests are likely to fail."
}
}

Expand Down
16 changes: 7 additions & 9 deletions dejagnu/baseboards/arc-linux-qemu-user.exp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ search_and_load_file "library file" "arc-common.exp" ${boards_dir}
process_multilib_options [arc_get_multilib_options]

#set QEMU flags
if ![info exists qemu_flags] {
if {![info exists qemu_flags]} {
set qemu_flags {}
}

# Select processor family.
if { [check_target_archs] } {
lappend qemu_flags \
-cpu archs
if {[check_target_archs]} {
lappend qemu_flags -cpu archs
set qemu_arch "arc"
} elseif { [check_target_arc64_64] } {
lappend qemu_flags \
-cpu hs6x
} elseif {[check_target_arc64_64]} {
lappend qemu_flags -cpu hs6x
set qemu_arch "arc64"
} else {
perror "Unknown CPU configuration"
Expand All @@ -56,15 +54,15 @@ set qemu_bin "$::env(QEMU_HOME)/bin/qemu-${qemu_arch}"

set_board_info sim_time_limit 300
# If we test libstdc++ increase the time.
if { $tool == "libstdc++" } {
if {$tool == "libstdc++"} {
set_board_info sim_time_limit 1200
}

# Setup the QEMU simulator.
set_board_info sim "$qemu_bin [join $qemu_flags]"
set_board_info is_simulator 1

set_board_info compiler "[find_gcc]"
set_board_info compiler "[find_gcc]"

# The simulator returns exit statuses
set_board_info needs_status_wrapper ""
Expand Down
32 changes: 16 additions & 16 deletions dejagnu/baseboards/arc-linux-qemu.exp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ send_user "ARC Linux test setup\n"
search_and_load_file "library file" "arc-linux-generic.exp" ${boards_dir}

# get the address of the host where qemu is running on
if { [info exists ::env(ARC_TEST_ADDR_UCLIBC)] } {
if {[info exists ::env(ARC_TEST_ADDR_UCLIBC)]} {
set addr $env(ARC_TEST_ADDR_UCLIBC)
} else {
set addr 127.0.0.1
Expand All @@ -41,32 +41,32 @@ set_board_info username root
set_board_info password ""

# Set up telnet connection details.
set_board_info shell_prompt "\[^\r\n\]*# "
set_board_info telnet_username "root"
set_board_info telnet_password ""
set_board_info telnet_exec_timeout 120
if { [info exists ::env(TARGET_TELNET_PORT)] } {
set_board_info netport $addr:$env(TARGET_TELNET_PORT)
set_board_info shell_prompt "\[^\r\n\]*# "
set_board_info telnet_username "root"
set_board_info telnet_password ""
set_board_info telnet_exec_timeout 120
if {[info exists ::env(TARGET_TELNET_PORT)]} {
set_board_info netport $addr:$env(TARGET_TELNET_PORT)
} else {
set_board_info netport $addr:5556
set_board_info netport $addr:5556
}


# Set up FTP connection details.
set_board_info ftp_username root
set_board_info ftp_password "\'\'"
set_board_info ftp_download_timeout 10
set_board_info ftp_upload_timeout 10
if { [info exists ::env(TARGET_FTP_PORT)] } {
set_board_info ftp_port $env(TARGET_FTP_PORT)
set_board_info ftp_username root
set_board_info ftp_password "\'\'"
set_board_info ftp_download_timeout 10
set_board_info ftp_upload_timeout 10
if {[info exists ::env(TARGET_FTP_PORT)]} {
set_board_info ftp_port $env(TARGET_FTP_PORT)
} else {
set_board_info ftp_port 5555
set_board_info ftp_port 5555
}

# This simulator isn't slow.
set_board_info slow_simulator 0

if { $tool == "gdb" } {
if {$tool == "gdb"} {
# IP address of target
set_board_info sockethost "$addr:"
}
Expand Down
Loading

0 comments on commit 3e010a6

Please sign in to comment.