suffix @var{suffix}.
@end table
+The @var{suffix} argument which describes the dump file to be scanned
+may contain a glob pattern that must expand to exactly one file
+name. This is useful if, e.g., different pass instances are executed
+depending on torture testing command-line flags, producing dump files
+whose names differ only in their pass instance number suffix. For
+example, to scan instances 1, 2, 3 of a tree pass ``mypass'' for
+occurrences of the string ``code has been optimized'', use:
+@smallexample
+/* @{ dg-options "-fdump-tree-mypass" @} */
+/* @{ dg-final @{ scan-tree-dump "code has been optimized" "mypass\[1-3\]" @} @} */
+@end smallexample
+
+
@subsubsection Check for output files
@table @code
return $dumpbase
}
+# Expand dump file name pattern to exactly one file.
+# Return a single dump file name or an empty string
+# if the pattern matches no file or more than one file.
+#
+# Argument 0 is the testcase name
+# Argument 1 is the dump file glob pattern
+proc glob-dump-file { args } {
+
+ set pattern [lindex $args 1]
+ set dump_file "[glob -nocomplain $pattern]"
+ set num_files [llength $dump_file]
+
+ if { $num_files != 1 } {
+ set testcase [lindex $args 0]
+ if { $num_files == 0 } {
+ verbose -log "$testcase: dump file does not exist"
+ }
+
+ if { $num_files > 1 } {
+ verbose -log "$testcase: multiple dump files found"
+ }
+
+ return
+ }
+
+ return $dump_file
+}
+
# Utility for scanning compiler result, invoked via dg-final.
# Call pass if pattern is present, otherwise fail.
#
set testname "$testcase scan-[lindex $args 0]-dump $suf \"$printable_pattern\""
set src [file tail $filename]
set dumpbase [dump-base $src [lindex $args 3]]
- set output_file "[glob -nocomplain $dumpbase.[lindex $args 2]]"
+
+ set pattern "$dumpbase.[lindex $args 2]"
+ set output_file "[glob-dump-file $testcase $pattern]"
if { $output_file == "" } {
- verbose -log "$testcase: dump file does not exist"
- verbose -log "dump file: $dumpbase.$suf"
unresolved "$testname"
return
}
set testname "$testcase scan-[lindex $args 0]-dump-times $suf \"$printable_pattern\" [lindex $args 2]"
set src [file tail $filename]
set dumpbase [dump-base $src [lindex $args 4]]
- set output_file "[glob -nocomplain $dumpbase.[lindex $args 3]]"
+
+ set pattern "$dumpbase.[lindex $args 3]"
+ set output_file "[glob-dump-file $testcase $pattern]"
if { $output_file == "" } {
- verbose -log "$testcase: dump file does not exist"
unresolved "$testname"
return
}
set testname "$testcase scan-[lindex $args 0]-dump-not $suf \"$printable_pattern\""
set src [file tail $filename]
set dumpbase [dump-base $src [lindex $args 3]]
- set output_file "[glob -nocomplain $dumpbase.[lindex $args 2]]"
+
+ set pattern "$dumpbase.[lindex $args 2]"
+ set output_file "[glob-dump-file $testcase $pattern]"
if { $output_file == "" } {
- verbose -log "$testcase: dump file does not exist"
unresolved "$testname"
return
}
set testname "$testcase scan-[lindex $args 0]-dump-dem $suf \"$printable_pattern\""
set src [file tail $filename]
set dumpbase [dump-base $src [lindex $args 3]]
- set output_file "[glob -nocomplain $dumpbase.[lindex $args 2]]"
+
+ set pattern "$dumpbase.[lindex $args 2]"
+ set output_file "[glob-dump-file $testcase $pattern]"
if { $output_file == "" } {
- verbose -log "$testcase: dump file does not exist"
unresolved "$testname"
return
}
set testname "$testcase scan-[lindex $args 0]-dump-dem-not $suf \"$printable_pattern\""
set src [file tail $filename]
set dumpbase [dump-base $src [lindex $args 3]]
- set output_file "[glob -nocomplain $dumpbase.[lindex $args 2]]"
+
+ set pattern "$dumpbase.[lindex $args 2]"
+ set output_file "[glob-dump-file $testcase $pattern]"
if { $output_file == "" } {
- verbose -log "$testcase: dump file does not exist"
unresolved "$testname"
return
}