mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-21 07:15:49 +00:00
mv: Add test cases for command-line options.
Sponsored by: Klara, Inc. Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D47582
This commit is contained in:
parent
2822a79533
commit
d4fb5984ab
@ -371,6 +371,118 @@ fifo_from_dir_into_dir_cleanup() {
|
||||
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 <n
|
||||
mv_checkfile fa fa
|
||||
mv_checkfile fb ${FS}fb
|
||||
# Second test, answer yes, file is replaced
|
||||
atf_check -e match:"^overwrite ${FS}fb\\?" \
|
||||
mv -i fa ${FS}fb <y
|
||||
mv_checkabsent fa
|
||||
mv_checkfile fa ${FS}fb
|
||||
done
|
||||
}
|
||||
mv_i_cleanup() {
|
||||
mv_cleanup
|
||||
}
|
||||
|
||||
atf_test_case mv_n cleanup
|
||||
mv_n_head() {
|
||||
atf_set "descr" "Decline replacement"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
mv_n_body() {
|
||||
mv_setup
|
||||
for FS in "" "fs/" ; do
|
||||
mv_makefile fa
|
||||
mv_makefile ${FS}fb
|
||||
atf_check mv -n fa ${FS}fb
|
||||
mv_checkfile fa fa
|
||||
mv_checkfile fb ${FS}fb
|
||||
done
|
||||
}
|
||||
mv_n_cleanup() {
|
||||
mv_cleanup
|
||||
}
|
||||
|
||||
atf_test_case mv_v cleanup
|
||||
mv_v_head() {
|
||||
atf_set "descr" "Verbose mode"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
mv_v_body() {
|
||||
mv_setup
|
||||
for FS in "" "fs/" ; do
|
||||
mv_makefile fa
|
||||
atf_check mkdir ${FS}da
|
||||
atf_check -o inline:"fa -> ${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_init_test_cases() {
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user