Skip to content

Conversation

JRF63
Copy link
Contributor

@JRF63 JRF63 commented Sep 17, 2024

Root cause is not properly following section 2.e of the cp spec. The bug itself is encountered if the file system lists D/D before D/a.

@JRF63 JRF63 marked this pull request as draft September 17, 2024 14:52
@jgarzik
Copy link
Contributor

jgarzik commented Sep 17, 2024

Here is the failure after testing this issue199 branch:


     Running tests/tree-tests.rs (target/release/deps/tree_tests-48a52f9cf418fb37)

running 111 tests
test cp::test_cp_dir_slash ... ok
test cp::test_cp_deref ... ok
test cp::test_cp_dir_vs_file ... ok
test cp::test_cp_childproof ... ok
test cp::test_cp_fail_perm ... FAILED
test cp::test_cp_into_self ... ok
test cp::test_cp_hl ... ok
test cp::test_cp_special_bits ... ignored
test cp::test_cp_i_2 ... ok
test cp::test_cp_i ... ok
test cp::test_cp_thru_dangling ... ok
test cp::test_cp_special_f ... ok
test cp::test_cp_r_vs_symlink ... ok
test link::link_already_exists ... ok
test link::link_create ... ok
test cp::test_cp_trailing_slash ... ok
test cp::test_cp_part_symlink ... ok
test ls::test_ls_empty_directory ... ok
test ls::test_ls_infloop ... ok
test ls::test_ls_file_type ... ok
test ls::test_ls_no_arg ... ok
test ls::test_ls_dangle ... ok
test ls::test_ls_recursive ... ok
test ls::test_ls_rt_1 ... ok
test ls::test_ls_m_option ... ok
test mkdir::test_create_single_directory ... ok
test ls::test_ls_inode ... ok
test mkdir::test_directory_already_exists ... ok
test mkdir::test_invalid_mode ... ok
test ls::test_ls_size_align ... ok
test mkdir::test_set_directory_mode ... ok
test cp::test_cp_proc_short_read ... ok
test mv::test_mv_atomic2 ... ok
test mv::test_mv_atomic ... ok
test cp::test_cp_same_file ... ok
test mv::test_mv_dir2dir ... ok
test mv::test_mv_dir_file ... ok
test mv::test_mv_hard_4 ... ok
test mv::test_mv_hardlink_case ... ignored
test mv::test_mv_hard_2 ... ok
test mv::test_mv_childproof ... ok
test mv::test_mv_force ... ok
test mv::test_mv_i_1 ... ok
test mv::test_mv_i_link_no ... ignored
test mv::test_mv_dup_source ... ok
test mv::test_mv_i_5 ... ok
test mv::test_mv_hard_link_1 ... ok
test mv::test_mv_i_2 ... ok
test mv::test_mv_into_self ... ok
test mv::test_mv_i_4 ... ok
test mv::test_mv_into_self_3 ... ok
test mv::test_mv_into_self_4 ... ok
test mv::test_mv_part_fail ... ok
test mv::test_mv_into_self_2 ... ok
test mv::test_mv_perm_1 ... ok
test mv::test_mv_part_hardlink ... ok
test mv::test_mv_partition_perm ... ok
test mv::test_mv_sticky_to_xpart ... ignored
test mv::test_mv_symlink_onto_hardlink_to_self ... ok
test mv::test_mv_special ... ok
test mv::test_mv_symlink_onto_hardlink ... ok
test mv::test_mv_to_symlink ... ok
test mv::test_mv_part_symlink ... ok
test readlink::test_readlink_non_existent_file ... ok
test mv::test_mv_part_rename ... ok
test readlink::test_readlink_not_a_symlink ... ok
test mv::test_mv_trailing_slash ... ok
test readlink::test_readlink_valid_symlink ... ok
test readlink::test_readlink_valid_symlink_no_newline ... ok
test rm::test_rm_cycle ... ok
test rm::test_rm_dir_no_w ... ok
test rm::test_rm_dir_nonrecur ... ok
test rm::test_rm_dot_rel ... ok
test rm::test_rm_empty_inacc ... ok
test rm::test_rm_f_1 ... ok
test rm::test_rm_fail_2eperm ... ignored
test rm::test_rm_empty_name ... ok
test rm::test_rm_i_1 ... ok
test rm::test_rm_fail_eacces ... ok
test rm::test_rm_i_no_r ... ok
test rm::test_rm_ignorable ... ok
test rm::test_rm_ir_1 ... ok
test rm::test_rm_inaccessible ... ok
test rm::test_rm_no_give_up ... ignored
test rm::test_rm_dangling_symlink ... ok
test rm::test_rm_r_4 ... ok
test rm::test_rm_r_3 ... ok
test rm::test_rm_r_root ... ok
test rm::test_rm_rm1 ... ok
test rm::test_rm_rm2 ... ok
test rm::test_rm_rm3 ... ok
test rm::test_rm_rm4 ... ok
test rm::test_rm_rm5 ... ok
test rm::test_rm_sunos_1 ... ok
test rm::test_rm_unread2 ... ok
test rm::test_rm_readdir_bug ... ok
test rm::test_rm_unread3 ... ok
test rmdir::rmdir_remove_directory_with_parents ... ok
test rmdir::rmdir_remove_existing_directory ... ok
test rm::test_rm_unreadable ... ok
test rmdir::rmdir_remove_non_empty_directory ... ok
test rmdir::rmdir_remove_non_existent_directory ... ok
test unlink::unlink_remove_directory ... ok
test unlink::unlink_remove_existing_file ... ok
test unlink::unlink_remove_non_existing_file ... ok
test rm::test_rm_deep_2 ... ok
test mv::test_mv_leak_fd ... ok
test rm::test_rm_hash ... ok
test ls::test_ls_time ... ok
test cp::test_cp_preserve_slink_time ... ok
test rm::test_rm_isatty ... ok

