# assembly source, and a .d file containing the expected output from
# objdump or nm or whatever, and leading comments indicating any options
# to be passed to the assembler or dump program.
+
proc run_dump_test { name } {
global subdir srcdir
global OBJDUMP NM AS
global OBJDUMPFLAGS NMFLAGS ASFLAGS
- set file "$srcdir/$subdir/$name"
+ if [string match "*/*" $name] {
+ set file $name
+ set name [file tail $name]
+ } else {
+ set file "$srcdir/$subdir/$name"
+ }
set opt_array [slurp_options "${file}.d"]
+ if { $opt_array == -1 } {
+ unresolved $subdir/$name
+ return
+ }
set opts(as) {}
set opts(objdump) {}
set opts(nm) {}
set opt_val [lindex $i 1]
if ![info exists opts($opt_name)] {
perror "unknown option $opt_name in file $file.d"
+ unresolved $subdir/$name
return
}
if [string length $opts($opt_name)] {
perror "option $opt_name multiply set in $file.d"
+ unresolved $subdir/$name
return
}
set opts($opt_name) $opt_val
{ set program nm }
default
{ perror "unrecognized program option $opts(PROG) in $file.d"
+ unresolved $subdir/$name
return }
}
} elseif {$opts(objdump) == "" && $opts(nm) != ""} {
set program objdump
} else {
perror "dump program unspecified in $file.d"
+ unresolved $subdir/$name
return
}
set progopts1 $opts($program)
eval set progopts \$[string toupper $program]FLAGS
eval set program \$[string toupper $program]
- if { $opts(name) == "" } { set testname "$subdir/$name" } else { set testname $opts(name) }
+ if { $opts(name) == "" } {
+ set testname "$subdir/$name"
+ } else {
+ set testname $opts(name)
+ }
if { $opts(source) == "" } {
set sourcefile ${file}.s
}
if { $progopts1 == "" } { set $progopts1 "-r" }
+ verbose "running $program $progopts $progopts1" 3
if [catch "exec $program $progopts $progopts1 > dump.out" comp_output] {
fail_phase $testname {running objdump} "$progopts $progopts1"
return
}
+ verbose_eval {[file_contents "dump.out"]} 3
if { [regexp_diff "dump.out" "${file}.d"] } then {
fail_phase $testname {checking output} "$ASFLAGS $opts(as)"
return
proc slurp_options { file } {
if [catch { set f [open $file r] } x] {
- perror "couldn't open `$file': $x"
+ #perror "couldn't open `$file': $x"
+ perror "$x"
+ return -1
}
set opt_array {}
# whitespace expression
return $differences
}
+
+proc file_contents { filename } {
+ set file [open $filename r]
+ set contents [read $file]
+ close $file
+ return $contents
+}
+
+proc verbose_eval { expr { level 1 } } {
+ global verbose
+ if $verbose>$level then { eval verbose "$expr" $level }
+}