lib/c-torture.exp (c-torture-compile): Pull out code for ...

Jim Wilson wilson@cygnus.com
Wed Feb 10 12:27:00 GMT 1999


I've checked in this patch to the gcc testsuite.

This takes some duplicated code out of c-torture.exp and puts it in gcc.exp
so it can be shared.  Commoning the code also fixes a few minor bugs.  In
the old code, it was possible for an execute test to fail to compile, and then
by marked as PASS for the compile and FAIL for execution.  It is now marked
FAIL for the compile and UNRESOLVED for execution.	
	
Wed Feb 10 12:15:35 1999  Felix Lee  <flee@cygnus.com>

        * lib/c-torture.exp (c-torture-compile): Pull out code for
        analyzing gcc error messages.
        (c-torture-execute): Likewise.  Fix some (harmless) false
        positives.
        * lib/gcc.exp (gcc_check_compile): New function.

Index: c-torture.exp
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/lib/c-torture.exp,v
retrieving revision 1.8
diff -p -r1.8 c-torture.exp
*** c-torture.exp	1998/12/16 22:24:16	1.8
--- c-torture.exp	1999/02/10 20:17:30
***************
*** 1,4 ****
! # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
  
  # 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
--- 1,4 ----
! # Copyright (C) 1992-1998, 1999 Free Software Foundation, Inc.
  
  # 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
*************** proc c-torture-compile { src option } {
*** 76,125 ****
      lappend options "additional_flags=-w $option"
  
      set comp_output [gcc_target_compile "$src" "$output" object $options];
!     
!     # Set a few common compiler messages.
!     set fatal_signal "*cc: Internal compiler error: program*got fatal signal"
!  
!     if [string match "$fatal_signal 6" $comp_output] then {
! 	gcc_fail $testcase "Got Signal 6, $option"
! 	remote_file build delete $output
! 	return
!     }
! 
!     if [string match "$fatal_signal 11" $comp_output] then {
! 	gcc_fail $testcase "Got Signal 11, $option"
! 	remote_file build delete $output
! 	return
!     }
! 
!     # We shouldn't get these because of -w, but just in case.
!     if [string match "*cc:*warning:*" $comp_output] then {
! 	warning "$testcase: (with warnings) $option"
! 	send_log "$comp_output\n"
! 	unresolved "$testcase, $option"
! 	remote_file build delete $output
! 	return
!     }
! 
!     set comp_output [prune_warnings $comp_output]
! 
!     set unsupported_message [gcc_check_unsupported_p $comp_output]
!     if { $unsupported_message != "" } {
! 	unsupported "$testcase: $unsupported_message"
! 	remote_file build delete $output
! 	return
!     }
! 
!     # remove any leftover LF/CR to make sure any output is legit
!     regsub -all -- "\[\r\n\]*" $comp_output "" comp_output
!     # If any message remains, we fail.
!     if ![string match "" $comp_output] then {
! 	gcc_fail $testcase $option
! 	remote_file build delete $output
! 	return
!     }
! 
!     gcc_pass $testcase $option
      remote_file build delete $output
  }
  
--- 76,82 ----
      lappend options "additional_flags=-w $option"
  
      set comp_output [gcc_target_compile "$src" "$output" object $options];
!     gcc_check_compile $testcase $option $output $comp_output
      remote_file build delete $output
  }
  
*************** proc c-torture-execute { src args } {
*** 201,257 ****
  	}
  	set comp_output [gcc_target_compile "$src" "${execname}" executable $options];
  
! 	# Set a few common compiler messages.
! 	set fatal_signal "*cc: Internal compiler error: program*got fatal signal"
! 	
! 	if [string match "$fatal_signal 6" $comp_output] then {
! 	    gcc_fail $testcase "Got Signal 6, $option"
! 	    remote_file build delete $execname
! 	    continue
! 	}
! 	
! 	if [string match "$fatal_signal 11" $comp_output] then {
! 	    gcc_fail $testcase "Got Signal 11, $option"
! 	    remote_file build delete $execname
! 	    continue
! 	}
! 	
! 	# We shouldn't get these because of -w, but just in case.
! 	if [string match "*cc:*warning:*" $comp_output] then {
! 	    warning "$testcase: (with warnings) $option"
! 	    send_log "$comp_output\n"
! 	    unresolved "$testcase, $option"
  	    remote_file build delete $execname
  	    continue
  	}
