tests: add some replace tests for transitional packages

This commit is contained in:
Duncan Overbruck 2021-03-14 17:21:55 +01:00
parent b1dfdfce25
commit d992fd1617
No known key found for this signature in database
GPG Key ID: 335C1D17EC3D6E35

View File

@ -274,6 +274,325 @@ replace_vpkg_with_update_body() {
atf_check_equal $(xbps-query -C xbps.d -r root -p state B) installed
}
atf_test_case replace_transitional_pkg
replace_transitional_pkg_head() {
atf_set "descr" "Tests for package replace: replace transitional package"
}
replace_transitional_pkg_body() {
mkdir some_repo root
mkdir -p pkg_A/usr/bin pkg_B/usr/bin empty
echo "A-1.0_1" > pkg_A/usr/bin/foo
echo "B-1.0_1" > pkg_B/usr/bin/foo
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.0_1 -s "B pkg" ../pkg_B
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd B
atf_check_equal $? 0
cd some_repo
xbps-create -A noarch -n A-1.1_1 -s "A pkg" --replaces "B>=0" --provides "B-1.0_1" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.1_1 -s "B pkg - transitional dummy package" --dependencies="A>=0" ../empty
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -ydu
atf_check_equal $? 0
result=$(xbps-query -r root -l | wc -l)
atf_check_equal $result 1
atf_check_equal $(xbps-query -C xbps.d -r root -p state A) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install A) ""
}
atf_test_case replace_transitional_pkg_automatically_installed
replace_transitional_pkg_automatically_installed_head() {
atf_set "descr" "Tests for package replace: update two packages, one gets replaced by the other"
}
replace_transitional_pkg_automatically_installed_body() {
mkdir some_repo root
mkdir -p pkg_A/usr/bin pkg_B/usr/bin empty
echo "A-1.0_1" > pkg_A/usr/bin/foo
echo "B-1.0_1" > pkg_B/usr/bin/bar
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.0_1 -s "B pkg" ../pkg_B
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd --automatic A
atf_check_equal $? 0
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd B
atf_check_equal $? 0
cd some_repo
xbps-create -A noarch -n A-1.1_1 -s "A pkg" --replaces "B>=0" --provides "B-1.0_1" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.1_1 -s "B pkg - transitional dummy package" --dependencies="A>=0" ../empty
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -ydu
atf_check_equal $? 0
result=$(xbps-query -r root -l | wc -l)
atf_check_equal $result 1
atf_check_equal $(xbps-query -C xbps.d -r root -p state A) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install A) ""
}
atf_test_case replace_transitional_pkg_automatically_installed2
replace_transitional_pkg_automatically_installed2_head() {
atf_set "descr" "Tests for package replace: update two packages, one gets replaced by the other"
}
replace_transitional_pkg_automatically_installed2_body() {
mkdir some_repo root
mkdir -p pkg_A/usr/bin pkg_B/usr/bin empty
echo "A-1.0_1" > pkg_A/usr/bin/foo
echo "B-1.0_1" > pkg_B/usr/bin/bar
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.0_1 -s "B pkg" ../pkg_B
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd --automatic A B
atf_check_equal $? 0
cd some_repo
xbps-create -A noarch -n A-1.1_1 -s "A pkg" --replaces "B>=0" --provides "B-1.0_1" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.1_1 -s "B pkg - transitional dummy package" --dependencies="A>=0" ../empty
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -ydu
atf_check_equal $? 0
result=$(xbps-query -r root -l | wc -l)
atf_check_equal $result 1
atf_check_equal $(xbps-query -C xbps.d -r root -p state A) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install A) "yes"
}
atf_test_case replace_transitional_pkg_automatically_installed3
replace_transitional_pkg_automatically_installed3_head() {
atf_set "descr" "Tests for package replace: update two packages, one gets replaced by the other"
}
replace_transitional_pkg_automatically_installed3_body() {
mkdir some_repo root
mkdir -p pkg_A/usr/bin pkg_B/usr/bin empty
echo "A-1.0_1" > pkg_A/usr/bin/foo
echo "B-1.0_1" > pkg_B/usr/bin/bar
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.0_1 -s "B pkg" ../pkg_B
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd --automatic B
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd A
atf_check_equal $? 0
cd some_repo
xbps-create -A noarch -n A-1.1_1 -s "A pkg" --replaces "B>=0" --provides "B-1.0_1" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.1_1 -s "B pkg - transitional dummy package" --dependencies="A>=0" ../empty
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -ydu
atf_check_equal $? 0
result=$(xbps-query -r root -l | wc -l)
atf_check_equal $result 1
atf_check_equal $(xbps-query -C xbps.d -r root -p state A) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install A) ""
}
atf_test_case replace_automatically_installed_dep
replace_automatically_installed_dep_head() {
atf_set "descr" "Tests for package replace: update two packages, one gets replaced by the other"
}
replace_automatically_installed_dep_body() {
mkdir some_repo root
mkdir -p pkg_A/usr/bin pkg_B/usr/bin pkg_C/usr/bin empty
echo "A-1.0_1" > pkg_A/usr/bin/a
echo "B-1.0_1" > pkg_B/usr/bin/b
echo "C-1.0_1" > pkg_C/usr/bin/c
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" --dependencies="B>=0 C>=0" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.0_1 -s "B pkg" ../pkg_B
atf_check_equal $? 0
xbps-create -A noarch -n C-1.0_1 -s "C pkg" ../pkg_C
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd A
atf_check_equal $? 0
cd some_repo
xbps-create -A noarch -n A-1.1_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.1_1 -s "B pkg" --replaces "C>=0" --provides "C-1.0_1" ../pkg_B
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -ydu
atf_check_equal $? 0
result=$(xbps-query -r root -l | wc -l)
atf_check_equal $result 2
atf_check_equal $(xbps-query -C xbps.d -r root -p state A) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p state B) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install A) ""
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install B) "yes"
}
atf_test_case replace_automatically_installed_dep3
replace_automatically_installed_dep3_head() {
atf_set "descr" "Tests for package replace: update two packages, one gets replaced by the other"
}
replace_automatically_installed_dep3_body() {
mkdir some_repo root
mkdir -p pkg_A/usr/bin pkg_B/usr/bin pkg_C/usr/bin empty
echo "A-1.0_1" > pkg_A/usr/bin/a
echo "B-1.0_1" > pkg_B/usr/bin/b
echo "C-1.0_1" > pkg_C/usr/bin/c
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" --dependencies="B>=0 C>=0" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.0_1 -s "B pkg" ../pkg_B
atf_check_equal $? 0
xbps-create -A noarch -n C-1.0_1 -s "C pkg" ../pkg_C
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
a2tf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd A C
atf_check_equal $? 0
cd some_repo
xbps-create -A noarch -n A-1.1_1 -s "A pkg" --dependencies="B>=0" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.1_1 -s "B pkg" --replaces "C>=0" --provides "C-1.0_1" ../pkg_B
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -ydu
atf_check_equal $? 0
result=$(xbps-query -r root -l | wc -l)
atf_check_equal $result 2
atf_check_equal $(xbps-query -C xbps.d -r root -p state A) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p state B) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install A) ""
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install B) ""
}
atf_test_case replace_automatically_installed_dep2
replace_automatically_installed_dep2_head() {
atf_set "descr" "Tests for package replace: update two packages, one gets replaced by the other"
}
replace_automatically_installed_dep2_body() {
mkdir some_repo root
mkdir -p pkg_A/usr/bin pkg_B/usr/bin pkg_C/usr/bin empty
echo "A-1.0_1" > pkg_A/usr/bin/a
echo "B-1.0_1" > pkg_B/usr/bin/b
echo "C-1.0_1" > pkg_C/usr/bin/c
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" --dependencies="B>=0 C>=0" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.0_1 -s "B pkg" ../pkg_B
atf_check_equal $? 0
xbps-create -A noarch -n C-1.0_1 -s "C pkg" ../pkg_C
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd A C
atf_check_equal $? 0
cd some_repo
xbps-create -A noarch -n A-1.1_1 -s "A pkg" --dependencies="B>=0" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.1_1 -s "B pkg" --replaces "C>=0" --provides "C-1.0_1" ../pkg_B
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -ydu
atf_check_equal $? 0
result=$(xbps-query -r root -l | wc -l)
atf_check_equal $result 2
atf_check_equal $(xbps-query -C xbps.d -r root -p state A) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p state B) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install A) ""
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install B) ""
}
atf_test_case replace_automatically_installed_dep3
replace_automatically_installed_dep3_head() {
atf_set "descr" "Tests for package replace: update two packages, one gets replaced by the other"
}
replace_automatically_installed_dep3_body() {
mkdir some_repo root
mkdir -p pkg_A/usr/bin pkg_B/usr/bin pkg_C/usr/bin empty
echo "A-1.0_1" > pkg_A/usr/bin/a
echo "B-1.0_1" > pkg_B/usr/bin/b
echo "C-1.0_1" > pkg_C/usr/bin/c
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" --dependencies="B>=0 C>=0" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.0_1 -s "B pkg" ../pkg_B
atf_check_equal $? 0
xbps-create -A noarch -n C-1.0_1 -s "C pkg" ../pkg_C
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd A
atf_check_equal $? 0
cd some_repo
xbps-create -A noarch -n A-1.1_1 -s "A pkg" --dependencies="B>=0" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.1_1 -s "B pkg" --replaces "C>=0" --provides "C-1.0_1" ../pkg_B
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -ydu
atf_check_equal $? 0
result=$(xbps-query -r root -l | wc -l)
atf_check_equal $result 2
atf_check_equal $(xbps-query -C xbps.d -r root -p state A) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p state B) installed
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install A) ""
atf_check_equal $(xbps-query -C xbps.d -r root -p automatic-install B) "yes"
}
atf_init_test_cases() {
atf_add_test_case replace_dups
atf_add_test_case replace_ntimes
@ -281,6 +600,13 @@ atf_init_test_cases() {
atf_add_test_case replace_pkg_files
atf_add_test_case replace_pkg_files_unmodified
atf_add_test_case replace_pkg_with_update
atf_add_test_case replace_vpkg_with_update
atf_add_test_case self_replace
atf_add_test_case replace_vpkg_with_update
atf_add_test_case replace_transitional_pkg
atf_add_test_case replace_transitional_pkg_automatically_installed
atf_add_test_case replace_transitional_pkg_automatically_installed2
atf_add_test_case replace_transitional_pkg_automatically_installed3
atf_add_test_case replace_automatically_installed_dep
atf_add_test_case replace_automatically_installed_dep2
atf_add_test_case replace_automatically_installed_dep3
}