Skip to content

Commit 3bd2ba0

Browse files
committed
Add test for statx
1 parent 7f22177 commit 3bd2ba0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/run-pass/fs.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ignore-windows: File handling is not implemented yet
22
// compile-flags: -Zmiri-disable-isolation
33

4-
use std::fs::{File, remove_file};
4+
use std::fs::{File, remove_file, metadata};
55
use std::io::{Read, Write, ErrorKind};
66

77
fn main() {
@@ -21,7 +21,15 @@ fn main() {
2121
// Reading until EOF should get the whole text.
2222
file.read_to_end(&mut contents).unwrap();
2323
assert_eq!(bytes, contents.as_slice());
24-
// Removing file should succeed
24+
25+
// Test that the file metadata is correct.
26+
let metadata = metadata(&path).unwrap();
27+
// `path` should point to a file.
28+
assert!(metadata.is_file());
29+
// The size of the file must be equal to the number of written bytes.
30+
assert_eq!(bytes.len() as u64, metadata.len());
31+
32+
// Removing file should succeed.
2533
remove_file(&path).unwrap();
2634

2735
// The two following tests also check that the `__errno_location()` shim is working properly.

0 commit comments

Comments
 (0)