]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
binutils/testsuite/
authorRichard Sandiford <rdsandiford@googlemail.com>
Sat, 20 Nov 2010 15:36:34 +0000 (15:36 +0000)
committerRichard Sandiford <rdsandiford@googlemail.com>
Sat, 20 Nov 2010 15:36:34 +0000 (15:36 +0000)
* lib/binutils-common.exp (regexp_diff): New procedure.
* lib/utils-lib.exp (regexp_diff): Delete.

gas/testsuite/
* lib/gas-defs.exp (regexp_diff): Delete.
(run_dump_test): Remove final "" argument in call to regexp_diff.
(run_list_test): Likewise.
(run_list_test_stdin): Likewise.
* gas/all/gas.exp (test_cond): Likewise.
* gas/elf/elf.exp (run_elf_list_test): Likewise.
* gas/m68k/all.exp: Likewise.
* gas/mep/complex-relocs.exp (regexp_test): Likewise.
* gas/mt/relocs.exp (regexp_test): Likewise.
* gas/symver/symver.exp (run_error_test): Likewise.

ld/testsuite/
* lib/ld-lib.exp (regexp_diff, simple_diff): Delete.

13 files changed:
binutils/testsuite/ChangeLog
binutils/testsuite/lib/binutils-common.exp
binutils/testsuite/lib/utils-lib.exp
gas/testsuite/ChangeLog
gas/testsuite/gas/all/gas.exp
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/m68k/all.exp
gas/testsuite/gas/mep/complex-relocs.exp
gas/testsuite/gas/mt/relocs.exp
gas/testsuite/gas/symver/symver.exp
gas/testsuite/lib/gas-defs.exp
ld/testsuite/ChangeLog
ld/testsuite/lib/ld-lib.exp

index 0c29b9c8995754ce4a3a0532eeefb4f478f74938..e044acc13726815f86a72d017c187c87ab3eabac 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-20  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * lib/binutils-common.exp (regexp_diff): New procedure.
+       * lib/utils-lib.exp (regexp_diff): Delete.
+
 2010-11-20  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * lib/binutils-common.exp: New file.
index 96b19552f1a7b34dc11708533b6a24333fce16d8..2f8b42652824f3475688a4112f5a0a8ff3f3382b 100644 (file)
@@ -149,3 +149,157 @@ proc is_elf64 { binary_file } {
 
     return 0
 }
