mv: Add test cases for command-line options.
Some checks are pending
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /opt/homebrew/opt/llvm@18/bin, macos-latest, bmake libarchive llvm@18, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /opt/homebrew/opt/llvm@18/bin, macos-latest, bmake libarchive llvm@18, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /usr/lib/llvm-18/bin, ubuntu-24.04, bmake libarchive-dev clang-18 lld-18, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /usr/lib/llvm-18/bin, ubuntu-24.04, bmake libarchive-dev clang-18 lld-18, arm64, aarch64) (push) Waiting to run

Sponsored by:	Klara, Inc.
Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D47582
This commit is contained in:
Dag-Erling Smørgrav 2024-11-19 10:29:15 +01:00
parent 2822a79533
commit d4fb5984ab

View File

@ -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
}