- 	
- 	set comp_output [prune_warnings $comp_output]
- 	
- 	set unsupported_message [gcc_check_unsupported_p $comp_output]
- 
- 	if { $unsupported_message != "" } {
- 	    unsupported "$testcase: $unsupported_message"
- 	    continue
- 	} elseif ![file exists $execname] {
- 	    if ![is3way] {
- 		fail "$testcase compilation, $option"
- 		untested "$testcase execution, $option"
- 		continue
- 	    } else {
- 		# FIXME: since we can't test for the existance of a remote
- 		# file without short of doing an remote file list, we assume
- 		# that since we got no output, it must have compiled.
- 		pass "$testcase compilation, $option"		
- 	    }
- 	} else {
- 	    pass "$testcase compilation, $option"
- 	}
  
  	# See if this source file uses "long long" types, if it does, and
  	# no_long_long is set, skip execution of the test.
  	if [target_info exists no_long_long] then {
  	    if [expr [search_for $src "long long"]] then {
! 		untested "$testcase execution, $option"
  		continue
  	    }
  	}
--- 158,174 ----
  	}
  	set comp_output [gcc_target_compile "$src" "${execname}" executable $options];
  
! 	if ![gcc_check_compile "$testcase compilation" $option $execname $comp_output] {
! 	    unresolved "$testcase execution, $option"
  	    remote_file build delete $execname
  	    continue
  	}
  
  	# See if this source file uses "long long" types, if it does, and
  	# no_long_long is set, skip execution of the test.
  	if [target_info exists no_long_long] then {
  	    if [expr [search_for $src "long long"]] then {
! 		unsupported "$testcase execution, $option"
  		continue
  	    }
  	}
Index: gcc.exp
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/lib/gcc.exp,v
retrieving revision 1.2
diff -p -r1.2 gcc.exp
*** gcc.exp	1998/12/16 22:24:22	1.2
--- gcc.exp	1999/02/10 20:17:30
***************
*** 1,4 ****
! # Copyright (C) 1992, 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
  
  # 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
--- 1,4 ----
! # Copyright (C) 1992, 1993, 1994, 1996, 1997, 1999 Free Software Foundation, Inc.
  
  # 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
*************** proc gcc_target_compile { source dest ty
*** 147,152 ****
--- 147,206 ----
      lappend options "compiler=$GCC_UNDER_TEST"
      return [target_compile $source $dest $type $options]
  }
+ 
+ 
+ # Reports pass/fail for a gcc compilation and returns true/false.
+ proc gcc_check_compile {testcase option objname gcc_output} {
+ 
+     set fatal_signal "*cc: Internal compiler error: program*got fatal signal"
+  
+     if [string match "$fatal_signal 6" $gcc_output] then {
+ 	gcc_fail $testcase "Got Signal 6, $option"
+ 	return 0
+     }
+ 
+     if [string match "$fatal_signal 11" $gcc_output] then {
+ 	gcc_fail $testcase "Got Signal 11, $option"
+ 	return 0
+     }
+ 
+     # We shouldn't get these because of -w, but just in case.
+     if [string match "*cc:*warning:*" $gcc_output] then {
+ 	warning "$testcase: (with warnings) $option"
+ 	send_log "$gcc_output\n"
+ 	unresolved "$testcase, $option"
+ 	return 0
+     }
+ 
+     set gcc_output [prune_warnings $gcc_output]
+ 
+     set unsupported_message [gcc_check_unsupported_p $gcc_output]
+     if { $unsupported_message != "" } {
+ 	unsupported "$testcase: $unsupported_message"
+ 	return 0
+     }
+ 
+     # remove any leftover LF/CR to make sure any output is legit
+     regsub -all -- "\[\r\n\]*" $gcc_output "" gcc_output
+ 
+     # If any message remains, we fail.
+     if ![string match "" $gcc_output] then {
+ 	gcc_fail $testcase $option
+ 	return 0
+     }
+ 
+     # fail if the desired object file doesn't exist.
+     # FIXME: there's no way of checking for existence on a remote host.
+     if {$objname != "" && ![is3way] && ![file exists $objname]} {
+ 	gcc_fail $testcase $option
+ 	return 0
+     }
+ 
+     gcc_pass $testcase $option
+     return 1
+ }
+ 
+ 
  
  #
  # gcc_pass -- utility to record a testcase passed


More information about the Gcc-patches mailing list