Skip to content

Commit 853458a

Browse files
committed
Check RELATIME against mountinfo only where it is defined
The libc backend defines `StatVfsMountFlags::RELATIME` only where libc has `ST_RELATIME` (Android and glibc), so the mountinfo test did not compile for x86_64-unknown-linux-musl with use-libc. Compare the other flags everywhere, and `RELATIME` where the constant exists.
1 parent 00d4575 commit 853458a

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎tests/fs/statfs.rs‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,24 @@ fn test_statvfs_mount_flags_match_mountinfo() {
117117
};
118118
let options: Vec<&str> = options.split(',').collect();
119119
let flags = rustix::fs::statvfs(point).unwrap().f_flag;
120-
for (option, flag) in [
120+
#[allow(unused_mut)]
121+
let mut pairs = vec![
121122
("ro", Flags::RDONLY),
122123
("nosuid", Flags::NOSUID),
123124
("nodev", Flags::NODEV),
124125
("noexec", Flags::NOEXEC),
125126
("noatime", Flags::NOATIME),
126127
("nodiratime", Flags::NODIRATIME),
127-
("relatime", Flags::RELATIME),
128-
] {
128+
];
129+
// The libc backend has `RELATIME` only where libc defines
130+
// `ST_RELATIME`.
131+
#[cfg(any(
132+
linux_raw,
133+
target_os = "android",
134+
all(target_os = "linux", target_env = "gnu")
135+
))]
136+
pairs.push(("relatime", Flags::RELATIME));
137+
for (option, flag) in pairs {
129138
assert_eq!(
130139
flags.contains(flag),
131140
options.contains(&option),

0 commit comments

Comments
 (0)