@@ -11,7 +11,6 @@ use std::{fs, path::PathBuf};
1111
1212use  anyhow:: Context ; 
1313use  bin_tests:: { build_artifacts,  ArtifactType ,  ArtifactsBuild ,  BuildProfile } ; 
14- use  datadog_profiling:: exporter; 
1514use  serde_json:: Value ; 
1615
1716#[ test]  
@@ -71,9 +70,24 @@ fn test_crash_tracking_bin_fork() {
7170#[ test]  
7271#[ cfg_attr( miri,  ignore) ]  
7372fn  test_crash_tracking_bin_abort ( )  { 
73+     // For now, do the base test (donthing).  For future we should probably also test chaining. 
7474    test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "abort" ) ; 
7575} 
7676
77+ #[ test]  
78+ #[ cfg_attr( miri,  ignore) ]  
79+ fn  test_crash_tracking_bin_sigill ( )  { 
80+     // For now, do the base test (donthing).  For future we should probably also test chaining. 
81+     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "sigill" ) ; 
82+ } 
83+ 
84+ // #[test] 
85+ // #[cfg_attr(miri, ignore)] 
86+ // fn test_crash_tracking_bin_sigbus() { 
87+ //     // For now, do the base test (donthing).  For future we should probably also test chaining. 
88+ //     test_crash_tracking_bin(BuildProfile::Release, "donothing", "sigbus"); 
89+ // } 
90+ 
7791fn  test_crash_tracking_bin ( 
7892    crash_tracking_receiver_profile :  BuildProfile , 
7993    mode :  & str , 
@@ -156,38 +170,36 @@ fn test_crash_tracking_bin(
156170
157171fn  assert_siginfo_message ( sig_info :  & Value ,  crash_typ :  & str )  { 
158172    match  crash_typ { 
159-         "abort"  => assert_eq ! ( 
160-             * sig_info, 
161-             serde_json:: json!( { 
162-                 "si_code" :  0 , 
163-                 "si_code_human_readable" :  "UNKNOWN" , 
164-                 "si_signo" :  6 , 
165-                 "si_signo_human_readable" :  "SIGABRT" , 
166-             } ) 
167-         ) , 
173+         "abort"  => { 
174+             assert_eq ! ( sig_info[ "si_code" ] ,  0 ) ; 
175+             assert_eq ! ( sig_info[ "si_code_human_readable" ] ,  "UNKNOWN" ) ; 
176+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGABRT ) ; 
177+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGABRT" ) ; 
178+         } 
179+         "sigbus"  => { 
180+             assert_eq ! ( sig_info[ "si_code" ] ,  2 ) ; 
181+             assert_eq ! ( sig_info[ "si_code_human_readable" ] ,  "UNKNOWN" ) ; 
182+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGBUS ) ; 
183+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGBUS" ) ; 
184+         } 
185+         "sigill"  => { 
186+             assert_eq ! ( sig_info[ "si_code" ] ,  2 ) ; 
187+             assert_eq ! ( sig_info[ "si_code_human_readable" ] ,  "UNKNOWN" ) ; 
188+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGILL ) ; 
189+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGILL" ) ; 
190+         } 
168191        "null_deref"  =>
169192        // On every platform other than OSX ARM, the si_code is 1: SEGV_MAPERR 
170193        // On OSX ARM, its 2: SEGV_ACCERR 
171194        { 
195+             assert_eq ! ( sig_info[ "si_addr" ] ,  "0x0000000000000000" ) ; 
172196            assert ! ( 
173-                 * sig_info
174-                     == serde_json:: json!( { 
175-                         "si_addr" :  "0x0000000000000000" , 
176-                         "si_code" :  0 , 
177-                         "si_code_human_readable" :  "UNKNOWN" , 
178-                         "si_signo" :  11 , 
179-                         "si_signo_human_readable" :  "SIGSEGV" , 
180-                     } ) 
181-                     || * sig_info
182-                         == serde_json:: json!( { 
183-                             "si_addr" :  "0x0000000000000000" , 
184-                             "si_code" :  2 , 
185-                             "si_code_human_readable" :  "UNKNOWN" , 
186-                             "si_signo" :  11 , 
187-                             "si_signo_human_readable" :  "SIGSEGV" , 
188-                         } ) , 
189-                 "Unexpected sig_info: {sig_info}" 
190-             ) 
197+                 sig_info[ "si_code" ]  == 2  || sig_info[ "si_code" ]  == 1 , 
198+                 "{sig_info:?}" 
199+             ) ; 
200+             assert_eq ! ( sig_info[ "si_code_human_readable" ] ,  "UNKNOWN" ) ; 
201+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGSEGV ) ; 
202+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGSEGV" ) ; 
191203        } 
192204        _ => panic ! ( "unexpected crash_typ {crash_typ}" ) , 
193205    } 
@@ -231,33 +243,36 @@ fn assert_telemetry_message(crash_telemetry: &[u8], crash_typ: &str) {
231243
232244    match  crash_typ { 
233245        "abort"  => { 
234-             let  mut  expected_tags = base_expected_tags. clone ( ) ; 
235-             expected_tags. extend ( [ 
236-                 "si_code_human_readable:UNKNOWN" , 
237-                 "si_code:0" , 
238-                 "si_signo_human_readable:SIGABRT" , 
239-                 "si_signo:6" , 
240-             ] ) ; 
241-             assert_eq ! ( expected_tags,  tags) ; 
246+             assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
247+             assert ! ( tags. contains( "si_code_human_readable:UNKNOWN" ) ,  "{tags:?}" ) ; 
248+             assert ! ( tags. contains( "si_code:0" ) ,  "{tags:?}" ) ; 
249+             assert ! ( tags. contains( "si_signo_human_readable:SIGABRT" ) ,  "{tags:?}" ) ; 
250+             assert ! ( tags. contains( "si_signo:6" ) ,  "{tags:?}" ) ; 
251+         } 
252+         "sigbus"  => { 
253+             assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
254+             assert ! ( tags. contains( "si_code_human_readable:UNKNOWN" ) ,  "{tags:?}" ) ; 
255+             assert ! ( tags. contains( "si_code:2" ) ,  "{tags:?}" ) ; 
256+             assert ! ( tags. contains( "si_signo_human_readable:SIGILL" ) ,  "{tags:?}" ) ; 
257+             assert ! ( tags. contains( "si_signo:4" ) ,  "{tags:?}" ) ; 
258+         } 
259+         "sigill"  => { 
260+             assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
261+             assert ! ( tags. contains( "si_code_human_readable:UNKNOWN" ) ,  "{tags:?}" ) ; 
262+             assert ! ( tags. contains( "si_code:2" ) ,  "{tags:?}" ) ; 
263+             assert ! ( tags. contains( "si_signo_human_readable:SIGILL" ) ,  "{tags:?}" ) ; 
264+             assert ! ( tags. contains( "si_signo:4" ) ,  "{tags:?}" ) ; 
242265        } 
243266        "null_deref"  => { 
244-             let  mut  expected_tags1 = base_expected_tags. clone ( ) ; 
245-             expected_tags1. extend ( [ 
246-                 "si_addr:0x0000000000000000" , 
247-                 "si_code_human_readable:UNKNOWN" , 
248-                 "si_code:1" , 
249-                 "si_signo_human_readable:SIGSEGV" , 
250-                 "si_signo:11" , 
251-             ] ) ; 
252-             let  mut  expected_tags2 = base_expected_tags. clone ( ) ; 
253-             expected_tags2. extend ( [ 
254-                 "si_addr:0x0000000000000000" , 
255-                 "si_code_human_readable:UNKNOWN" , 
256-                 "si_code:2" , 
257-                 "si_signo_human_readable:SIGSEGV" , 
258-                 "si_signo:11" , 
259-             ] ) ; 
260-             assert ! ( expected_tags1 == tags || expected_tags2 == tags,  "{tags:?}" ) ; 
267+             assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
268+             assert ! ( tags. contains( "si_addr:0x0000000000000000" ) ,  "{tags:?}" ) ; 
269+             assert ! ( tags. contains( "si_code_human_readable:UNKNOWN" ) ,  "{tags:?}" ) ; 
270+             assert ! ( tags. contains( "si_signo_human_readable:SIGSEGV" ) ,  "{tags:?}" ) ; 
271+             assert ! ( tags. contains( "si_signo:11" ) ,  "{tags:?}" ) ; 
272+             assert ! ( 
273+                 tags. contains( "si_code:1" )  || tags. contains( "si_code:2" ) , 
274+                 "{tags:?}" 
275+             ) ; 
261276        } 
262277        _ => panic ! ( "{crash_typ}" ) , 
263278    } 
0 commit comments