Skip to content

Commit 9a17dec

Browse files
committed
Fix test and remove group & user for redox
- Make sure all tests pass the CI - Redox does not (yet) have passwd functions, so remove it
1 parent b6ea5c0 commit 9a17dec

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

src/sys/signal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ impl SigSet {
464464

465465
/// Suspends execution of the calling thread until one of the signals in the
466466
/// signal mask becomes pending, and returns the accepted signal.
467+
#[cfg(not(target_os = "redox"))] // RedoxFS does not yet support sigwait
467468
pub fn wait(&self) -> Result<Signal> {
468469
let mut signum = mem::MaybeUninit::uninit();
469470
let res = unsafe { libc::sigwait(&self.sigset as *const libc::sigset_t, signum.as_mut_ptr()) };

src/unistd.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use fcntl::FcntlArg::F_SETFD;
99
use libc::{self, c_char, c_void, c_int, c_long, c_uint, size_t, pid_t, off_t,
1010
uid_t, gid_t, mode_t, PATH_MAX};
1111
use std::{fmt, mem, ptr};
12-
use std::ffi::{CString, CStr, OsString};
12+
use std::ffi::{CStr, OsString};
1313
#[cfg(not(target_os = "redox"))]
14-
use std::ffi::{OsStr};
14+
use std::ffi::{CString, OsStr};
1515
use std::os::unix::ffi::OsStringExt;
1616
#[cfg(not(target_os = "redox"))]
1717
use std::os::unix::ffi::OsStrExt;
@@ -525,7 +525,9 @@ pub fn mkfifo<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()> {
525525
/// [mkfifoat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mkfifoat.html).
526526
// mkfifoat is not implemented in OSX or android
527527
#[inline]
528-
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
528+
#[cfg(not(any(
529+
target_os = "macos", target_os = "ios",
530+
target_os = "android", target_os = "redox")))]
529531
pub fn mkfifoat<P: ?Sized + NixPath>(dirfd: Option<RawFd>, path: &P, mode: Mode) -> Result<()> {
530532
let res = path.with_nix_path(|cstr| unsafe {
531533
libc::mkfifoat(at_rawfd(dirfd), cstr.as_ptr(), mode.bits() as mode_t)
@@ -1203,6 +1205,7 @@ pub enum LinkatFlags {
12031205
///
12041206
/// # References
12051207
/// See also [linkat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/linkat.html)
1208+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support symlinks yet
12061209
pub fn linkat<P: ?Sized + NixPath>(
12071210
olddirfd: Option<RawFd>,
12081211
oldpath: &P,
@@ -1325,7 +1328,6 @@ pub fn fsync(fd: RawFd) -> Result<()> {
13251328
// TODO: exclude only Apple systems after https://github.com/rust-lang/libc/pull/211
13261329
#[cfg(any(target_os = "linux",
13271330
target_os = "android",
1328-
target_os = "redox",
13291331
target_os = "emscripten"))]
13301332
#[inline]
13311333
pub fn fdatasync(fd: RawFd) -> Result<()> {
@@ -1660,6 +1662,7 @@ pub fn initgroups(user: &CStr, group: Gid) -> Result<()> {
16601662
///
16611663
/// See also [pause(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pause.html).
16621664
#[inline]
1665+
#[cfg(not(target_os = "redox"))]
16631666
pub fn pause() {
16641667
unsafe { libc::pause() };
16651668
}
@@ -2579,6 +2582,7 @@ pub fn access<P: ?Sized + NixPath>(path: &P, amode: AccessFlags) -> Result<()> {
25792582
/// fields are based on the user's locale, which could be non-UTF8, while other fields are
25802583
/// guaranteed to conform to [`NAME_REGEX`](https://serverfault.com/a/73101/407341), which only
25812584
/// contains ASCII.
2585+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
25822586
#[derive(Debug, Clone, PartialEq)]
25832587
pub struct User {
25842588
/// Username
@@ -2607,6 +2611,7 @@ pub struct User {
26072611
pub expire: libc::time_t
26082612
}
26092613

2614+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
26102615
impl From<&libc::passwd> for User {
26112616
fn from(pw: &libc::passwd) -> User {
26122617
unsafe {
@@ -2630,6 +2635,7 @@ impl From<&libc::passwd> for User {
26302635
}
26312636
}
26322637

2638+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
26332639
impl User {
26342640
fn from_anything<F>(f: F) -> Result<Option<Self>>
26352641
where
@@ -2707,6 +2713,7 @@ impl User {
27072713
}
27082714

27092715
/// Representation of a Group, based on `libc::group`
2716+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
27102717
#[derive(Debug, Clone, PartialEq)]
27112718
pub struct Group {
27122719
/// Group name
@@ -2717,6 +2724,7 @@ pub struct Group {
27172724
pub mem: Vec<String>
27182725
}
27192726

2727+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
27202728
impl From<&libc::group> for Group {
27212729
fn from(gr: &libc::group) -> Group {
27222730
unsafe {
@@ -2729,6 +2737,7 @@ impl From<&libc::group> for Group {
27292737
}
27302738
}
27312739

2740+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
27322741
impl Group {
27332742
unsafe fn members(mem: *mut *mut c_char) -> Vec<String> {
27342743
let mut ret = Vec::new();

test/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cfg_if! {
3333
}
3434
}
3535
}
36-
} else {
36+
} else if #[cfg(not(target_os = "redox"))] {
3737
macro_rules! require_capability {
3838
($capname:ident) => {}
3939
}
@@ -95,7 +95,7 @@ cfg_if! {
9595
}
9696
}
9797
}
98-
} else {
98+
} else if #[cfg(not(target_os = "redox"))] {
9999
macro_rules! skip_if_seccomp {
100100
($name:expr) => {}
101101
}

test/test_unistd.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ fn test_mkfifo_directory() {
108108
}
109109

110110
#[test]
111-
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
111+
#[cfg(not(any(
112+
target_os = "macos", target_os = "ios",
113+
target_os = "android", target_os = "redox")))]
112114
fn test_mkfifoat_none() {
113115
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
114116

@@ -123,7 +125,9 @@ fn test_mkfifoat_none() {
123125
}
124126

125127
#[test]
126-
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
128+
#[cfg(not(any(
129+
target_os = "macos", target_os = "ios",
130+
target_os = "android", target_os = "redox")))]
127131
fn test_mkfifoat() {
128132
let tempdir = tempfile::tempdir().unwrap();
129133
let dirfd = open(tempdir.path(), OFlag::empty(), Mode::empty()).unwrap();
@@ -137,7 +141,9 @@ fn test_mkfifoat() {
137141
}
138142

139143
#[test]
140-
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
144+
#[cfg(not(any(
145+
target_os = "macos", target_os = "ios",
146+
target_os = "android", target_os = "redox")))]
141147
fn test_mkfifoat_directory_none() {
142148
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
143149

@@ -146,7 +152,9 @@ fn test_mkfifoat_directory_none() {
146152
}
147153

148154
#[test]
149-
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
155+
#[cfg(not(any(
156+
target_os = "macos", target_os = "ios",
157+
target_os = "android", target_os = "redox")))]
150158
fn test_mkfifoat_directory() {
151159
// mkfifoat should fail if a directory is given
152160
let tempdir = tempfile::tempdir().unwrap();
@@ -680,6 +688,7 @@ fn test_symlinkat() {
680688
}
681689

682690
#[test]
691+
#[cfg(not(target_os = "redox"))]
683692
fn test_linkat_file() {
684693
let tempdir = tempfile::tempdir().unwrap();
685694
let oldfilename = "foo.txt";
@@ -700,6 +709,7 @@ fn test_linkat_file() {
700709
}
701710

702711
#[test]
712+
#[cfg(not(target_os = "redox"))]
703713
fn test_linkat_olddirfd_none() {
704714
let _dr = ::DirRestore::new();
705715

@@ -724,6 +734,7 @@ fn test_linkat_olddirfd_none() {
724734
}
725735

726736
#[test]
737+
#[cfg(not(target_os = "redox"))]
727738
fn test_linkat_newdirfd_none() {
728739
let _dr = ::DirRestore::new();
729740

@@ -748,7 +759,7 @@ fn test_linkat_newdirfd_none() {
748759
}
749760

750761
#[test]
751-
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
762+
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
752763
fn test_linkat_no_follow_symlink() {
753764
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
754765

@@ -785,6 +796,7 @@ fn test_linkat_no_follow_symlink() {
785796
}
786797

787798
#[test]
799+
#[cfg(not(target_os = "redox"))]
788800
fn test_linkat_follow_symlink() {
789801
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
790802

0 commit comments

Comments
 (0)