77//@ needs-profiler-support
88//@ ignore-cross-compile
99
10- use run_make_support:: { invalid_utf8_contains, llvm_profdata, run, rustc} ;
10+ use run_make_support:: {
11+ has_extension, has_prefix, invalid_utf8_contains, llvm_profdata, run, rustc, shallow_find_files,
12+ } ;
1113
1214fn main ( ) {
1315 rustc ( ) . profile_generate ( "profdata" ) . opt ( ) . input ( "foo.rs" ) . output ( "foo" ) . run ( ) ;
1416 run ( "foo" ) ;
15- llvm_profdata ( )
16- . merge ( )
17- . output ( "merged.profdata" )
18- . input ( "profdata/default_15907418011457399462_0.profraw" )
19- . run ( ) ;
17+ // The profdata filename is a long sequence of numbers, fetch it by prefix and extension
18+ // to keep the test working even if the filename changes.
19+ let profdata_files = shallow_find_files ( "profdata" , |path| {
20+ has_prefix ( path, "default" ) && has_extension ( path, "profraw" )
21+ } ) ;
22+ let profdata_file = profdata_files. get ( 0 ) . unwrap ( ) ;
23+ llvm_profdata ( ) . merge ( ) . output ( "merged.profdata" ) . input ( profdata_file) . run ( ) ;
2024 rustc ( )
2125 . profile_use ( "merged.profdata" )
2226 . opt ( )
@@ -25,5 +29,13 @@ fn main() {
2529 . arg ( "-Zremark-dir=profiles" )
2630 . run ( ) ;
2731 // Check that PGO hotness is included in the remark files
28- invalid_utf8_contains ( "profiles/foo.cba44757bc0621b9-cgu.0.opt.opt.yaml" , "Hotness" ) ;
32+ let remark_files = shallow_find_files ( "profiles" , |path| {
33+ has_prefix ( path, "foo" ) && has_extension ( path, "yaml" )
34+ } ) ;
35+ assert ! ( !remark_files. is_empty( ) ) ;
36+ for file in remark_files {
37+ if !file. to_str ( ) . unwrap ( ) . contains ( "codegen" ) {
38+ invalid_utf8_contains ( file, "Hotness" )
39+ } ;
40+ }
2941}
0 commit comments