Skip to content

Commit 411d7f4

Browse files
Merge pull request #4 from andrewdavidmackenzie/fix_warnings
Fix warnings and re-enable tests that crashed previously
2 parents f558686 + c0f063c commit 411d7f4

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/libproc/kmesg_buffer.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ extern crate errno;
33

44
use self::libc::{uint32_t, c_int};
55

6-
use std::{ptr, mem, env, io};
7-
use std::io::Write;
6+
use std::{ptr, mem, env};
87
use std::fmt;
98

109
use libproc::proc_pid;
1110

11+
#[cfg(test)]
12+
use std::io;
13+
#[cfg(test)]
14+
use std::io::Write;
15+
1216
// See https://opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/sys/msgbuf.h
1317
const MAX_MSG_BSIZE : c_int = (1*1024*1024);
1418
const MSG_MAGIC : c_int = 0x063061;
@@ -162,4 +166,4 @@ fn kmessagebuffer_test() {
162166
} else {
163167
writeln!(&mut io::stdout(), "test libproc::kmesg_buffer::kmessagebuffer_test ... skipped as it needs to be run as root").unwrap();
164168
}
165-
}
169+
}

src/libproc/proc_pid.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,7 @@ pub fn regionfilename(pid: i32, address: u64) -> Result<String, String> {
268268
}
269269
}
270270

271-
//#[test]
272-
// TODO periodically this test causes a Segfault with this message - about 1 in 10 times!!!
273-
// error: Process didn't exit successfully: `/Users/andrew/workspace/libproc-rs/target/debug/libproc-503ad0ba07eb6318` (signal: 11, SIGSEGV: invalid memory reference)
271+
#[test]
274272
// This checks that it can find the regionfilename of the region at address 0, of the init process with PID 1
275273
fn regionfilename_test() {
276274
match regionfilename(1, 0) {
@@ -314,10 +312,8 @@ fn pidpath_test_init_pid() {
314312
}
315313
}
316314

317-
//#[test]
318-
//#[should_panic]
319-
// TODO periodically this test causes a Segfault with this message - about 1 in 10 times!!!
320-
// error: Process didn't exit successfully: `/Users/andrew/workspace/libproc-rs/target/debug/libproc-503ad0ba07eb6318` (signal: 11, SIGSEGV: invalid memory reference)
315+
#[test]
316+
#[should_panic]
321317
// This checks that it cannot find the path of the process with pid -1
322318
fn pidpath_test_unknown_pid() {
323319
match pidpath(-1) {
@@ -405,8 +401,7 @@ pub fn name(pid: i32) -> Result<String, String> {
405401
}
406402
}
407403

408-
// #[test]
409-
// TODO periodically this test causes a Segfault with this message - about 1 in 10 times!!!
404+
#[test]
410405
// error: Process didn't exit successfully: `/Users/andrew/workspace/libproc-rs/target/debug/libproc-503ad0ba07eb6318` (signal: 11, SIGSEGV: invalid memory reference)
411406
// This checks that it can find the name of the init process with PID 1
412407
fn name_test_init_pid() {

0 commit comments

Comments
 (0)