Skip to content

Commit f3cb6b3

Browse files
committed
Fix building the tests for Redox and Illumos
Also, split the overbroad test_mknod_family into two tests
1 parent 28f547f commit f3cb6b3

File tree

4 files changed

+44
-36
lines changed

4 files changed

+44
-36
lines changed

test/test_fcntl.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ use std::io::prelude::*;
2828
#[cfg(not(target_os = "redox"))]
2929
use std::os::unix::fs;
3030

31-
use crate::*;
32-
3331
#[test]
3432
#[cfg(not(target_os = "redox"))]
3533
fn test_openat() {

test/test_stat.rs

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use std::path::Path;
1111

1212
#[cfg(not(any(target_os = "netbsd", target_os = "redox")))]
1313
use libc::{S_IFMT, S_IFLNK};
14-
#[cfg(not(target_os = "redox"))]
1514
use libc::mode_t;
1615

1716
#[cfg(not(target_os = "redox"))]
@@ -312,39 +311,47 @@ fn test_mkdirat_fail() {
312311
target_os = "ios",
313312
target_os = "macos",
314313
target_os = "redox")))]
315-
fn test_mknod_family() {
314+
fn test_mknod() {
315+
use stat::{lstat, mknod, SFlag};
316+
317+
let file_name = "test_file";
318+
let tempdir = tempfile::tempdir().unwrap();
319+
let target = tempdir.path().join(file_name);
320+
mknod(&target, SFlag::S_IFREG, Mode::S_IRWXU, 0).unwrap();
321+
let mode = lstat(&target).unwrap().st_mode as mode_t;
322+
assert!(mode & libc::S_IFREG == libc::S_IFREG);
323+
assert!(mode & libc::S_IRWXU == libc::S_IRWXU);
324+
}
325+
326+
#[test]
327+
#[cfg(not(any(target_os = "freebsd",
328+
target_os = "illumos",
329+
target_os = "ios",
330+
target_os = "macos",
331+
target_os = "redox")))]
332+
fn test_mknodat() {
316333
use fcntl::{AtFlags, OFlag};
317334
use nix::dir::Dir;
318-
use stat::{fstatat, lstat, mknod, mknodat, SFlag};
335+
use stat::{fstatat, mknodat, SFlag};
319336

320337
let file_name = "test_file";
321-
{
322-
let tempdir = tempfile::tempdir().unwrap();
323-
let target = tempdir.path().join(file_name);
324-
mknod(&target, SFlag::S_IFREG, Mode::S_IRWXU, 0).unwrap();
325-
let mode = lstat(&target).unwrap().st_mode as mode_t;
326-
assert!(mode & libc::S_IFREG == libc::S_IFREG);
327-
assert!(mode & libc::S_IRWXU == libc::S_IRWXU);
328-
}
329-
{
330-
let tempdir = tempfile::tempdir().unwrap();
331-
let target_dir = Dir::open(tempdir.path(), OFlag::O_DIRECTORY, Mode::S_IRWXU).unwrap();
332-
mknodat(
333-
target_dir.as_raw_fd(),
334-
file_name,
335-
SFlag::S_IFREG,
336-
Mode::S_IRWXU,
337-
0,
338-
)
339-
.unwrap();
340-
let mode = fstatat(
341-
target_dir.as_raw_fd(),
342-
file_name,
343-
AtFlags::AT_SYMLINK_NOFOLLOW,
344-
)
345-
.unwrap()
346-
.st_mode as mode_t;
347-
assert!(mode & libc::S_IFREG == libc::S_IFREG);
348-
assert!(mode & libc::S_IRWXU == libc::S_IRWXU);
349-
}
338+
let tempdir = tempfile::tempdir().unwrap();
339+
let target_dir = Dir::open(tempdir.path(), OFlag::O_DIRECTORY, Mode::S_IRWXU).unwrap();
340+
mknodat(
341+
target_dir.as_raw_fd(),
342+
file_name,
343+
SFlag::S_IFREG,
344+
Mode::S_IRWXU,
345+
0,
346+
)
347+
.unwrap();
348+
let mode = fstatat(
349+
target_dir.as_raw_fd(),
350+
file_name,
351+
AtFlags::AT_SYMLINK_NOFOLLOW,
352+
)
353+
.unwrap()
354+
.st_mode as mode_t;
355+
assert!(mode & libc::S_IFREG == libc::S_IFREG);
356+
assert!(mode & libc::S_IRWXU == libc::S_IRWXU);
350357
}

test/test_time.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
target_os = "emscripten",
77
))]
88
use nix::time::clock_getcpuclockid;
9-
use nix::time::{clock_getres, clock_gettime, ClockId};
9+
use nix::time::{clock_gettime, ClockId};
1010

11+
#[cfg(not(target_os = "redox"))]
1112
#[test]
1213
pub fn test_clock_getres() {
13-
assert!(clock_getres(ClockId::CLOCK_REALTIME).is_ok());
14+
assert!(nix::time::clock_getres(ClockId::CLOCK_REALTIME).is_ok());
1415
}
1516

1617
#[test]
@@ -31,6 +32,7 @@ pub fn test_clock_getcpuclockid() {
3132
assert!(clock_gettime(clock_id).is_ok());
3233
}
3334

35+
#[cfg(not(target_os = "redox"))]
3436
#[test]
3537
pub fn test_clock_id_res() {
3638
assert!(ClockId::CLOCK_REALTIME.res().is_ok());

test/test_unistd.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,7 @@ fn test_access_file_exists() {
10251025
assert!(access(&path, AccessFlags::R_OK | AccessFlags::W_OK).is_ok());
10261026
}
10271027

1028+
#[cfg(not(target_os = "redox"))]
10281029
#[test]
10291030
fn test_user_into_passwd() {
10301031
// get the UID of the "nobody" user

0 commit comments

Comments
 (0)