failures:

---- cp::test_cp_fail_perm stdout ----
thread 'cp::test_cp_fail_perm' panicked at plib/src/testing.rs:68:5:
assertion `left == right` failed
  left: "cp: Permission denied\n"
 right: "cp: cannot open '/home/jgarzik/repo/posixutils-rs/target/tmp/test_cp_fail_perm/D/a' for reading: Permission denied\n"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    cp::test_cp_fail_perm

test result: FAILED. 104 passed; 1 failed; 6 ignored; 0 measured; 0 filtered out; finished in 3.08s

error: test failed, to rerun pass `-p posixutils-tree --test tree-tests`

@JRF63 JRF63 force-pushed the issue199 branch 2 times, most recently from 79daf93 to daa9e35 Compare September 18, 2024 13:37
@JRF63 JRF63 marked this pull request as ready for review September 18, 2024 14:04
@jgarzik
Copy link
Contributor

jgarzik commented Sep 18, 2024

This fails on Linux in a new way:


---- cp::test_cp_fail_perm stdout ----
thread 'cp::test_cp_fail_perm' panicked at tree/tests/cp/mod.rs:348:34:
called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    cp::test_cp_fail_perm

test result: FAILED. 105 passed; 1 failed; 6 ignored; 0 measured; 0 filtered out; finished in 3.09s

Also tested on MacOS. All tests pass. No regressions.

@JRF63
Copy link
Contributor Author

JRF63 commented Sep 18, 2024

Forgot to reset the permissions for DD like in test_cp_issue199. Latest commit is the same as the previous plus the said modification:

@@ -342,7 +342,7 @@ fn test_cp_fail_perm() {
         1,
     );

-    for f in [test_dir, d, d_a] {
+    for f in [test_dir, d, d_a, dd] {
         fs::set_permissions(f, fs::Permissions::from_mode(0o777)).unwrap();
     }
     fs::remove_dir_all(test_dir).unwrap();

@jgarzik jgarzik merged commit 80a0bd2 into rustcoreutils:main Sep 19, 2024
2 checks passed
@jgarzik
Copy link
Contributor

jgarzik commented Sep 19, 2024

Testing successful, well done.

Fixed #199

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants