Skip to content

Commit

Permalink
Skip the OFD locks tests on OverlayFS and musl
Browse files Browse the repository at this point in the history
OFD lock functions don't work as expected on overlayfs, which is a type
of union file system.  And OVERLAYFS_SUPER_MAGIC isn't defined on musl,
at least not yet.
  • Loading branch information
asomers committed Jul 3, 2020
1 parent d57326e commit f4698ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -17,7 +17,7 @@ exclude = [
]

[dependencies]
libc = { git = "https://github.com/rust-lang/libc/", features = [ "extra_traits" ] }
libc = { git = "https://github.com/rust-lang/libc/", rev = "fdc5cf4a1ba362aec989bd3dc7ec88bcd371a23a", features = [ "extra_traits" ] }
bitflags = "1.1"
cfg-if = "0.1.10"

Expand Down
2 changes: 2 additions & 0 deletions src/sys/statfs.rs
Expand Up @@ -72,6 +72,8 @@ pub const NFS_SUPER_MAGIC: FsType = FsType(libc::NFS_SUPER_MAGIC);
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
pub const OPENPROM_SUPER_MAGIC: FsType = FsType(libc::OPENPROM_SUPER_MAGIC);
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
pub const OVERLAYFS_SUPER_MAGIC: FsType = FsType(libc::OVERLAYFS_SUPER_MAGIC);
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
pub const PROC_SUPER_MAGIC: FsType = FsType(libc::PROC_SUPER_MAGIC);
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
pub const QNX4_SUPER_MAGIC: FsType = FsType(libc::QNX4_SUPER_MAGIC);
Expand Down
20 changes: 18 additions & 2 deletions test/test_fcntl.rs
Expand Up @@ -228,11 +228,19 @@ mod linux_android {
target_arch = "mips64",
target_arch = "mips64el",
target_arch = "powerpc64",
target_arch = "powerpc64le")))]
target_arch = "powerpc64le",
target_env = "musl")))]
fn test_ofd_write_lock() {
let tmp = NamedTempFile::new().unwrap();

let fd = tmp.as_raw_fd();
let statfs = nix::sys::statfs::fstatfs(&tmp).unwrap();
if statfs.filesystem_type() == nix::sys::statfs::OVERLAYFS_SUPER_MAGIC {
// OverlayFS is a union file system. It returns one inode value in
// stat(2), but a different one shows up in /proc/locks. So we must
// skip the test.
skip!("/proc/locks does not work on overlayfs");
}
let inode = fstat(fd).expect("fstat failed").st_ino as usize;

let mut flock = libc::flock {
Expand Down Expand Up @@ -262,11 +270,19 @@ mod linux_android {
target_arch = "mips64",
target_arch = "mips64el",
target_arch = "powerpc64",
target_arch = "powerpc64le")))]
target_arch = "powerpc64le",
target_env = "musl")))]
fn test_ofd_read_lock() {
let tmp = NamedTempFile::new().unwrap();

let fd = tmp.as_raw_fd();
let statfs = nix::sys::statfs::fstatfs(&tmp).unwrap();
if statfs.filesystem_type() == nix::sys::statfs::OVERLAYFS_SUPER_MAGIC {
// OverlayFS is a union file system. It returns one inode value in
// stat(2), but a different one shows up in /proc/locks. So we must
// skip the test.
skip!("/proc/locks does not work on overlayfs");
}
let inode = fstat(fd).expect("fstat failed").st_ino as usize;

let mut flock = libc::flock {
Expand Down

0 comments on commit f4698ea

Please sign in to comment.