Skip to content

Commit

Permalink
refactor: remove old tests files which have been merged (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
saidsay-so authored Sep 21, 2024
1 parent c5ab1b3 commit fe2db62
Show file tree
Hide file tree
Showing 165 changed files with 78 additions and 5,015 deletions.
11 changes: 9 additions & 2 deletions rust/src/tests/chflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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 @@ -110,6 +111,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 @@ -133,6 +135,7 @@ fn set_flags_symlink(ctx: &mut TestContext) {
#[cfg(lchflags)]
crate::test_case! {
/// lchflags changes flags without following symlinks
// chflags/00.t
lchflags_set_flags_no_follow_symlink, root, FileSystemFeature::Chflags
}
#[cfg(lchflags)]
Expand All @@ -155,7 +158,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 @@ -185,7 +189,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 @@ -226,6 +231,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
6 changes: 5 additions & 1 deletion rust/src/tests/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ fn failed_chmod_unchanged_ctime(ctx: &mut SerializedTestContext, f_type: FileTyp
});
}

// chmod/00.t:L119
crate::test_case! {
/// S_ISGID bit shall be cleared upon successful return from chmod of a regular file
/// if the calling process does not have appropriate privileges, and if
Expand Down Expand Up @@ -149,7 +150,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 +199,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
Loading

0 comments on commit fe2db62

Please sign in to comment.