7
7
//@ needs-profiler-support
8
8
//@ ignore-cross-compile
9
9
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
+ } ;
11
13
12
14
fn main ( ) {
13
15
rustc ( ) . profile_generate ( "profdata" ) . opt ( ) . input ( "foo.rs" ) . output ( "foo" ) . run ( ) ;
14
16
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 ( ) ;
20
24
rustc ( )
21
25
. profile_use ( "merged.profdata" )
22
26
. opt ( )
@@ -25,5 +29,13 @@ fn main() {
25
29
. arg ( "-Zremark-dir=profiles" )
26
30
. run ( ) ;
27
31
// 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
+ }
29
41
}
0 commit comments