From d6f67a775503d8785926a0844e25065602844c85 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 25 Nov 2024 22:12:06 +0000 Subject: [PATCH] disable few tests and fix st_mode field. --- src/shims/unix/fs.rs | 2 ++ src/shims/unix/solarish/foreign_items.rs | 2 +- tests/pass/shims/fs.rs | 11 ++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/shims/unix/fs.rs b/src/shims/unix/fs.rs index 644486e3ce..58529769fd 100644 --- a/src/shims/unix/fs.rs +++ b/src/shims/unix/fs.rs @@ -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), diff --git a/src/shims/unix/solarish/foreign_items.rs b/src/shims/unix/solarish/foreign_items.rs index 1c693f45de..ee342f5c2a 100644 --- a/src/shims/unix/solarish/foreign_items.rs +++ b/src/shims/unix/solarish/foreign_items.rs @@ -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" => { diff --git a/tests/pass/shims/fs.rs b/tests/pass/shims/fs.rs index 81151f4ac4..56bcd80eec 100644 --- a/tests/pass/shims/fs.rs +++ b/tests/pass/shims/fs.rs @@ -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}; @@ -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)] @@ -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(); @@ -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.