+
+# Compare two files line-by-line.  FILE_1 is the actual output and FILE_2
+# is the expected output.  Ignore blank lines in either file.
+#
+# FILE_2 is a series of regexps, comments and # directives.  The directives
+# are:
+#
+#    #pass
+#        Treat the test as a PASS if everything up till this point has
+#        matched.  Ignore any remaining lines in either FILE_1 or FILE_2.
+#
+#    #failif
+#        Reverse the sense of the test: expect differences to exist.
+#
+#    #...
+#    REGEXP
+#        Skip all lines in FILE_1 until the first that matches REGEXP.
+#
+# Other # lines are comments.  Skip empty lines in both files.
+#
+# The first optional argument is a list of regexp substitutions of the form:
+#
+#    EXP1 SUBSPEC1 EXP2 SUBSPEC2 ...
+#
+# This tells the function to apply each regexp substitution EXPi->SUBSPECi
+# in order to every line of FILE_2.
+#
+# Return nonzero if differences exist.
+proc regexp_diff { file_1 file_2 args } {
+    set eof -1
+    set end_1 0
+    set end_2 0
+    set differences 0
+    set diff_pass 0
+    set fail_if_match 0
+    set ref_subst ""
+    if { [llength $args] > 0 } {
+       set ref_subst [lindex $args 0]
+    }
+    if { [llength $args] > 1 } {
+       perror "Too many arguments to regexp_diff"
+       return 1
+    }
+
+    if [file exists $file_1] then {
+       set file_a [open $file_1 r]
+    } else {
+       perror "$file_1 doesn't exist"
+       return 1
+    }
+
+    if [file exists $file_2] then {
+       set file_b [open $file_2 r]
+    } else {
+       perror "$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 } {
+           # Ignore blank line in FILE_1.
+           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 "#failif" $line_b] } {
+               send_log "fail if no difference\n"
+               verbose "fail if no difference" 3
+               set fail_if_match 1
+           } elseif { [string match "#..." $line_b] } {
+               if { [gets $file_b line_b] == $eof } {
+                   set end_2 1
+                   set diff_pass 1
+                   break
+               }
+               # Substitute on the reference.
+               foreach {name value} $ref_subst {
+                   regsub -- $name $line_b $value line_b
+               }
+               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 {
+           # Substitute on the reference.
+           foreach {name value} $ref_subst {
+               regsub -- $name $line_b $value line_b
+           }
+           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"
+               verbose "regexp_diff match failure\n" 3
+               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
+    }
+
+    if { $fail_if_match } {
+       if { $differences == 0 } {
+           set differences 1
+       } else {
+           set differences 0
+       }
+    }
+
+    close $file_a
+    close $file_b
+
+    return $differences
+}
index 6dbbecf310d466f1f3c17d051f6b9e6617693cca..72e368cbb393d08779a450b054ec4833d5b67e95 100644 (file)
@@ -242,8 +242,8 @@ proc exe_ext {} {
 #
 # After the option lines come regexp lines.  `run_dump_test' calls
 # `regexp_diff' to compare the output of the dumping tool against the
-# regexps in FILE.d.  `regexp_diff' is defined later in this file; see
-# further comments there.
+# regexps in FILE.d.  `regexp_diff' is defined in binutils-common.exp;
+# see further comments there.
 
 proc run_dump_test { name {extra_options {}} } {
     global subdir srcdir
@@ -538,110 +538,6 @@ proc slurp_options { file } {
     return $opt_array
 }
 
-# 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 {
-       perror "$file_1 doesn't exist"
-       return 1
-    }
-
-    if [file exists $file_2] then {
-       set file_b [open $file_2 r]
-    } else {
-       perror "$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
-                   set diff_pass 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"
-               verbose "regexp_diff match failure\n" 3
-               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
-}
-
 proc file_contents { filename } {
     set file [open $filename r]
     set contents [read $file]
index d1583856ba036a85e4f8da6ffa85269e72243ac5..90b3bfce6e3566dae233e1a35a95681d1217ce57 100644 (file)
@@ -1,3 +1,16 @@
+2010-11-20  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * lib/gas-defs.exp (regexp_diff): Delete.
+       (run_dump_test): Remove final "" argument in call to regexp_diff.
+       (run_list_test): Likewise.
+       (run_list_test_stdin): Likewise.
+       * gas/all/gas.exp (test_cond): Likewise.
+       * gas/elf/elf.exp (run_elf_list_test): Likewise.
+       * gas/m68k/all.exp: Likewise.
+       * gas/mep/complex-relocs.exp (regexp_test): Likewise.
+       * gas/mt/relocs.exp (regexp_test): Likewise.
+       * gas/symver/symver.exp (run_error_test): Likewise.
+
 2010-11-20  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * lib/gas-defs.exp (load_common_lib): New function.  Load
index 1dd7cbb025b1c77d631f738a7ed1e8697589ed2f..c41db983c12c0fe950a6d7d2b27ef6dadae3cde5 100644 (file)
@@ -308,7 +308,7 @@ proc test_cond {} {
        send_log "$comp_output\n"
        fail $testname
     } else {
-       if { [regexp_diff dump.out $srcdir/$subdir/cond.l ""] } {
+       if { [regexp_diff dump.out $srcdir/$subdir/cond.l] } {
            fail $testname
        } else {
            pass $testname
index 1aebf8af69c2a2ac11428236c3d48b6e969214d9..3babe0b1cb4948f8d7cca1b66027c2c60c5e0a60 100644 (file)
@@ -9,7 +9,7 @@ proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } {
     set file $srcdir/$subdir/$name
     gas_run ${name}.s "$opts -o dump.o" ">&dump.out"
     if { ![string match "" $opts]
-         && [regexp_diff "dump.out" "${file}.l" ""] } then {
+         && [regexp_diff "dump.out" "${file}.l"] } then {
        fail $testname
        verbose "output is [file_contents "dump.out"]" 2
        return
@@ -28,7 +28,7 @@ proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } {
        return
     }
     verbose_eval {[file_contents "dump.out"]} 3
-    if { [regexp_diff "dump.out" "${file}.e${suffix}" ""] } then {
+    if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then {
        fail $testname
        verbose "output is [file_contents "dump.out"]" 2
        return
index 443fdb62b4262f27f0a4dfe42e5487d688b5d0c8..f4bdfa7745990e67329b5f0d4d08a836954ce9cc 100644 (file)
@@ -83,7 +83,7 @@ if { [istarget m68*-*-*] || [istarget fido*-*-*] } then {
        verbose "$comp_output" 3
        fail $testname
     } else {
-       if [regexp_diff "err.out" "$srcdir/$subdir/op68000.d" ""] then {
+       if [regexp_diff "err.out" "$srcdir/$subdir/op68000.d"] then {
            fail $testname
        } else {
            pass $testname
index a5a3127fb1f50913dd955c842da72a0bfd69bbda..83d89bb6375d8352bf35b108f517239c0aec2708 100644 (file)
@@ -18,7 +18,7 @@ proc objdump_test { exec flags dest test } {
 }
 
 proc regexp_test { file1 file2 test } {
-    if [regexp_diff $file1 $file2 ""] then { fail $test } else { pass $test }
+    if [regexp_diff $file1 $file2] then { fail $test } else { pass $test }
 }
 
 
index d47742ebf32e2eb7855591898b8e8789f3b56338..076f428bc73b30d8182543fbf72a201a790fc5e7 100644 (file)
@@ -15,7 +15,7 @@ proc objdump_test { exec flags dest test } {
 }
 
 proc regexp_test { file1 file2 test } {
-    if [regexp_diff $file1 $file2 ""] then { fail $test } else { pass $test }
+    if [regexp_diff $file1 $file2] then { fail $test } else { pass $test }
 }
 
 
index b4caae97a43bddb39b96411dc3be7758ac7f20f4..6fcae0edab206fc8aa60f3ef9ee77cdcd402b847 100644 (file)
@@ -6,7 +6,7 @@ proc run_error_test { name opts } {
     set testname "symver $name"
     set file $srcdir/$subdir/$name
     gas_run ${name}.s $opts ">&dump.out"
-    if { [regexp_diff "dump.out" "${file}.l" ""] } then {
+    if { [regexp_diff "dump.out" "${file}.l"] } then {
        fail $testname
        verbose "output is [file_contents "dump.out"]" 2
        return
index cacfb50ae3b13170366af81816437d00a98e6b97..f10d72adce7d9653845eb32354decbc4c29fa95a 100644 (file)
@@ -427,8 +427,8 @@ proc run_dump_tests { testcases {extra_options {}} } {
 #
 # After the option lines come regexp lines.  `run_dump_test' calls
 # `regexp_diff' to compare the output of the dumping tool against the
-# regexps in FILE.d.  `regexp_diff' is defined later in this file; see
-# further comments there.
+# regexps in FILE.d.  `regexp_diff' is defined in binutils-common.exp;
+# see further comments there.
 
 proc run_dump_test { name {extra_options {}} } {
     global subdir srcdir
@@ -679,7 +679,7 @@ proc run_dump_test { name {extra_options {}} } {
            }
            set stderrfile $srcdir/$subdir/$opts(stderr)
            verbose "wrote pruned stderr to dump.stderr" 3
-           if { [regexp_diff "dump.stderr" "$stderrfile" ""] } then {
+           if { [regexp_diff "dump.stderr" "$stderrfile"] } then {
                if { $opts(error) != "" } {
                    verbose -log "$exitstat with: <$comp_output>, expected: <$opts(error)>"
                    if [regexp $opts(error) $comp_output] {
@@ -839,120 +839,6 @@ expect_after -i {
     eof                                { perror "eof" }
 }
 
-# regexp_diff, based on simple_diff taken from ld test suite.
-#      Compares two files line-by-line.
-#      FILE_1 contains strings, FILE_2 contains regexps and #-comments
-#      Blank lines are ignored in either file.
-#      Subsitutions in REF_SUBST are applied on FILE_2 lines.
-#      Returns non-zero if differences exist.
-#
-proc regexp_diff { file_1 file_2 ref_subst} {
-
-    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 {
-       perror "$file_1 doesn't exist"
-       return 1
-    }
-
-    if [file exists $file_2] then {
-       set file_b [open $file_2 r]
-    } else {
-       perror "$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 } {
-            # Ignore blank line in FILE_1.
-           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
-                   set diff_pass 1
-                   break
-               }
-                # Substitute on the reference.
-                foreach {name value} $ref_subst {
-                    regsub -- $name $line_b $value line_b
-                }
-               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 {
-            # Substitute on the reference.
-            foreach {name value} $ref_subst {
-                regsub -- $name $line_b $value line_b
-            }
-            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"
-               verbose "regexp_diff match failure\n" 3
-               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
-}
-
 proc file_contents { filename } {
     set file [open $filename r]
     set contents [read $file]
@@ -1008,7 +894,7 @@ proc run_list_test { name {opts {}} {testname {}} } {
     }
     set file $srcdir/$subdir/$name
     gas_run ${name}.s $opts ">&dump.out"
-    if { [regexp_diff "dump.out" "${file}.l" ""] } then {
+    if { [regexp_diff "dump.out" "${file}.l"] } then {
        fail $testname
        verbose "output is [file_contents "dump.out"]" 2
        return
@@ -1027,7 +913,7 @@ proc run_list_test_stdin { name {opts {}} {testname {}} } {
     }
     set file $srcdir/$subdir/$name
     gas_run_stdin ${name}.s $opts ">&dump.out"
-    if { [regexp_diff "dump.out" "${file}.l" ""] } then {
+    if { [regexp_diff "dump.out" "${file}.l"] } then {
        fail $testname
        verbose "output is [file_contents "dump.out"]" 2
        return
index 30d1a1a3a475667a0c9f2ce65a39989c0035f4a7..d1fc0c44b9dab5dc15ce465a247da23833c0dc0e 100644 (file)
@@ -1,3 +1,7 @@
+2010-11-20  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * lib/ld-lib.exp (regexp_diff, simple_diff): Delete.
+
 2010-11-20  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * lib/ld-lib.exp (load_common_lib): New function.  Load
index c1e141a2b414e58805966c453e45c5b193fd673a..48e9635d03f337741769f35c66a1e654e2e0ff1a 100644 (file)
@@ -408,75 +408,6 @@ proc ld_simple_link_defsyms {} {
     return $flags
 }
 
-# Compares two files line-by-line.
-#   Returns differences if exist.
-#   Returns null if file(s) cannot be opened.
-#
-proc simple_diff { file_1 file_2 } {
-    global target
-
-    set eof -1
-    set differences 0
-
-    if [file exists $file_1] then {
-       set file_a [open $file_1 r]
-    } else {
-       warning "$file_1 doesn't exist"
-       return
-    }
-
-    if [file exists $file_2] then {
-       set file_b [open $file_2 r]
-    } else {
-       fail "$file_2 doesn't exist"
-       return
-    }
-
-    verbose "# Diff'ing: $file_1 $file_2\n" 2
-
-    while { [gets $file_a line] != $eof } {
-       if [regexp "^#.*$" $line] then {
-           continue
-       } else {
-           lappend list_a $line
-       }
-    }
-    close $file_a
-
-    while { [gets $file_b line] != $eof } {
-       if [regexp "^#.*$" $line] then {
-           continue
-       } else {
-           lappend list_b $line
-       }
-    }
-    close $file_b
-
-    for { set i 0 } { $i < [llength $list_a] } { incr i } {
-       set line_a [lindex $list_a $i]
-       set line_b [lindex $list_b $i]
-
-       verbose "\t$file_1: $i: $line_a\n" 3
-       verbose "\t$file_2: $i: $line_b\n" 3
-       if [string compare $line_a $line_b] then {
-           verbose -log "\t$file_1: $i: $line_a\n"
-           verbose -log "\t$file_2: $i: $line_b\n"
-
-           fail "Test: $target"
-           return
-       }
-    }
-
-    if { [llength $list_a] != [llength $list_b] } {
-       fail "Test: $target"
-       return
-    }
-
-    if $differences<1 then {
-       pass "Test: $target"
-    }
-}
-
 # run_dump_test FILE
 # Copied from gas testsuite, tweaked and further extended.
 #
@@ -577,8 +508,8 @@ proc simple_diff { file_1 file_2 } {
 #
 # After the option lines come regexp lines.  `run_dump_test' calls
 # `regexp_diff' to compare the output of the dumping tool against the
-# regexps in FILE.d.  `regexp_diff' is defined later in this file; see
-# further comments there.
+# regexps in FILE.d.  `regexp_diff' is defined in binutils-common.exp;
+# see further comments there.
 #
 proc run_dump_test { name } {
     global subdir srcdir
@@ -943,123 +874,6 @@ proc slurp_options { file } {
     return $opt_array
 }
 
-# regexp_diff, copied from gas, based on simple_diff above.
-#      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
-    set fail_if_match 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 "#failif" $line_b ] {
-               send_log "fail if no difference\n"
-               verbose "fail if no difference" 3
-               set fail_if_match 1
-           } elseif [ string match "#..." $line_b ] {
-               if { [gets $file_b line_b] == $eof } {
-                   set end_2 1
-                   set diff_pass 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"] {
-               verbose "regexp_diff match failure\n" 3
-               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
-    }
-
-    if { $fail_if_match } {
-       if { $differences == 0 } {
-           set differences 1
-       } else {
-           set differences 0
-       }
-    }
-
-    close $file_a
-    close $file_b
-
-    return $differences
-}
-
 proc file_contents { filename } {
     set file [open $filename r]
     set contents [read $file]