This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[RFA] Testsuite: remove regexp_diff from readelf.exp
- From: Richard Earnshaw <Richard dot Earnshaw at buzzard dot freeserve dot co dot uk>
- To: binutils at sourceware dot org
- Date: Sat, 21 Apr 2007 12:38:17 +0100
- Subject: [RFA] Testsuite: remove regexp_diff from readelf.exp
proc regexp_diff has been provided by lib/utils-lib.exp since April
last year, so the copy in readelf.exp is now technically redundant.
More importantly, the version in readelf.exp has a bug which means that
if the template file has
#...
at the end of the file, then this fails to match the remainder properly.
This in turn can cause testsuite failures if the readelf version of this
proc overrides the utils-lib version. (This can happen if you run
multiple passes of the testsuite, for example as part of a multi-lib
system).
It seems to me that the best solution is to just remove the now outdated
version of this proc from readelf.exp and rely on the version in
utils-lib.exp
OK to apply?
R.
2007-04-21 Richard Earnshaw <rearnsha@arm.com>
* binutils-all/readelf.exp (regexp_diff): Delete.
Index: readelf.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/binutils-all/readelf.exp,v
retrieving revision 1.24
diff -p -p -r1.24 readelf.exp
*** readelf.exp 14 Feb 2007 10:05:59 -0000 1.24
--- readelf.exp 21 Apr 2007 11:29:17 -0000
*************** proc file_contents { filename } {
*** 31,138 ****
return $contents
}
- # regexp_diff, based on simple_diff taken from ld test suite
- # compares two files line-by-line
- # file1 contains strings, file2 contains regexps and #-comments
- # blank lines are ignored in either file
- # returns non-zero if differences exist
- #
- proc regexp_diff { file_1 file_2 } {
-
- set eof -1
- set end_1 0
- set end_2 0
- set differences 0
- set diff_pass 0
-
- if [file exists $file_1] then {
- set file_a [open $file_1 r]
- } else {
- warning "$file_1 doesn't exist"
- return 1
- }
-
- if [file exists $file_2] then {
- set file_b [open $file_2 r]
- } else {
- fail "$file_2 doesn't exist"
- close $file_a
- return 1
- }
-
- verbose " Regexp-diff'ing: $file_1 $file_2" 2
-
- while { 1 } {
- set line_a ""
- set line_b ""
- while { [string length $line_a] == 0 } {
- if { [gets $file_a line_a] == $eof } {
- set end_1 1
- break
- }
- }
- while { [string length $line_b] == 0 || [string match "#*" $line_b] }
{
- if [ string match "#pass" $line_b ] {
- set end_2 1
- set diff_pass 1
- break
- } elseif [ string match "#..." $line_b ] {
- if { [gets $file_b line_b] == $eof } {
- set end_2 1
- break
- }
- verbose "looking for \"^$line_b$\"" 3
- while { ![regexp "^$line_b$" "$line_a"] } {
- verbose "skipping \"$line_a\"" 3
- if { [gets $file_a line_a] == $eof } {
- set end_1 1
- break
- }
- }
- break
- }
- if { [gets $file_b line_b] == $eof } {
- set end_2 1
- break
- }
- }
-
- if { $diff_pass } {
- break
- } elseif { $end_1 && $end_2 } {
- break
- } elseif { $end_1 } {
- send_log "extra regexps in $file_2 starting with \"^
$line_b$\"\nEOF from $file_1\n"
- verbose "extra regexps in $file_2 starting with \"^$line_b
$\"\nEOF from $file_1" 3
- set differences 1
- break
- } elseif { $end_2 } {
- send_log "extra lines in $file_1 starting with \"^$line_a
$\"\nEOF from $file_2\n"
- verbose "extra lines in $file_1 starting with \"^$line_a
$\"\nEOF from $file_2\n" 3
- set differences 1
- break
- } else {
- verbose "regexp \"^$line_b$\"\nline \"$line_a\"" 3
- if ![regexp "^$line_b$" "$line_a"] {
- send_log "regexp_diff match failure\n"
- send_log "regexp \"^$line_b$\"\nline \"$line_a\"\n"
- set differences 1
- }
- }
- }
-
- if { $differences == 0 && !$diff_pass && [eof $file_a] != [eof
$file_b] } {
- send_log "$file_1 and $file_2 are different lengths\n"
- verbose "$file_1 and $file_2 are different lengths" 3
- set differences 1
- }
-
- close $file_a
- close $file_b
-
- return $differences
- }
-
# Find out the size by reading the output of the EI_CLASS field.
# Similar to the test for readelf -h, but we're just looking for the
# EI_CLASS line here.
--- 31,36 ----