@@ -269,9 +269,13 @@ pub fn pidinfo<T: PIDInfo>(_pid: i32, _arg: u64) -> Result<T, String> {
269269/// use libproc::libproc::proc_pid::regionfilename;
270270///
271271/// // This checks that it can find the regionfilename of the region at address 0, of the init process with PID 1
272- /// match regionfilename(1, 0) {
273- /// Ok(regionfilename) => println!("Region Filename (at address = 0) of init process PID = 1 is '{}'", regionfilename),
274- /// Err(message) => assert!(true, message)
272+ /// use libproc::libproc::proc_pid::am_root;
273+ ///
274+ /// if am_root() {
275+ /// match regionfilename(1, 0) {
276+ /// Ok(regionfilename) => println!("Region Filename (at address = 0) of init process PID = 1 is '{}'", regionfilename),
277+ /// Err(message) => panic!(message)
278+ /// }
275279/// }
276280/// ```
277281#[ cfg( target_os = "macos" ) ]
@@ -612,10 +616,7 @@ mod test {
612616 #[ test]
613617 #[ cfg( target_os = "macos" ) ]
614618 fn libversion_test ( ) {
615- match libversion ( ) {
616- Ok ( ( major, minor) ) => println ! ( "Major = {}, Minor = {}" , major, minor) ,
617- Err ( message) => panic ! ( message)
618- }
619+ libversion ( ) . unwrap ( ) ;
619620 }
620621
621622 #[ test]
@@ -644,7 +645,7 @@ mod test {
644645 Err ( err) => assert ! ( false , "Error retrieving process name: {}" , err)
645646 }
646647 } else {
647- println ! ( "Cannot run name_test on macos unless run as root" ) ;
648+ println ! ( "Cannot run ' name_test' on macos unless run as root" ) ;
648649 }
649650 }
650651
0 commit comments