# Copyright (C) 1988, 90, 91, 92, 95, 96, 1997, 2007
|
# Copyright (C) 1988, 90, 91, 92, 95, 96, 1997, 2007
|
# Free Software Foundation, Inc.
|
# Free Software Foundation, Inc.
|
|
|
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
# (at your option) any later version.
|
# (at your option) any later version.
|
#
|
#
|
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
#
|
#
|
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
# along with GCC; see the file COPYING3. If not see
|
# along with GCC; see the file COPYING3. If not see
|
# .
|
# .
|
|
|
# This file was derived from mike-g++.exp written by Mike Stump
|
# This file was derived from mike-g++.exp written by Mike Stump
|
|
|
#
|
#
|
# mike_cleanup -- remove any files that are created by the testcase
|
# mike_cleanup -- remove any files that are created by the testcase
|
#
|
#
|
proc mike_cleanup { src_code output_file assembly_file } {
|
proc mike_cleanup { src_code output_file assembly_file } {
|
remote_file build delete $output_file $assembly_file
|
remote_file build delete $output_file $assembly_file
|
}
|
}
|
|
|
#
|
#
|
# prebase -- sets up a Mike Stump (mrs@cygnus.com) style gcc test
|
# prebase -- sets up a Mike Stump (mrs@cygnus.com) style gcc test
|
#
|
#
|
proc prebase { } {
|
proc prebase { } {
|
global compiler_output
|
global compiler_output
|
global not_compiler_output
|
global not_compiler_output
|
global compiler_result
|
global compiler_result
|
global not_compiler_result
|
global not_compiler_result
|
global program_output
|
global program_output
|
global groups
|
global groups
|
global run
|
global run
|
global actions
|
global actions
|
global target_regexp
|
global target_regexp
|
|
|
set compiler_output "^$"
|
set compiler_output "^$"
|
set not_compiler_output ".*Internal compiler error.*"
|
set not_compiler_output ".*Internal compiler error.*"
|
set compiler_result ""
|
set compiler_result ""
|
set not_compiler_result ""
|
set not_compiler_result ""
|
set program_output ".*PASS.*"
|
set program_output ".*PASS.*"
|
set groups {}
|
set groups {}
|
set run no
|
set run no
|
set actions assemble
|
set actions assemble
|
set target_regexp ".*"
|
set target_regexp ".*"
|
}
|
}
|
|
|
#
|
#
|
# run the test
|
# run the test
|
#
|
#
|
proc postbase { src_code run groups args } {
|
proc postbase { src_code run groups args } {
|
global verbose
|
global verbose
|
global srcdir
|
global srcdir
|
global subdir
|
global subdir
|
global not_compiler_output
|
global not_compiler_output
|
global compiler_output
|
global compiler_output
|
global compiler_result
|
global compiler_result
|
global not_compiler_result
|
global not_compiler_result
|
global program_output
|
global program_output
|
global actions
|
global actions
|
global target_regexp
|
global target_regexp
|
global host_triplet
|
global host_triplet
|
global target_triplet
|
global target_triplet
|
global tool
|
global tool
|
global tmpdir
|
global tmpdir
|
global GCC_UNDER_TEST
|
global GCC_UNDER_TEST
|
global GROUP
|
global GROUP
|
|
|
if ![info exists GCC_UNDER_TEST] {
|
if ![info exists GCC_UNDER_TEST] {
|
error "No compiler specified for testing."
|
error "No compiler specified for testing."
|
}
|
}
|
|
|
if ![regexp $target_regexp $target_triplet] {
|
if ![regexp $target_regexp $target_triplet] {
|
unsupported $subdir/$src_code
|
unsupported $subdir/$src_code
|
return
|
return
|
}
|
}
|
|
|
if { [llength $args] > 0 } {
|
if { [llength $args] > 0 } {
|
set comp_options [lindex $args 0]
|
set comp_options [lindex $args 0]
|
} else {
|
} else {
|
set comp_options ""
|
set comp_options ""
|
}
|
}
|
|
|
set fail_message $subdir/$src_code
|
set fail_message $subdir/$src_code
|
set pass_message $subdir/$src_code
|
set pass_message $subdir/$src_code
|
|
|
if [info exists GROUP] {
|
if [info exists GROUP] {
|
if {[lsearch $groups $GROUP] == -1} {
|
if {[lsearch $groups $GROUP] == -1} {
|
return
|
return
|
}
|
}
|
}
|
}
|
|
|
if [string match $run yes] {
|
if [string match $run yes] {
|
set actions run
|
set actions run
|
}
|
}
|
|
|
set output_file "$tmpdir/[file tail [file rootname $src_code]]"
|
set output_file "$tmpdir/[file tail [file rootname $src_code]]"
|
set assembly_file "$output_file"
|
set assembly_file "$output_file"
|
append assembly_file ".S"
|
append assembly_file ".S"
|
|
|
set compile_type "none"
|
set compile_type "none"
|
|
|
case $actions {
|
case $actions {
|
compile
|
compile
|
{
|
{
|
set compile_type "assembly"
|
set compile_type "assembly"
|
set output_file $assembly_file
|
set output_file $assembly_file
|
}
|
}
|
assemble
|
assemble
|
{
|
{
|
set compile_type "object"
|
set compile_type "object"
|
append output_file ".o"
|
append output_file ".o"
|
}
|
}
|
link
|
link
|
{
|
{
|
set compile_type "executable"
|
set compile_type "executable"
|
append output_file ".exe"
|
append output_file ".exe"
|
}
|
}
|
run
|
run
|
{
|
{
|
set compile_type "executable"
|
set compile_type "executable"
|
append output_file ".exe"
|
append output_file ".exe"
|
set run yes
|
set run yes
|
}
|
}
|
default
|
default
|
{
|
{
|
set output_file ""
|
set output_file ""
|
set compile_type "none"
|
set compile_type "none"
|
}
|
}
|
}
|
}
|
|
|
set src_file "$srcdir/$subdir/$src_code"
|
set src_file "$srcdir/$subdir/$src_code"
|
set options ""
|
set options ""
|
lappend options "compiler=$GCC_UNDER_TEST"
|
lappend options "compiler=$GCC_UNDER_TEST"
|
|
|
if { $comp_options != "" } {
|
if { $comp_options != "" } {
|
lappend options "additional_flags=$comp_options"
|
lappend options "additional_flags=$comp_options"
|
}
|
}
|
|
|
set comp_output [gcc_target_compile $src_file $output_file $compile_type $options]
|
set comp_output [gcc_target_compile $src_file $output_file $compile_type $options]
|
|
|
set pass no
|
set pass no
|
|
|
# Delete things like "ld.so warning" messages.
|
# Delete things like "ld.so warning" messages.
|
set comp_output [prune_warnings $comp_output]
|
set comp_output [prune_warnings $comp_output]
|
|
|
if [regexp -- $not_compiler_output $comp_output] {
|
if [regexp -- $not_compiler_output $comp_output] {
|
if { $verbose > 1 } {
|
if { $verbose > 1 } {
|
send_user "\nChecking:\n$not_compiler_output\nto make sure it does not match:\n$comp_output\nbut it does.\n\n"
|
send_user "\nChecking:\n$not_compiler_output\nto make sure it does not match:\n$comp_output\nbut it does.\n\n"
|
} else {
|
} else {
|
send_log "\nCompiler output:\n$comp_output\n\n"
|
send_log "\nCompiler output:\n$comp_output\n\n"
|
}
|
}
|
fail $fail_message
|
fail $fail_message
|
# The framework doesn't like to see any error remnants,
|
# The framework doesn't like to see any error remnants,
|
# so remove them.
|
# so remove them.
|
uplevel {
|
uplevel {
|
if [info exists errorInfo] {
|
if [info exists errorInfo] {
|
unset errorInfo
|
unset errorInfo
|
}
|
}
|
}
|
}
|
mike_cleanup $src_code $output_file $assembly_file
|
mike_cleanup $src_code $output_file $assembly_file
|
return
|
return
|
}
|
}
|
|
|
# remove any leftover CRs.
|
# remove any leftover CRs.
|
regsub -all -- "\r" $comp_output "" comp_output
|
regsub -all -- "\r" $comp_output "" comp_output
|
|
|
regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $comp_output "" comp_output
|
regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $comp_output "" comp_output
|
regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $comp_output "" comp_output
|
regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $comp_output "" comp_output
|
|
|
set unsupported_message [${tool}_check_unsupported_p $comp_output]
|
set unsupported_message [${tool}_check_unsupported_p $comp_output]
|
if { $unsupported_message != "" } {
|
if { $unsupported_message != "" } {
|
unsupported "$subdir/$src_code: $unsupported_message"
|
unsupported "$subdir/$src_code: $unsupported_message"
|
mike_cleanup $src_code $output_file $assembly_file
|
mike_cleanup $src_code $output_file $assembly_file
|
return
|
return
|
}
|
}
|
|
|
if { $verbose > 1 } {
|
if { $verbose > 1 } {
|
send_user "\nChecking:\n$compiler_output\nto see if it matches:\n$comp_output\n"
|
send_user "\nChecking:\n$compiler_output\nto see if it matches:\n$comp_output\n"
|
} else {
|
} else {
|
send_log "\nCompiler output:\n$comp_output\n\n"
|
send_log "\nCompiler output:\n$comp_output\n\n"
|
}
|
}
|
if [regexp -- $compiler_output $comp_output] {
|
if [regexp -- $compiler_output $comp_output] {
|
if { $verbose > 1 } {
|
if { $verbose > 1 } {
|
send_user "Yes, it matches.\n\n"
|
send_user "Yes, it matches.\n\n"
|
}
|
}
|
set pass yes
|
set pass yes
|
if [file exists [file rootname [file tail $src_code]].s] {
|
if [file exists [file rootname [file tail $src_code]].s] {
|
set fd [open [file rootname [file tail $src_code]].s r]
|
set fd [open [file rootname [file tail $src_code]].s r]
|
set dot_s [read $fd]
|
set dot_s [read $fd]
|
close $fd
|
close $fd
|
if { $compiler_result != "" } {
|
if { $compiler_result != "" } {
|
verbose "Checking .s file for $compiler_result" 2
|
verbose "Checking .s file for $compiler_result" 2
|
if [regexp -- $compiler_result $dot_s] {
|
if [regexp -- $compiler_result $dot_s] {
|
verbose "Yes, it matches." 2
|
verbose "Yes, it matches." 2
|
} else {
|
} else {
|
verbose "Nope, doesn't match." 2
|
verbose "Nope, doesn't match." 2
|
verbose $dot_s 4
|
verbose $dot_s 4
|
set pass no
|
set pass no
|
}
|
}
|
}
|
}
|
if { $not_compiler_result != "" } {
|
if { $not_compiler_result != "" } {
|
verbose "Checking .s file for not $not_compiler_result" 2
|
verbose "Checking .s file for not $not_compiler_result" 2
|
if ![regexp -- $not_compiler_result $dot_s] {
|
if ![regexp -- $not_compiler_result $dot_s] {
|
verbose "Nope, not found (that's good)." 2
|
verbose "Nope, not found (that's good)." 2
|
} else {
|
} else {
|
verbose "Uh oh, it was found." 2
|
verbose "Uh oh, it was found." 2
|
verbose $dot_s 4
|
verbose $dot_s 4
|
set pass no
|
set pass no
|
}
|
}
|
}
|
}
|
}
|
}
|
if [string match $run yes] {
|
if [string match $run yes] {
|
set result [gcc_load $output_file]
|
set result [gcc_load $output_file]
|
set status [lindex $result 0]
|
set status [lindex $result 0]
|
set output [lindex $result 1]
|
set output [lindex $result 1]
|
if { $status == -1 } {
|
if { $status == -1 } {
|
mike_cleanup $src_code $output_file $assembly_file
|
mike_cleanup $src_code $output_file $assembly_file
|
return
|
return
|
}
|
}
|
if { $verbose > 1 } {
|
if { $verbose > 1 } {
|
send_user "Checking:\n$program_output\nto see if it matches:\n$output\n\n"
|
send_user "Checking:\n$program_output\nto see if it matches:\n$output\n\n"
|
}
|
}
|
if ![regexp -- $program_output $output] {
|
if ![regexp -- $program_output $output] {
|
set pass no
|
set pass no
|
if { $verbose > 1 } {
|
if { $verbose > 1 } {
|
send_user "Nope, does not match.\n\n"
|
send_user "Nope, does not match.\n\n"
|
}
|
}
|
} else {
|
} else {
|
if { $verbose > 1 } {
|
if { $verbose > 1 } {
|
send_user "Yes, it matches.\n\n"
|
send_user "Yes, it matches.\n\n"
|
}
|
}
|
}
|
}
|
}
|
}
|
} else {
|
} else {
|
if { $verbose > 1 } {
|
if { $verbose > 1 } {
|
send_user "Nope, does not match.\n\n"
|
send_user "Nope, does not match.\n\n"
|
}
|
}
|
}
|
}
|
|
|
if [string match $pass "yes"] {
|
if [string match $pass "yes"] {
|
pass $pass_message
|
pass $pass_message
|
} else {
|
} else {
|
fail $fail_message
|
fail $fail_message
|
}
|
}
|
|
|
# The framework doesn't like to see any error remnants,
|
# The framework doesn't like to see any error remnants,
|
# so remove them.
|
# so remove them.
|
uplevel {
|
uplevel {
|
if [info exists errorInfo] {
|
if [info exists errorInfo] {
|
unset errorInfo
|
unset errorInfo
|
}
|
}
|
}
|
}
|
|
|
mike_cleanup $src_code $output_file $assembly_file
|
mike_cleanup $src_code $output_file $assembly_file
|
}
|
}
|
|
|