This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: Export LC_ALL=C (Re: Sorting in nm and testsuite)
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Geoff Keating <geoffk at redhat dot com>
- Cc: hjl at lucon dot org, binutils at sources dot redhat dot com
- Date: Tue, 2 Jul 2002 20:40:52 +0930
- Subject: Re: PATCH: Export LC_ALL=C (Re: Sorting in nm and testsuite)
- References: <20020625093422.A19940@lucon.org> <15640.41118.308312.396608@tooth.toronto.redhat.com> <20020625101431.A20781@lucon.org> <3D18BDFE.30403@cygnus.com> <20020625134922.A24058@lucon.org> <20020626050021.GA4895@nevyn.them.org> <20020626051946.GT22093@bubble.sa.bigpond.net.au> <200206270000.g5R00sm28947@desire.geoffk.org>
On Wed, Jun 26, 2002 at 05:00:54PM -0700, Geoff Keating wrote:
> > Date: Wed, 26 Jun 2002 14:49:46 +0930
> > From: Alan Modra <amodra@bigpond.net.au>
>
> > I happen to think it quite reasonable to set LC_ALL in
> > the makefile. If you're in the habit of running standalone tests,
> > you'll soon get into the habit of setting one more environment var as
> > well. :)
>
> It's not 'one more', it's 'one'. Normally you don't need to set any
> special environment variables to use runtest.
>
> After all, we're not saying that we only support binutils when
> LC_ALL=C, right? So how can we test them with other LC_ALL settings
> if the testsuite requires LC_ALL=C everywhere?
Oh well, how about this then? I'm a raw amateur when it comes to
expect and tcl, so I'd appreciate someone reviewing this critically.
This patch should allow us to revert H.J.'s 2002-06-25 LC_ALL patch,
but note we still have ld/Makefile.am setting LC_COLLATE, LC_ALL and
LANG, for the benefit of ld/testsuite/ld-elfvers/vers.exp which uses
sort. I guess something similar could be done there.
gas/testsuite/ChangeLog
* lib/gas-defs.exp (run_dump_test): Run objdump/nm/objcopy/readelf
with LC_ALL=C to ensure consistent sorting.
ld/testsuite/ChangeLog
* lib/ld-lib.exp (default_ld_nm): Run nm with LC_ALL=C to ensure
consistent sorting.
(run_dump_test): Likewise for objdump/nm/objcopy/readelf.
* ld-sh/sh64/sh64.exp (run_ld_link_tests): Likewise.
Index: gas/testsuite/lib/gas-defs.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/lib/gas-defs.exp,v
retrieving revision 1.8
diff -u -p -r1.8 gas-defs.exp
--- gas/testsuite/lib/gas-defs.exp 30 May 2002 16:12:23 -0000 1.8
+++ gas/testsuite/lib/gas-defs.exp 2 Jul 2002 10:47:27 -0000
@@ -227,7 +227,9 @@ proc gas_init { args } {
# nm: FLAGS
# objcopy: FLAGS
# Use the specified program to analyze the .o file, and pass it
-# FLAGS, in addition to the .o file name.
+# FLAGS, in addition to the .o file name. Note that they are run
+# with LC_ALL=C in the environment to give consistent sorting
+# of symbols.
#
# source: SOURCE
# Assemble the file SOURCE.s. If omitted, this defaults to FILE.s.
@@ -250,6 +252,7 @@ proc run_dump_test { name } {
global OBJDUMP NM AS OBJCOPY READELF
global OBJDUMPFLAGS NMFLAGS ASFLAGS OBJCOPYFLAGS READELFFLAGS
global host_triplet
+ global env
if [string match "*/*" $name] {
set file $name
@@ -401,24 +404,28 @@ proc run_dump_test { name } {
# Objcopy, unlike the other two, won't send its output to stdout,
# so we have to run it specially.
+ set cmd "$binary $progopts $progopts1 dump.o > dump.out"
if { $program == "objcopy" } {
- send_log "$binary $progopts $progopts1 dump.o dump.out\n"
- catch "exec $binary $progopts $progopts1 dump.o dump.out" comp_output
- set comp_output [prune_warnings $comp_output]
- if ![string match "" $comp_output] then {
- send_log "$comp_output\n"
- fail $testname
- return
- }
+ set cmd "$binary $progopts $progopts1 dump.o dump.out"
+ }
+
+ # Ensure consistent sorting of symbols
+ if {[info exists env(LC_ALL)]} {
+ set old_lc_all $env(LC_ALL)
+ }
+ set env(LC_ALL) "C"
+ send_log "$cmd\n"
+ catch "exec $cmd" comp_output
+ if {[info exists old_lc_all]} {
+ set env(LC_ALL) $old_lc_all
} else {
- send_log "$binary $progopts $progopts1 dump.o > dump.out\n"
- catch "exec $binary $progopts $progopts1 dump.o > dump.out" comp_output
- set comp_output [prune_warnings $comp_output]
- if ![string match "" $comp_output] then {
- send_log "$comp_output\n"
- fail $testname
- return
- }
+ unset env(LC_ALL)
+ }
+ set comp_output [prune_warnings $comp_output]
+ if ![string match "" $comp_output] then {
+ send_log "$comp_output\n"
+ fail $testname
+ return
}
verbose_eval {[file_contents "dump.out"]} 3
Index: ld/testsuite/ld-sh/sh64/sh64.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-sh/sh64/sh64.exp,v
retrieving revision 1.1
diff -u -p -r1.1 sh64.exp
--- ld/testsuite/ld-sh/sh64/sh64.exp 8 Feb 2002 06:49:58 -0000 1.1
+++ ld/testsuite/ld-sh/sh64/sh64.exp 2 Jul 2002 10:47:29 -0000
@@ -132,6 +132,7 @@ proc run_ld_link_tests { ldtests } {
global readelf
global srcdir
global subdir
+ global env
set binfile "tmpdir/linked"
@@ -199,8 +200,19 @@ proc run_ld_link_tests { ldtests } {
set dumpfile [lindex $actionlist 2]
set binary $dump_prog
- send_log "$binary $progopts $binfile > dump.out\n"
- catch "exec $binary $progopts $binfile > dump.out" comp_output
+ # Ensure consistent sorting of symbols
+ if {[info exists env(LC_ALL)]} {
+ set old_lc_all $env(LC_ALL)
+ }
+ set env(LC_ALL) "C"
+ set cmd "$binary $progopts $binfile > dump.out"
+ send_log "$cmd\n"
+ catch "exec $cmd" comp_output
+ if {[info exists old_lc_all]} {
+ set env(LC_ALL) $old_lc_all
+ } else {
+ unset env(LC_ALL)
+ }
set comp_output [prune_warnings $comp_output]
if ![string match "" $comp_output] then {
Index: ld/testsuite/lib/ld-lib.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/lib/ld-lib.exp,v
retrieving revision 1.14
diff -u -p -r1.14 ld-lib.exp
--- ld/testsuite/lib/ld-lib.exp 7 May 2002 11:08:55 -0000 1.14
+++ ld/testsuite/lib/ld-lib.exp 2 Jul 2002 10:47:29 -0000
@@ -299,9 +299,19 @@ proc default_ld_nm { nm nmflags object }
if ![info exists NMFLAGS] { set NMFLAGS "" }
+ # Ensure consistent sorting of symbols
+ if {[info exists env(LC_ALL)]} {
+ set old_lc_all $env(LC_ALL)
+ }
+ set env(LC_ALL) "C"
verbose -log "$nm $NMFLAGS $nmflags $object >tmpdir/nm.out"
catch "exec $nm $NMFLAGS $nmflags $object >tmpdir/nm.out" exec_output
+ if {[info exists old_lc_all]} {
+ set env(LC_ALL) $old_lc_all
+ } else {
+ unset env(LC_ALL)
+ }
set exec_output [prune_warnings $exec_output]
if [string match "" $exec_output] then {
set file [open tmpdir/nm.out r]
@@ -474,6 +484,8 @@ proc simple_diff { file_1 file_2 } {
# objcopy: FLAGS
# Use the specified program to analyze the assembler or linker
# output file, and pass it FLAGS, in addition to the output name.
+# Note that they are run with LC_ALL=C in the environment to give
+# consistent sorting of symbols.
#
# source: SOURCE [FLAGS]
# Assemble the file SOURCE.s using the flags in the "as" directive
@@ -512,6 +524,7 @@ proc run_dump_test { name } {
global OBJDUMP NM AS OBJCOPY READELF LD
global OBJDUMPFLAGS NMFLAGS ASFLAGS OBJCOPYFLAGS READELFFLAGS LDFLAGS
global host_triplet runtests
+ global env
if [string match "*/*" $name] {
set file $name
@@ -778,26 +791,28 @@ proc run_dump_test { name } {
# Objcopy, unlike the other two, won't send its output to stdout,
# so we have to run it specially.
+ set cmd "$binary $progopts $progopts1 $objfile > $dumpfile"
if { $program == "objcopy" } {
set cmd "$binary $progopts $progopts1 $objfile $dumpfile"
- send_log "$cmd\n"
- catch "exec $cmd" comp_output
- set comp_output [prune_warnings $comp_output]
- if ![string match "" $comp_output] then {
- send_log "$comp_output\n"
- fail $testname
- return
- }
+ }
+
+ # Ensure consistent sorting of symbols
+ if {[info exists env(LC_ALL)]} {
+ set old_lc_all $env(LC_ALL)
+ }
+ set env(LC_ALL) "C"
+ send_log "$cmd\n"
+ catch "exec $cmd" comp_output
+ if {[info exists old_lc_all]} {
+ set env(LC_ALL) $old_lc_all
} else {
- set cmd "$binary $progopts $progopts1 $objfile > $dumpfile"
- send_log "$cmd\n"
- catch "exec $cmd" comp_output
- set comp_output [prune_warnings $comp_output]
- if ![string match "" $comp_output] then {
- send_log "$comp_output\n"
- fail $testname
- return
- }
+ unset env(LC_ALL)
+ }
+ set comp_output [prune_warnings $comp_output]
+ if ![string match "" $comp_output] then {
+ send_log "$comp_output\n"
+ fail $testname
+ return
}
verbose_eval {[file_contents $dumpfile]} 3
--
Alan Modra
IBM OzLabs - Linux Technology Centre