Skip to content

Commit

Permalink
refactor: remove old tests files which have been merged
Browse files Browse the repository at this point in the history
  • Loading branch information
saidsay-so committed Mar 26, 2024
1 parent f871a78 commit f730e9f
Show file tree
Hide file tree
Showing 172 changed files with 77 additions and 5,705 deletions.
11 changes: 9 additions & 2 deletions rust/src/tests/chflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ fn get_flags(ctx: &TestContext) -> (FileFlag, FileFlag, FileFlag) {

crate::test_case! {
/// chflags(2) set the flags provided for the file.
// chflags/00.t
set_flags, root, FileSystemFeature::Chflags => [Regular, Dir, Fifo, Block, Char, Socket]
}
fn set_flags(ctx: &mut TestContext, ft: FileType) {
Expand Down Expand Up @@ -106,6 +107,7 @@ fn set_flags(ctx: &mut TestContext, ft: FileType) {

crate::test_case! {
/// chflags changes flags while following symlinks
// chflags/00.t
set_flags_symlink, root, FileSystemFeature::Chflags
}
fn set_flags_symlink(ctx: &mut TestContext) {
Expand All @@ -129,6 +131,7 @@ fn set_flags_symlink(ctx: &mut TestContext) {
#[cfg(any(target_os = "netbsd", target_os = "freebsd", target_os = "dragonfly"))]
crate::test_case! {
/// lchflags changes flags without following symlinks
// chflags/00.t
lchflags_set_flags_no_follow_symlink, root, FileSystemFeature::Chflags
}
#[cfg(any(target_os = "netbsd", target_os = "freebsd", target_os = "dragonfly"))]
Expand All @@ -151,7 +154,8 @@ fn lchflags_set_flags_no_follow_symlink(ctx: &mut TestContext) {
}

crate::test_case! {
// successful chflags(2) updates ctime
/// successful chflags(2) updates ctime
// chflags/00.t
changed_ctime_success, root => [Regular, Dir, Fifo, Block, Char, Socket]
}
fn changed_ctime_success(ctx: &mut TestContext, ft: FileType) {
Expand Down Expand Up @@ -181,7 +185,8 @@ fn changed_ctime_success(ctx: &mut TestContext, ft: FileType) {
}
}
crate::test_case! {
// unsuccessful chflags(2) does not update ctime
/// unsuccessful chflags(2) does not update ctime
// chflags/00.t
unchanged_ctime_failed, serialized, root => [Regular, Dir, Fifo, Block, Char, Socket]
}
fn unchanged_ctime_failed(ctx: &mut SerializedTestContext, ft: FileType) {
Expand Down Expand Up @@ -222,6 +227,8 @@ enotdir_comp_test_case!(chflags(~path, FileFlag::empty()));

// chflags/02.t
enametoolong_comp_test_case!(chflags(~path, FileFlag::empty()));

// chflags/03.t
enametoolong_path_test_case!(chflags(~path, FileFlag::empty()));

// chflags/04.t
Expand Down
5 changes: 4 additions & 1 deletion rust/src/tests/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ crate::test_case! {
/// chmod returns EFTYPE if the effective user ID is not the super-user,
/// the mode includes the sticky bit (S_ISVTX),
/// and path does not refer to a directory
// chmod/12.t
// chmod/11.t
eftype, serialized, root => [Regular, Fifo, Block, Char, Socket]
}
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
Expand Down Expand Up @@ -198,7 +198,10 @@ fn eftype(ctx: &mut SerializedTestContext, ft: FileType) {
mod lchmod {
use super::*;

// chmod/01.t
enotdir_comp_test_case!(lchmod(~path, Mode::empty()));

// chmod/04.t
enoent_named_file_test_case!(lchmod(~path, Mode::empty()));
enoent_comp_test_case!(lchmod(~path, Mode::empty()));

Expand Down
21 changes: 14 additions & 7 deletions rust/src/tests/chown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ fn chown_wrapper(ctx: &mut TestContext, path: &std::path::Path) -> nix::Result<(
chown(path, Some(user.uid), None)
}

// chown/01.t
enotdir_comp_test_case!(chown, chown_wrapper);

// chown/02.t
enametoolong_comp_test_case!(chown, chown_wrapper);

// chown/03.t
enametoolong_path_test_case!(chown, chown_wrapper);

// chown/04.t
enoent_named_file_test_case!(chown, chown_wrapper);

Expand All @@ -33,12 +40,6 @@ eloop_comp_test_case!(chown, chown_wrapper);
// chown/06.t
eloop_final_comp_test_case!(chown, chown_wrapper);

// chown/02.t
enametoolong_comp_test_case!(chown, chown_wrapper);

// chown/03.t
enametoolong_path_test_case!(chown, chown_wrapper);

// chown/09.t
erofs_named_test_case!(chown, chown_wrapper);

Expand All @@ -56,14 +57,20 @@ mod lchown {
lchown(path, Some(user.uid), Some(user.gid))
}

// chown/01.t
enotdir_comp_test_case!(lchown, lchown_wrapper);

// chown/04.t
enoent_named_file_test_case!(lchown, lchown_wrapper);
enoent_comp_test_case!(lchown, lchown_wrapper);

// chown/06.t#L25
eloop_comp_test_case!(lchown, lchown_wrapper);


// chown/02.t
enametoolong_comp_test_case!(lchown, lchown_wrapper);

// chown/03.t
enametoolong_path_test_case!(lchown, lchown_wrapper);

// chown/09.t
Expand Down
5 changes: 5 additions & 0 deletions rust/src/tests/ftruncate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::{

crate::test_case! {
/// ftruncate should extend a file, and shrink a sparse file
// ftruncate/00.t
extend_file_shrink_sparse
}
fn extend_file_shrink_sparse(ctx: &mut TestContext) {
Expand All @@ -37,6 +38,7 @@ fn extend_file_shrink_sparse(ctx: &mut TestContext) {

crate::test_case! {
/// ftruncate should shrink the file if the specified size is less than the actual one
// ftruncate/00.t
shrink_not_empty
}
fn shrink_not_empty(ctx: &mut TestContext) {
Expand All @@ -62,6 +64,7 @@ fn shrink_not_empty(ctx: &mut TestContext) {

crate::test_case! {
/// ftruncate should update ctime if it succeeds
// ftruncate/00.t
update_ctime_success
}
fn update_ctime_success(ctx: &mut TestContext) {
Expand All @@ -74,6 +77,7 @@ fn update_ctime_success(ctx: &mut TestContext) {

crate::test_case! {
/// ftruncate should not update ctime if it fails
// ftruncate/00.t
unchanged_ctime_failed
}
fn unchanged_ctime_failed(ctx: &mut TestContext) {
Expand All @@ -88,6 +92,7 @@ crate::test_case! {
/// The file mode of a newly created file should not affect whether ftruncate
/// will work, only the create args
/// https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=154873
// ftruncate/00.t
affected_create_flags_only, serialized, root
}
fn affected_create_flags_only(ctx: &mut SerializedTestContext) {
Expand Down
2 changes: 2 additions & 0 deletions rust/src/tests/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ fn has_reasonable_link_max(_: &Config, base_path: &Path) -> anyhow::Result<()> {

crate::test_case! {
/// link returns EMLINK if the link count of the file named by name1 would exceed {LINK_MAX}
// link/05.t
link_count_max; has_reasonable_link_max
}
fn link_count_max(ctx: &mut TestContext) {
Expand Down Expand Up @@ -233,6 +234,7 @@ fn enoent_source_not_exists(ctx: &mut TestContext) {

crate::test_case! {
/// link returns EEXIST if the destination file exists
// link/10.t
eexist_dest_exists => [Regular, Dir, Fifo, Block, Char, Socket, Symlink(None)]
}
fn eexist_dest_exists(ctx: &mut TestContext, ft: FileType) {
Expand Down
4 changes: 4 additions & 0 deletions rust/src/tests/mkdir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ crate::test_case! {
/// POSIX: The file permission bits of the new directory shall be initialized from
/// mode. These file permission bits of the mode argument shall be modified by the
/// process' file creation mask.
// mkdir/00.t
permission_bits_from_mode, serialized
}
fn permission_bits_from_mode(ctx: &mut SerializedTestContext) {
Expand All @@ -27,6 +28,7 @@ crate::test_case! {
/// POSIX: The directory's user ID shall be set to the process' effective user ID.
/// The directory's group ID shall be set to the group ID of the parent directory
/// or to the effective group ID of the process.
// mkdir/00.t
uid_gid_eq_euid_egid, serialized, root
}
fn uid_gid_eq_euid_egid(ctx: &mut SerializedTestContext) {
Expand All @@ -38,6 +40,7 @@ crate::test_case! {
/// st_ctime, and st_mtime fields of the directory. Also, the st_ctime and
/// st_mtime fields of the directory that contains the new entry shall be marked
/// for update.
// mkdir/00.t
changed_time_fields_success
}
fn changed_time_fields_success(ctx: &mut TestContext) {
Expand All @@ -51,6 +54,7 @@ fn changed_time_fields_success(ctx: &mut TestContext) {
});
}

// mkdir/01.t
enotdir_comp_test_case!(mkdir(~path, Mode::empty()));

// mkdir/02.t
Expand Down
3 changes: 3 additions & 0 deletions rust/src/tests/mkfifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ crate::test_case! {
/// POSIX: The file permission bits of the new FIFO shall be initialized from
/// mode. The file permission bits of the mode argument shall be modified by the
/// process' file creation mask.
// mkfifo/00.t
permission_bits_from_mode, serialized
}
fn permission_bits_from_mode(ctx: &mut SerializedTestContext) {
Expand All @@ -28,6 +29,7 @@ crate::test_case! {
/// POSIX: The FIFO's user ID shall be set to the process' effective user ID.
/// The FIFO's group ID shall be set to the group ID of the parent directory or to
/// the effective group ID of the process.
// mkfifo/00.t
uid_gid_eq_euid_egid, serialized, root
}
fn uid_gid_eq_euid_egid(ctx: &mut SerializedTestContext) {
Expand All @@ -39,6 +41,7 @@ crate::test_case! {
/// st_ctime, and st_mtime fields of the file. Also, the st_ctime and
/// st_mtime fields of the directory that contains the new entry shall be marked
/// for update.
// mkfifo/00.t
changed_time_fields_success
}
fn changed_time_fields_success(ctx: &mut TestContext) {
Expand Down
11 changes: 9 additions & 2 deletions rust/src/tests/mknod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ crate::test_case! {
/// POSIX: The file permission bits of the new FIFO shall be initialized from
/// mode. The file permission bits of the mode argument shall be modified by the
/// process' file creation mask.
// mknod/00.t
permission_bits_from_mode, serialized
}
fn permission_bits_from_mode(ctx: &mut SerializedTestContext) {
Expand All @@ -32,6 +33,7 @@ crate::test_case! {
/// POSIX: The FIFO's user ID shall be set to the process' effective user ID.
/// The FIFO's group ID shall be set to the group ID of the parent directory or to
/// the effective group ID of the process.
// mknod/00.t
uid_gid_eq_euid_egid, serialized, root
}
fn uid_gid_eq_euid_egid(ctx: &mut SerializedTestContext) {
Expand All @@ -43,6 +45,7 @@ crate::test_case! {
/// st_ctime, and st_mtime fields of the file. Also, the st_ctime and
/// st_mtime fields of the directory that contains the new entry shall be marked
/// for update.
// mknod/00.t
changed_time_fields_success
}
fn changed_time_fields_success(ctx: &mut TestContext) {
Expand All @@ -59,16 +62,17 @@ fn changed_time_fields_success(ctx: &mut TestContext) {
// mknod/01.t
enotdir_comp_test_case!(mknod(~path, SFlag::S_IFIFO, Mode::empty(), 0));

// TODO: Move to privileged module
crate::test_case! {
/// mknod returns ENOTDIR if a component of the path prefix is not a directory
/// when trying to create char/block files
// mknod/01.t
enotdir_comp_char_block, root => [Regular, Fifo, Block, Char, Socket]
}
fn enotdir_comp_char_block(ctx: &mut TestContext, ft: FileType) {
let base_path = ctx.create(ft).unwrap();
let path = base_path.join("previous_not_dir");

// mknod/01.t
assert_eq!(
mknod(&path, SFlag::S_IFCHR, Mode::empty(), 0).unwrap_err(),
Errno::ENOTDIR
Expand Down Expand Up @@ -125,10 +129,12 @@ fn device_files(ctx: &mut TestContext, ft: FileType) {
assert!(check(&stat.file_type()));
}

// TODO: Move to privileged module and precise that it concerns only block and char
crate::test_case! {
/// mknod changes st_ctime and st_mtime of the parent directory
/// and marks for update the st_atime, st_ctime and st_mtime fields
/// of the new file
// mknod/00.t
changed_times_success, root => [Block, Char]
}
fn changed_times_success(ctx: &mut TestContext, ft: FileType) {
Expand Down Expand Up @@ -157,7 +163,8 @@ fn changed_times_success(ctx: &mut TestContext, ft: FileType) {

#[cfg(target_os = "illumos")]
crate::test_case! {
/// mknod creates devices with old and new numbers
/// mknod creates devices with old and new-style numbers
// mknod/11.t
create_old_new_device, root
}
#[cfg(target_os = "illumos")]
Expand Down
13 changes: 10 additions & 3 deletions rust/src/tests/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use super::errors::etxtbsy::etxtbsy_test_case;
use super::mksyscalls::{assert_perms_from_mode_and_umask, assert_uid_gid};
use super::{assert_times_changed, assert_times_unchanged, ATIME, CTIME, MTIME};

// open/00.t

fn open_wrapper(path: &Path, mode: Mode) -> nix::Result<()> {
open(path, OFlag::O_CREAT | OFlag::O_WRONLY, mode).and_then(close)
Expand All @@ -33,6 +32,7 @@ crate::test_case! {
/// on the file-mode bits and the corresponding bits in the complement of the
/// process' file mode creation mask. Thus, all bits in the file mode whose
/// corresponding bit in the file mode creation mask is set are cleared.
// open/00.t
permission_bits_from_mode, serialized
}
fn permission_bits_from_mode(ctx: &mut SerializedTestContext) {
Expand All @@ -44,6 +44,7 @@ crate::test_case! {
/// of the file shall be set to the effective user ID of the process; the group ID
/// of the file shall be set to the group ID of the file's parent directory or to
/// the effective group ID of the process [...]
// open/00.t
uid_gid_eq_euid_egid, serialized, root
}
fn uid_gid_eq_euid_egid(ctx: &mut SerializedTestContext) {
Expand All @@ -55,6 +56,7 @@ crate::test_case! {
/// st_ctime, and st_mtime fields of the directory. Also, the st_ctime and
/// st_mtime fields of the directory that contains the new entry shall be marked
/// for update.
// open/00.t
changed_time_fields_success
}
fn changed_time_fields_success(ctx: &mut TestContext) {
Expand All @@ -71,6 +73,7 @@ fn changed_time_fields_success(ctx: &mut TestContext) {
crate::test_case! {
/// open do not update parent directory ctime and mtime fields if
/// the file previously existed.
// open/00.t
exists_no_update
}
fn exists_no_update(ctx: &mut TestContext) {
Expand All @@ -85,6 +88,7 @@ fn exists_no_update(ctx: &mut TestContext) {

crate::test_case! {
/// open with O_TRUNC should truncate an exisiting file.
// open/00.t
open_trunc
}
fn open_trunc(ctx: &mut TestContext) {
Expand Down Expand Up @@ -124,6 +128,7 @@ fn interact_2gb(ctx: &mut TestContext) {
}

// POSIX states that open should return ELOOP, but FreeBSD returns EMLINK instead
// open/16.t
#[cfg(not(target_os = "freebsd"))]
crate::test_case! {
/// open returns ELOOP when O_NOFOLLOW was specified and the target is a symbolic link
Expand Down Expand Up @@ -168,6 +173,7 @@ crate::test_case! {
#[cfg(target_os = "linux")]
crate::test_case! {
/// open returns ENXIO when trying to open UNIX domain socket
// open/24.t
socket_error
}
fn socket_error(ctx: &mut TestContext) {
Expand All @@ -190,6 +196,7 @@ fn socket_error(ctx: &mut TestContext) {
crate::test_case! {
/// open returns ENXIO when O_NONBLOCK is set, the named file is a fifo, O_WRONLY is set,
/// and no process has the file open for reading
// open/17.t
fifo_nonblock_wronly
}
fn fifo_nonblock_wronly(ctx: &mut TestContext) {
Expand Down Expand Up @@ -227,20 +234,20 @@ erofs_named_test_case!(
// open/15.t
erofs_new_file_test_case!(
open,
open_flag_wrapper_ctx(OFlag::O_RDONLY | OFlag::O_CREAT,)
open_flag_wrapper_ctx(OFlag::O_RDONLY | OFlag::O_CREAT)
);

// open/12.t
eloop_comp_test_case!(open(~path, OFlag::empty(), Mode::empty()));

crate::test_case! {
/// open returns EISDIR if the named file is a directory
// open/13.t
eisdir
}
fn eisdir(ctx: &mut TestContext) {
let path = ctx.create(FileType::Dir).unwrap();

// open/13.t
assert_eq!(
open(&path, OFlag::O_WRONLY, Mode::empty()),
Err(Errno::EISDIR)
Expand Down
Loading

0 comments on commit f730e9f

Please sign in to comment.