Skip to content

Commit c8ab4cb

Browse files
committed
Fix test_chdir when TMPDIR is a symlink
suppress some more unused variable warnings
1 parent fab0707 commit c8ab4cb

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

test/sys/test_wait.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use libc::exit;
66

77
#[test]
88
fn test_wait_signal() {
9+
#[allow(unused_variables)]
910
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
1011

1112
match fork() {
@@ -17,11 +18,11 @@ fn test_wait_signal() {
1718
// panic, fork should never fail unless there is a serious problem with the OS
1819
Err(_) => panic!("Error: Fork Failed")
1920
}
20-
drop(m); // Appease the unused_variable checker
2121
}
2222

2323
#[test]
2424
fn test_wait_exit() {
25+
#[allow(unused_variables)]
2526
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
2627

2728
match fork() {
@@ -32,5 +33,4 @@ fn test_wait_exit() {
3233
// panic, fork should never fail unless there is a serious problem with the OS
3334
Err(_) => panic!("Error: Fork Failed")
3435
}
35-
drop(m); // Appease the unused_variable checker
3636
}

test/test_unistd.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ fn test_fchdir() {
155155
// fchdir changes the process's cwd
156156
#[allow(unused_variables)]
157157
let m = ::CWD_MTX.lock().expect("Mutex got poisoned by another test");
158+
158159
let tmpdir = TempDir::new("test_fchdir").unwrap();
159160
let tmpdir_path = tmpdir.path().canonicalize().unwrap();
160161
let tmpdir_fd = File::open(&tmpdir_path).unwrap().into_raw_fd();
@@ -170,15 +171,17 @@ fn test_getcwd() {
170171
// chdir changes the process's cwd
171172
#[allow(unused_variables)]
172173
let m = ::CWD_MTX.lock().expect("Mutex got poisoned by another test");
173-
let tmp_dir = TempDir::new("test_getcwd").unwrap();
174-
assert!(chdir(tmp_dir.path()).is_ok());
175-
assert_eq!(getcwd().unwrap(), tmp_dir.path());
174+
175+
let tmpdir = TempDir::new("test_getcwd").unwrap();
176+
let tmpdir_path = tmpdir.path().canonicalize().unwrap();
177+
assert!(chdir(&tmpdir_path).is_ok());
178+
assert_eq!(getcwd().unwrap(), tmpdir_path);
176179

177180
// make path 500 chars longer so that buffer doubling in getcwd
178181
// kicks in. Note: One path cannot be longer than 255 bytes
179182
// (NAME_MAX) whole path cannot be longer than PATH_MAX (usually
180183
// 4096 on linux, 1024 on macos)
181-
let mut inner_tmp_dir = tmp_dir.path().to_path_buf();
184+
let mut inner_tmp_dir = tmpdir_path.to_path_buf();
182185
for _ in 0..5 {
183186
let newdir = iter::repeat("a").take(100).collect::<String>();
184187
inner_tmp_dir.push(newdir);

0 commit comments

Comments
 (0)