This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[generic + mips testsuite patch]: run_dump_test w/ extraoptions


[ this needs MIPS approval and general gas testsuite approval.  Skip
  to the patch if you're interested in the latter. 8-]

The following patch adds the ability for machine-specific test .exp
files to pass an additional option to run_dump_test, which causes it
to add extra "stuff" to the test name or to the arg lists used to run
various programs.

It adds code to the MIPS test code to make use of this.


This was motivated by the following problem:

The MIPS port supports many -march=<whatever> switches, which cause
assembler to be generated for a particular architecture.

However, in order to produce consistent test results, most of the MIPS
testsuite entries hard-wire a single architecture!

This, of course, means that one could possibly break a 'random'
architecture in a strange way, and one wouldn't notice.

One solution which has been employed is to have multiple .d files for
a given test.  This works out well for a limited number of variations,
e.g. "r3000" vs. "r4000" (i.e., 32-bit GPRs vs. 64-bit GPRs), but
still typically you end up with exactly 2 test cases for 2 specific
architectures, and the rest are left to work or not work as the case
may be.

Of course, one could make N .d files, but that is ... tedious.
mips1, mips2, mips3, mips4, mips32, mips64, ... and those are just
some of the "stock" ISAs.  add in individual CPUs and it would get
horrible.  Of course, each file would have to have slightly different
headers.

So, the solution:

Provide the ability to have a 'generic' .d file for each type, and
have the expect code add arguments for a given test.

For example, with this modification, there are currently 2 "32-bit
rotate" tests: rol.d and rol-hw.d (both of which use the same rol.s
source file).  The former is on architectures with no hardware 'ror'
instruction, the latter for architectures with a hardware 'ror'
instruction.

The result is testsuite output like:

	PASS: MIPS macro rol/ror (mips1)
	PASS: MIPS macro rol/ror (mips3)
	PASS: MIPS macro rol/ror (mips32)
	PASS: MIPS macro rol/ror (mips64)
	PASS: MIPS macro rol/ror (sb1)
	PASS: MIPS hardware rol/ror (vr5400)

and, of course, better test coverage for random architectures.


At first i've only converted the rotate tests (since i wanted to fix
them anyway for something else i'm working on).

Eventually I hope others will create more MIPS tests and generally add
to the infrastructure so that coverage is improved.

It would be nice if complete testing of the expected default
architecture for a given set of tools was added.  More future work for
somebody.  8-)



chris
===================================================================
2002-12-18  Chris Demetriou  <cgd@broadcom.com>

	* lib/gas-defs.exp (run_dump_test): Add a new optional argument,
	"extra_options".

	* gas/mips/mips.exp (run_dump_test_arch): New function.
	(run_dump_test_arches): Likewise.
	(rol, rol-hw, rol64, rol64-hw): Run with run_dump_test_arches.
	* gas/mips/rol.d: Remove compiler and objdump flags, and
	architecture from test name.
	* gas/mips/rol-hw.d: Likewise.
	* gas/mips/rol64.d: Likewise.
	* gas/mips/rol64-hw.d: Likewise.

Index: gas/mips/mips.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.52
diff -u -p -r1.52 mips.exp
--- gas/mips/mips.exp	18 Dec 2002 22:52:48 -0000	1.52
+++ gas/mips/mips.exp	19 Dec 2002 01:09:05 -0000
@@ -21,6 +21,64 @@ proc run_list_test { name opts } {
     pass $testname
 }
 
