From 7b66a2885b38a5af58f2b17c9b3bc9bda6a42ad3 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Tue, 6 Aug 2019 13:07:23 +0200 Subject: [PATCH] tests: add two more tests for preserving and force removal of conf files --- tests/xbps/libxbps/shell/remove_test.sh | 65 +++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/xbps/libxbps/shell/remove_test.sh b/tests/xbps/libxbps/shell/remove_test.sh index 148722ab..28a8a35d 100644 --- a/tests/xbps/libxbps/shell/remove_test.sh +++ b/tests/xbps/libxbps/shell/remove_test.sh @@ -552,6 +552,69 @@ remove_modified_files_body() { atf_check_equal $rv 0 } +atf_test_case keep_modified_conf_files + +keep_modified_conf_files_head() { + atf_set "descr" "Tests for package removal: keep modified conf files in rootdir" +} + +keep_modified_conf_files_body() { + mkdir some_repo + mkdir -p pkg_A/bin + echo "1234" >pkg_A/bin/ash + echo "1234" >pkg_A/bin/sh + + cd some_repo + xbps-create -A noarch -n A-1.0_1 -s "A pkg" --config-files "/bin/ash /bin/sh" ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + xbps-install -r root -C null.conf --repository=$PWD/some_repo -y A + atf_check_equal $? 0 + echo "keep" >root/bin/sh + echo "keep" >root/bin/ash + + xbps-remove -r root -yvd A + atf_check_equal $? 0 + rv=1 + if [ -e root/bin/sh -a -e root/bin/ash ]; then + rv=0 + fi + atf_check_equal $rv 0 +} + +atf_test_case remove_modified_conf_files + +remove_modified_conf_files_head() { + atf_set "descr" "Tests for package removal: force remove modified conf files in rootdir" +} + +remove_modified_conf_files_body() { + mkdir some_repo + mkdir -p pkg_A/bin + echo "1234" >pkg_A/bin/ash + echo "1234" >pkg_A/bin/sh + + cd some_repo + xbps-create -A noarch -n A-1.0_1 -s "A pkg" --config-files "/bin/ash /bin/sh" ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + xbps-install -r root -C null.conf --repository=$PWD/some_repo -y A + atf_check_equal $? 0 + echo "don't keep" >root/bin/sh + echo "don't keep" > root/bin/ash + + xbps-remove -r root -yvdf A + atf_check_equal $? 0 + rv=0 + [ -e root/bin/sh ] && rv=1 + [ -e root/bin/ash ] && rv=1 + atf_check_equal $rv 0 +} + atf_init_test_cases() { atf_add_test_case keep_base_symlinks atf_add_test_case keep_modified_symlinks @@ -572,4 +635,6 @@ atf_init_test_cases() { atf_add_test_case remove_directory atf_add_test_case keep_modified_files atf_add_test_case remove_modified_files + atf_add_test_case keep_modified_conf_files + atf_add_test_case remove_modified_conf_files }