summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/tests/fs/statfs.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/rustix/tests/fs/statfs.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/tests/fs/statfs.rs')
-rw-r--r--vendor/rustix/tests/fs/statfs.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/rustix/tests/fs/statfs.rs b/vendor/rustix/tests/fs/statfs.rs
new file mode 100644
index 000000000..f8bf2e350
--- /dev/null
+++ b/vendor/rustix/tests/fs/statfs.rs
@@ -0,0 +1,49 @@
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[test]
+fn test_statfs_abi() {
+ use rustix::fs::{FsWord, StatFs, NFS_SUPER_MAGIC, PROC_SUPER_MAGIC};
+
+ // Ensure these all have consistent types.
+ let t: StatFs = unsafe { std::mem::zeroed() };
+ let _s: FsWord = t.f_type;
+ let _u: FsWord = PROC_SUPER_MAGIC;
+ let _v: FsWord = NFS_SUPER_MAGIC;
+
+ // Ensure that after all the platform-specific dancing we have to do, this
+ // constant comes out with the correct value.
+ #[cfg(all(libc, not(target_env = "musl")))]
+ {
+ assert_eq!(
+ i128::from(PROC_SUPER_MAGIC),
+ i128::from(libc::PROC_SUPER_MAGIC)
+ );
+ assert_eq!(
+ i128::from(NFS_SUPER_MAGIC),
+ i128::from(libc::NFS_SUPER_MAGIC)
+ );
+ }
+
+ #[cfg(linux_raw)]
+ {
+ assert_eq!(
+ i128::from(PROC_SUPER_MAGIC),
+ i128::from(linux_raw_sys::general::PROC_SUPER_MAGIC)
+ );
+ assert_eq!(
+ i128::from(NFS_SUPER_MAGIC),
+ i128::from(linux_raw_sys::general::NFS_SUPER_MAGIC)
+ );
+ }
+
+ assert_eq!(PROC_SUPER_MAGIC, 0x0000_9fa0);
+ assert_eq!(NFS_SUPER_MAGIC, 0x0000_6969);
+}
+
+#[test]
+fn test_statfs() {
+ let statfs = rustix::fs::statfs("Cargo.toml").unwrap();
+ let f_blocks = statfs.f_blocks;
+ assert_ne!(f_blocks, 0);
+ // Previously we checked f_files != 0 here, but at least btrfs doesn't set
+ // that.
+}