+# Invoke run_dump_test with extra arguments as appropriate for a given
+# architecture.  (Note: for now, the list of architectures here is
+# incomplete.)
+proc run_dump_test_arch { name arch } {
+    global subdir
+
+    set name_extra "($arch)"
+
+    # XXX FIXME: reimplement as tcl array or other data structure.
+    case "$arch" in {
+        "mips1"			{
+	    set as_extra "-march=mips1 -mtune=mips1"
+	    set objdump_extra "-mmips:3000"
+	}
+        "mips3"			{
+	    set as_extra "-march=mips3 -mtune=mips3"
+	    set objdump_extra "-mmips:4000"
+	}
+        "mips32"		{
+	    set as_extra "-march=mips32 -mtune=mips32"
+	    set objdump_extra "-mmips:isa32"
+	}
+        "mips64"		{
+	    set as_extra "-march=mips64 -mtune=mips64"
+	    set objdump_extra "-mmips:isa64"
+	}
+        "r3000"			{
+	    set as_extra "-march=r3000 -mtune=r3000"
+	    set objdump_extra "-mmips:3000"
+	}
+        "r4000"			{
+	    set as_extra "-march=r4000 -mtune=r4000"
+	    set objdump_extra "-mmips:4000"
+	}
+	"sb1"			{
+	    set as_extra "-march=sb1 -mtune=sb1"
+	    set objdump_extra "-mmips:sb1"
+	}
+	"vr5400"		{
+	    set as_extra "-march=vr5400 -mtune=vr5400"
+	    set objdump_extra "-mmips:5400"
+	}
+        default                 {
+	    perror "unknown arch \"$arch\" passed to run_dump_test_arch"
+            unresolved $subdir/$name+$arch
+	    return
+	}
+    }
+    run_dump_test $name \
+      "{name {$name_extra}} {as {$as_extra}} {objdump {$objdump_extra}}"
+}
+
+proc run_dump_test_arches { name arch_list } {
+    foreach arch $arch_list {
+	run_dump_test_arch $name $arch
+    }
+}
+
 if { [istarget mips*-*-*] } then {
     set no_mips16 0
     set elf [expr [istarget *-*-elf*] || [istarget *-*-irix5*] || [istarget *-*-irix6* ] || [istarget *-*-linux*] || [istarget *-*-netbsd*] ]
@@ -124,10 +182,13 @@ if { [istarget mips*-*-*] } then {
     } else {
 	run_dump_test "mul"
     }
-    run_dump_test "rol"
-    run_dump_test "rol-hw"
-    run_dump_test "rol64"
-    run_dump_test "rol64-hw"
+
+    run_dump_test_arches "rol"		{ mips1 mips3 mips32 mips64 sb1 }
+    run_dump_test_arches "rol-hw"	{ vr5400 }
+
+    run_dump_test_arches "rol64"	{ mips3 mips64 sb1 }
+    run_dump_test_arches "rol64-hw"	{ vr5400 }
+
     if !$aout { run_dump_test "sb" }
     run_dump_test "trunc"
     if !$aout { run_dump_test "ulh" }
Index: gas/mips/rol-hw.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/rol-hw.d,v
retrieving revision 1.1
diff -u -p -r1.1 rol-hw.d
--- gas/mips/rol-hw.d	18 Dec 2002 22:52:48 -0000	1.1
+++ gas/mips/rol-hw.d	19 Dec 2002 01:09:05 -0000
@@ -1,6 +1,5 @@
-#objdump: -dr --prefix-addresses -mmips:5400
-#as: -march=vr5400 -mtune=vr5400
-#name: MIPS hardware rol (vr5400)
+#objdump: -dr --prefix-addresses
+#name: MIPS hardware rol/ror
 #source: rol.s
 #stderr: rol-hw.l
 
Index: gas/mips/rol.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/rol.d,v
retrieving revision 1.5
diff -u -p -r1.5 rol.d
--- gas/mips/rol.d	18 Dec 2002 22:52:48 -0000	1.5
+++ gas/mips/rol.d	19 Dec 2002 01:09:05 -0000
@@ -1,6 +1,5 @@
-#objdump: -dr --prefix-addresses -mmips:3000
-#as: -march=r3000 -mtune=r3000
-#name: MIPS macro rol (r3000)
+#objdump: -dr --prefix-addresses
+#name: MIPS macro rol/ror
 #stderr: rol.l
 
 # Test the rol and ror macros.
Index: gas/mips/rol64-hw.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/rol64-hw.d,v
retrieving revision 1.1
diff -u -p -r1.1 rol64-hw.d
--- gas/mips/rol64-hw.d	18 Dec 2002 22:52:48 -0000	1.1
+++ gas/mips/rol64-hw.d	19 Dec 2002 01:09:05 -0000
@@ -1,6 +1,5 @@
-#objdump: -dr --prefix-addresses -mmips:5400
-#as: -march=vr5400 -mtune=vr5400
-#name: MIPS hardware drol (vr5400)
+#objdump: -dr --prefix-addresses
+#name: MIPS hardware drol/dror
 #source: rol64.s
 #stderr: rol64-hw.l
 
Index: gas/mips/rol64.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/rol64.d,v
retrieving revision 1.3
diff -u -p -r1.3 rol64.d
--- gas/mips/rol64.d	18 Dec 2002 22:52:48 -0000	1.3
+++ gas/mips/rol64.d	19 Dec 2002 01:09:05 -0000
@@ -1,6 +1,5 @@
-#objdump: -dr --prefix-addresses -mmips:4000
-#as: -march=r4000 -mtune=r4000
-#name: MIPS macro drol (r4000)
+#objdump: -dr --prefix-addresses
+#name: MIPS macro drol/dror
 #stderr: rol64.l
 
 # Test the drol and dror macros.
Index: lib/gas-defs.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/lib/gas-defs.exp,v
retrieving revision 1.10
diff -u -p -r1.10 gas-defs.exp
--- lib/gas-defs.exp	9 Sep 2002 01:54:45 -0000	1.10
+++ lib/gas-defs.exp	19 Dec 2002 01:09:06 -0000
@@ -183,7 +183,7 @@ proc gas_init { args } {
 }
 
 
-# run_dump_test FILE
+# run_dump_test FILE (optional:) EXTRA_OPTIONS
 #
 # Assemble a .s file, then run some utility on it and check the output.
 #
@@ -207,6 +207,12 @@ proc gas_init { args } {
 # list ends with the first line that doesn't match the above syntax
 # (hmm, not great for error detection).
 #
+# The optional EXTRA_OPTIONS argument to `run_dump_test' is a list of
+# two-element lists.  The first element of each is an option name, and
+# the second additional arguments to be added on to the end of the
+# option list as given in FILE.d.  (If omitted, no additional options
+# are added.)
+#
 # The interesting options are:
 #
 #   name: TEST-NAME
@@ -247,7 +253,7 @@ proc gas_init { args } {
 # regexps in FILE.d.  `regexp_diff' is defined later in this file; see
 # further comments there.
 
-proc run_dump_test { name } {
+proc run_dump_test { name {extra_options {}} } {
     global subdir srcdir
     global OBJDUMP NM AS OBJCOPY READELF
     global OBJDUMPFLAGS NMFLAGS ASFLAGS OBJCOPYFLAGS READELFFLAGS
@@ -291,6 +297,22 @@ proc run_dump_test { name } {
 	    return
 	}
 	set opts($opt_name) $opt_val
+    }
+
+    foreach i $extra_options {
+	set opt_name [lindex $i 0]
+	set opt_val [lindex $i 1]
+	if ![info exists opts($opt_name)] {
+	    perror "unknown option $opt_name given in extra_opts"
+	    unresolved $subdir/$name
+	    return
+	}
+	# add extra option to end of existing option, adding space
+	# if necessary.
+	if [string length $opts($opt_name)] {
+	    append opts($opt_name) " "
+	}
+	append opts($opt_name) $opt_val
     }
 
     if {$opts(PROG) != ""} {


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