diff --git a/bin/mv/tests/mv_test.sh b/bin/mv/tests/mv_test.sh --- a/bin/mv/tests/mv_test.sh +++ b/bin/mv/tests/mv_test.sh @@ -371,6 +371,118 @@ mv_cleanup } +atf_test_case mv_f cleanup +mv_f_head() { + atf_set "descr" "Force replacement" + atf_set "require.user" "root" +} +mv_f_body() { + mv_setup + for FS in "" "fs/" ; do + mv_makefile fa + atf_check mv fa ${FS}fb + mv_checkfile fa ${FS}fb + mv_checkabsent fa + mv_makefile fa + :> ${FS}fb + atf_check mv -i -n -f fa ${FS}fb + mv_checkfile fa ${FS}fb + mv_checkabsent fa + done +} +mv_f_cleanup() { + mv_cleanup +} + +atf_test_case mv_h cleanup +mv_h_head() { + atf_set "descr" "Replace symbolic link" + atf_set "require.user" "root" +} +mv_h_body() { + mv_setup + for FS in "" "fs/" ; do + atf_check mkdir ${FS}da + atf_check ln -s da ${FS}db + # First test without -h, file goes into symlink target + mv_makefile fa + atf_check mv fa ${FS}db + mv_checkfile fa ${FS}da/fa + # Second test with -h, file replaces symlink + mv_makefile fa + atf_check mv -h fa ${FS}db + mv_checkfile fa ${FS}db + done +} +mv_h_cleanup() { + mv_cleanup +} + +atf_test_case mv_i cleanup +mv_i_head() { + atf_set "descr" "Confirm replacement" + atf_set "require.user" "root" +} +mv_i_body() { + mv_setup + echo n >n + echo y >y + for FS in "" "fs/" ; do + mv_makefile fa + mv_makefile ${FS}fb + # First test, answer no, file is not replaced + atf_check -e match:"^overwrite ${FS}fb\\?" \ + mv -i fa ${FS}fb ${FS}da/fa\n" \ + mv -v fa ${FS}da + done +} +mv_v_cleanup() { + mv_cleanup +} + atf_init_test_cases() { atf_add_test_case rename_file atf_add_test_case file_into_dir @@ -388,4 +500,9 @@ atf_add_test_case fifo_into_dir atf_add_test_case fifo_from_dir atf_add_test_case fifo_from_dir_into_dir + atf_add_test_case mv_f + atf_add_test_case mv_h + atf_add_test_case mv_i + atf_add_test_case mv_n + atf_add_test_case mv_v }