diff --git a/tests/xbps/libxbps/shell/Kyuafile b/tests/xbps/libxbps/shell/Kyuafile index 55a533d7..6b29b95c 100644 --- a/tests/xbps/libxbps/shell/Kyuafile +++ b/tests/xbps/libxbps/shell/Kyuafile @@ -25,3 +25,4 @@ atf_test_program{name="cyclic_deps"} atf_test_program{name="conflicts"} atf_test_program{name="downgrade_hold"} atf_test_program{name="ignore"} +atf_test_program{name="preserve"} diff --git a/tests/xbps/libxbps/shell/Makefile b/tests/xbps/libxbps/shell/Makefile index c35da2a9..d976f7a1 100644 --- a/tests/xbps/libxbps/shell/Makefile +++ b/tests/xbps/libxbps/shell/Makefile @@ -7,7 +7,7 @@ TESTSHELL+= replace_test installmode_test obsoletefiles_test TESTSHELL+= issue31_test scripts_test incorrect_deps_test TESTSHELL+= vpkg_test install_test preserve_files_test configure_test TESTSHELL+= update_shlibs update_hold update_repolock cyclic_deps conflicts -TESTSHELL+= update_itself downgrade_hold ignore +TESTSHELL+= update_itself downgrade_hold ignore preserve EXTRA_FILES = Kyuafile include $(TOPDIR)/mk/test.mk diff --git a/tests/xbps/libxbps/shell/preserve.sh b/tests/xbps/libxbps/shell/preserve.sh new file mode 100644 index 00000000..a97b5c02 --- /dev/null +++ b/tests/xbps/libxbps/shell/preserve.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env atf-sh + +atf_test_case preserve_update + +preserve_update_head() { + atf_set "descr" "Tests for pkg install/upgrade with preserve" +} + +preserve_update_body() { + mkdir some_repo + mkdir -p pkg_A/1.0 + echo "blahblah" > pkg_A/1.0/blah + echo "foofoo" > pkg_A/1.0/foo + + cd some_repo + xbps-create -A noarch -n A-1.0_1 -s "A pkg" --preserve ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + xbps-install -r root --repository=$PWD/some_repo -yd A + atf_check_equal $? 0 + + cd some_repo + mv ../pkg_A/1.0 ../pkg_A/1.1 + rm -f *.xbps + xbps-create -A noarch -n A-1.1_1 -s "A pkg" --preserve ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + xbps-install -r root --repository=$PWD/some_repo -yd A + atf_check_equal $? 0 + + rv=0 + [ -e root/1.0/blah -a -e root/1.0/blah ] || rv=1 + [ -e root/1.1/blah -a -e root/1.1/blah ] || rv=2 + atf_check_equal $rv 0 + + xbps-pkgdb -r root -av + atf_check_equal $? 0 +} + +atf_test_case preserve_update_conflict + +preserve_update_conflict_head() { + # current behaviour is to not fail + atf_set "descr" "Tests for pkg install/upgrade with preserve conflict" +} + +preserve_update_conflict_body() { + mkdir some_repo + mkdir -p pkg_A/1.0 + echo "blahblah" > pkg_A/1.0/blah + echo "foofoo" > pkg_A/1.0/foo + + cd some_repo + xbps-create -A noarch -n A-1.0_1 -s "A pkg" --preserve ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + xbps-install -r root --repository=$PWD/some_repo -yd A + atf_check_equal $? 0 + + cd some_repo + rm -f *.xbps + xbps-create -A noarch -n A-1.0_2 -s "A pkg" --preserve ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + xbps-install -r root --repository=$PWD/some_repo -yd A + atf_check_equal $? 0 + + rv=0 + [ -e root/1.0/blah -a -e root/1.0/blah ] || rv=1 + atf_check_equal $rv 0 + + xbps-pkgdb -r root -av + atf_check_equal $? 0 +} + +atf_init_test_cases() { + atf_add_test_case preserve_update + atf_add_test_case preserve_update_conflict +}