This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

New proc for gcc testsuite


Hi Guys,

  I would like to add a new proc to the gcc testsuite.  Actually it is
  a proc that is already in use for the eCos tests, and I would like
  to make it available to the rest of the testsuite.  The proc is
  called gcc_target_object_format, and it attempts to determine the
  file format in use by the compiler's target.  The reason that this
  proc is useful is that some compiler features are only supported by
  certain file formats, and hence should only be tested if that file
  format is in use.  (For example I want to add a test of the
  comnpiler's DLL support, but this is only supported by COFF/PE based
  toolchains).

  So - may I check this patch in please ?

Cheers
	Nick


1999-06-29  Nick Clifton  <nickc@cygnus.com>

	* lib/file-format.exp: New file: Move definition of proc 
	gcc_target_object_format to here from
	gcc.dg/special/ecos.exp.

	* lib/c-torture.exp: Include lib file-format.exp.
	* lib/gcc-dg.exp: Include lib file-format.exp.

	* gcc.dg/special/ecos.exp: Remove definition of proc
	gcc_target_object_format. 

*** /dev/null	Tue May  5 21:32:27 1998
- --- lib/file-format.exp	Tue Jun 29 09:54:22 1999
***************
*** 0 ****
- --- 1,73 ----
+ #   Copyright (C) 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
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ # 
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+ # 
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+ 
+ # Please email any bugs, comments, and/or additions to this file to:
+ # egcs-bugs@egcs.cygnus.com
+ 
+ # This file defines a proc for determining the file format in use by the
+ # target.  This is useful for tests that are only supported by certain file
+ # formats.  This procedure is defined in a seperate file so that it can be
+ # included by other expect library files.
+ 
+ proc gcc_target_object_format { } { 
+     global gcc_target_object_format_saved
+ 
+     if [info exists gcc_target_object_format_saved] {
+         verbose "gcc_target_object_format returning saved $gcc_target_object_format_saved" 2
+     } else {
+         set objdump_name [find_binutils_prog objdump]
+         set open_file [open objfmtst.c w]
+         puts $open_file "void foo(void) { }"
+         close $open_file
+         
+         gcc_target_compile objfmtst.c objfmtst.o object ""
+         
+         set output [exec $objdump_name --file-headers objfmtst.o ]
+         
+         file delete objfmtst.o
+         
+         if ![ regexp "file format (.*)arch" $output dummy objformat ]  {
+             verbose "Could not parse objdump output" 2
+             set gcc_target_object_format_saved unknown
+         } else {
+             switch -regexp $objformat {
+                 elf          {
+                     set gcc_target_object_format_saved elf
+                 } 
+                 ecoff        {
+                     set gcc_target_object_format_saved ecoff
+                 }
+                 coff         {
+                     set gcc_target_object_format_saved coff
+                 }
+                 a\.out       {
+                     set gcc_target_object_format_saved a.out
+                 }
+                 pe       {
+                     set gcc_target_object_format_saved pe
+                 }
+                 default      {
+                     verbose "Unknown file format: $objformat" 3
+                     set gcc_target_object_format_saved unknown
+                 }
+             }
+ 	    
+             verbose "gcc_target_object_format returning $gcc_target_object_format_saved" 2
+         }
+     }
+ 
+     return $gcc_target_object_format_saved
+ }

Index: lib/c-torture.exp
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/lib/c-torture.exp,v
retrieving revision 1.10
diff -p -r1.10 c-torture.exp
*** c-torture.exp	1999/02/24 14:12:44	1.10
- --- c-torture.exp	1999/06/29 09:24:10
***************
*** 19,24 ****
- --- 19,26 ----
  
  # This file was written by Rob Savoye. (rob@cygnus.com)
  
+ load_lib file-format.exp
+ 
  # The default option list can be overridden by
  # TORTURE_OPTIONS="{ { list1 } ... { listN } }"
  
Index: lib/gcc-dg.exp
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/lib/gcc-dg.exp,v
retrieving revision 1.3
diff -p -r1.3 gcc-dg.exp
*** gcc-dg.exp	1998/12/16 22:24:21	1.3
- --- gcc-dg.exp	1999/06/29 09:24:10
***************
*** 1,4 ****
! #   Copyright (C) 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) 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
***************
*** 20,25 ****
- --- 20,26 ----
  # Define gcc callbacks for dg.exp.
  
  load_lib dg.exp
+ load_lib file-format.exp
  
  proc gcc-dg-test { prog do_what extra_tool_flags } {
      # Set up the compiler flags, based on what we're going to do.

Index: gcc.dg/special/ecos.exp
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/gcc.dg/special/ecos.exp,v
retrieving revision 1.1
diff -p -r1.1 ecos.exp
*** ecos.exp	1999/02/10 16:00:06	1.1
- --- ecos.exp	1999/06/29 09:24:11
***************
*** 24,82 ****
  # Load support procs.
  load_lib gcc-dg.exp
  
! ###################################
! # proc gcc_target_object_format { }
! ###################################
! 
! proc gcc_target_object_format { } { 
!     global gcc_target_object_format_saved
! 
!     if [info exists gcc_target_object_format_saved] {
!         verbose "gcc_target_object_format returning saved $gcc_target_object_format_saved" 2
!         return $gcc_target_object_format_saved
!     } else {
! 
!         set objdump_name [find_binutils_prog objdump]
!         set open_file [open objfmtst.c w]
!         puts $open_file "void foo(void) { }"
!         close $open_file
!         
!         gcc_target_compile objfmtst.c objfmtst.o object ""
!         
!         set output [exec $objdump_name --file-headers objfmtst.o ]
!         
!         file delete objfmtst.o
!         
!         if ![ regexp "file format (.*)arch" $output dummy objformat ]  {
!             verbose "Could not parse objdump output" 2
!             set gcc_target_object_format_saved unknown
!         } else {
!             switch -regexp $objformat {
!                 elf          {
!                     verbose "gcc_target_object_format returning elf" 2
!                     set gcc_target_object_format_saved elf
!                 } 
!                 ecoff        {
!                     verbose "gcc_target_object_format returning ecoff" 2
!                     set gcc_target_object_format_saved ecoff
!                 }
!                 coff         {
!                     verbose "gcc_target_object_format returning coff" 2
!                     set gcc_target_object_format_saved coff
!                 }
!                 a\.out       {
!                     verbose "gcc_target_object_format returning a.out" 2
!                     set gcc_target_object_format_saved a.out
!                 }
!                 default      {
!                     verbose "gcc_target_object_format returning unknown" 2
!                     set gcc_target_object_format_saved unknown
!                 }
!             }
!         }
!         return $gcc_target_object_format_saved
!     }
! }
  
  ###############################
  # proc check_weak_available { }
- --- 24,33 ----
  # Load support procs.
  load_lib gcc-dg.exp
  
! ###############################
! # proc gcc_target_object_format {}
! ###############################
! # has been moved to:  gcc/testsuite/lib/file-format.exp
  
  ###############################
  # proc check_weak_available { }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]