Skip to content

Commit

Permalink
disable few tests and fix st_mode field.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Nov 25, 2024
1 parent 2f8c45b commit d6f67a7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/shims/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,13 @@ trait EvalContextExtPrivate<'tcx>: crate::MiriInterpCxExt<'tcx> {
let (access_sec, access_nsec) = metadata.accessed.unwrap_or((0, 0));
let (created_sec, created_nsec) = metadata.created.unwrap_or((0, 0));
let (modified_sec, modified_nsec) = metadata.modified.unwrap_or((0, 0));
let mode = metadata.mode.to_uint(this.libc_ty_layout("mode_t").size)?;

let buf = this.deref_pointer_as(buf_op, this.libc_ty_layout("stat"))?;
this.write_int_fields_named(
&[
("st_dev", 0),
("st_mode", mode.try_into().unwrap()),
("st_nlink", 0),
("st_ino", 0),
("st_uid", 0),
Expand Down
2 changes: 1 addition & 1 deletion src/shims/unix/solarish/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let result = this.macos_fbsd_solaris_readdir_r(dirp, entry, result)?;
this.write_scalar(result, dest)?;
}
// TODO readdir ?
// TODO readdir/readdir64: for tests fs::test_directory/canonicalize

// Miscellaneous
"___errno" => {
Expand Down
11 changes: 10 additions & 1 deletion tests/pass/shims/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
#![feature(io_error_more)]
#![feature(io_error_uncategorized)]

#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
use std::collections::BTreeMap;
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
use std::fs::{canonicalize, create_dir, read_dir, remove_dir, remove_dir_all};
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
use std::ffi::OsString;
use std::fs::{
File, OpenOptions, canonicalize, create_dir, read_dir, remove_dir, remove_dir_all, remove_file,
File, OpenOptions, remove_file,
rename,
};
use std::io::{Error, ErrorKind, IsTerminal, Read, Result, Seek, SeekFrom, Write};
Expand All @@ -27,7 +31,10 @@ fn main() {
test_file_sync();
test_errors();
test_rename();
// solarish needs to intercept readdir/readdir64 for these tests.
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
test_directory();
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
test_canonicalize();
test_from_raw_os_error();
#[cfg(unix)]
Expand Down Expand Up @@ -232,6 +239,7 @@ fn test_rename() {
remove_file(&path2).unwrap();
}

#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
fn test_canonicalize() {
let dir_path = utils::prepare_dir("miri_test_fs_dir");
create_dir(&dir_path).unwrap();
Expand All @@ -244,6 +252,7 @@ fn test_canonicalize() {
remove_dir_all(&dir_path).unwrap();
}

#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
fn test_directory() {
let dir_path = utils::prepare_dir("miri_test_fs_dir");
// Creating a directory should succeed.
Expand Down

0 comments on commit d6f67a7

Please sign in to comment.