xbps-rindex: add test to trigger stage deadlock

This commit is contained in:
Enno Boland 2018-06-28 13:05:47 +02:00
parent daa1b44682
commit 219f6c2310

View File

@ -108,9 +108,68 @@ stage_body() {
atf_check_equal $? 1
}
atf_test_case stage_resolve_bug
stage_resolve_bug_head() {
atf_set "descr" "xbps-rindex(8) -a: commit package to stage test"
}
stage_resolve_bug_body() {
# Scanario: provides a shlib, then it is moved (for example for splitting the
# pkg) to libprovider. afterwards requirer is added resulting in
mkdir provider libprovider requirer stage-trigger some_repo
touch provider/1 libprovider/2 requirer/3 stage-trigger/4
cd some_repo
# first add the provider and the requirer to the repo
xbps-create -A noarch -n provider-1.0_1 -s "foo pkg" --shlib-provides "libfoo.so.1 libbar.so.1" ../provider
atf_check_equal $? 0
xbps-create -A noarch -n require-1.0_1 -s "foo pkg" --shlib-requires "libfoo.so.1" ../requirer
atf_check_equal $? 0
xbps-create -A noarch -n stage-trigger-1.0_1 -s "foo pkg" --shlib-requires "libbar.so.1" ../stage-trigger
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
# then add libprovider that also provides the library
xbps-create -A noarch -n libprovider-1.0_2 -s "foo pkg" --shlib-provides "libfoo.so.1" ../libprovider
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 1
# trigger staging
xbps-create -A noarch -n provider-1.0_2 -s "foo pkg" --shlib-provides "libfoo.so.1" ../provider
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 0
# then add a new provider not containing the provides field. This resulted in
# a stage state despites the library is resolved through libprovides
xbps-create -A noarch -n provider-1.0_3 -s "foo pkg" ../provider
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 0
# resolve staging
# the actual bug appeared here: libfoo.so.1 is still provided by libprovider, but
# xbps-rindex fails to register that.
xbps-create -A noarch -n stage-trigger-1.0_2 -s "foo pkg" ../stage-trigger
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 1
}
atf_init_test_cases() {
atf_add_test_case update
atf_add_test_case revert
atf_add_test_case stage
atf_add_test_case stage_resolve_bug
}