Skip to content

Commit 106927a

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 5229c44 commit 106927a

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
@@ -10,9 +10,9 @@ 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};
1212
use std::convert::Infallible;
13-
use std::ffi::{CString, CStr, OsString};
13+
use std::ffi::{CStr, OsString};
1414
#[cfg(not(target_os = "redox"))]
15-
use std::ffi::OsStr;
15+
use std::ffi::{CString, OsStr};
1616
use std::os::unix::ffi::OsStringExt;
1717
#[cfg(not(target_os = "redox"))]
1818
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)
@@ -1205,6 +1207,7 @@ pub enum LinkatFlags {
12051207
///
12061208
/// # References
12071209
/// See also [linkat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/linkat.html)
1210+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support symlinks yet
12081211
pub fn linkat<P: ?Sized + NixPath>(
12091212
olddirfd: Option<RawFd>,
12101213
oldpath: &P,
@@ -1327,7 +1330,6 @@ pub fn fsync(fd: RawFd) -> Result<()> {
13271330
// TODO: exclude only Apple systems after https://github.com/rust-lang/libc/pull/211
13281331
#[cfg(any(target_os = "linux",
13291332
target_os = "android",
1330-
target_os = "redox",
13311333
target_os = "emscripten"))]
13321334
#[inline]
13331335
pub fn fdatasync(fd: RawFd) -> Result<()> {
@@ -1662,6 +1664,7 @@ pub fn initgroups(user: &CStr, group: Gid) -> Result<()> {
16621664
///
16631665
/// See also [pause(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pause.html).
16641666
#[inline]
1667+
#[cfg(not(target_os = "redox"))]
16651668
pub fn pause() {
16661669
unsafe { libc::pause() };
16671670
}
@@ -2581,6 +2584,7 @@ pub fn access<P: ?Sized + NixPath>(path: &P, amode: AccessFlags) -> Result<()> {
25812584
/// fields are based on the user's locale, which could be non-UTF8, while other fields are
25822585
/// guaranteed to conform to [`NAME_REGEX`](https://serverfault.com/a/73101/407341), which only
25832586
/// contains ASCII.
2587+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
25842588
#[derive(Debug, Clone, PartialEq)]
25852589
pub struct User {
25862590
/// Username
@@ -2609,6 +2613,7 @@ pub struct User {
26092613
pub expire: libc::time_t
26102614
}
26112615

2616+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
26122617
impl From<&libc::passwd> for User {
26132618
fn from(pw: &libc::passwd) -> User {
26142619
unsafe {
@@ -2632,6 +2637,7 @@ impl From<&libc::passwd> for User {
26322637
}
26332638
}
26342639

2640+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
26352641
impl User {
26362642
fn from_anything<F>(f: F) -> Result<Option<Self>>
26372643
where
@@ -2709,6 +2715,7 @@ impl User {
27092715
}
27102716

27112717
/// Representation of a Group, based on `libc::group`
2718+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
27122719
#[derive(Debug, Clone, PartialEq)]
27132720
pub struct Group {
27142721
/// Group name
@@ -2719,6 +2726,7 @@ pub struct Group {
27192726
pub mem: Vec<String>
27202727
}
27212728

2729+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
27222730
impl From<&libc::group> for Group {
27232731
fn from(gr: &libc::group) -> Group {
27242732
unsafe {
@@ -2731,6 +2739,7 @@ impl From<&libc::group> for Group {
27312739
}
27322740
}
27332741

2742+
#[cfg(not(target_os = "redox"))] // RedoxFS does not support passwd
27342743
impl Group {
27352744
unsafe fn members(mem: *mut *mut c_char) -> Vec<String> {
27362745
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)