Skip to content

Commit

Permalink
tests: move the repository stage into the repodata file
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncaen committed Oct 28, 2023
1 parent e0460e6 commit f49235c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 43 deletions.
59 changes: 24 additions & 35 deletions tests/xbps/xbps-rindex/add_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,13 @@ revert_body() {
mkdir -p some_repo pkg_A
touch pkg_A/file00
cd some_repo
xbps-create -A noarch -n foo-1.1_1 -s "foo pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
xbps-create -A noarch -n foo-1.0_1 -r "1.1_1" -s "foo pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
atf_check -o ignore -e ignore -- xbps-create -A noarch -n foo-1.1_1 -s "foo pkg" ../pkg_A
atf_check -o ignore -e ignore -- xbps-rindex -d -a $PWD/*.xbps
atf_check -o ignore -e ignore -- xbps-create -A noarch -n foo-1.0_1 -r "1.1_1" -s "foo pkg" ../pkg_A
atf_check -o ignore -e ignore -- xbps-rindex -d -a $PWD/*.xbps
cd ..
result="$(xbps-query -r root -C empty.conf --repository=some_repo -s '')"
expected="[-] foo-1.0_1 foo pkg"
rv=0
if [ "$result" != "$expected" ]; then
echo "result: $result"
echo "expected: $expected"
rv=1
fi
atf_check_equal $rv 0
atf_check -o "inline:[-] foo-1.0_1 foo pkg\n" -e empty -- \
xbps-query -r root -C empty.conf --repository=some_repo -Rs ''
}

atf_test_case stage
Expand All @@ -76,36 +65,36 @@ stage_body() {
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 1
atf_check -o inline:" 1 $PWD (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L

xbps-create -A noarch -n foo-1.1_1 -s "foo pkg" --shlib-provides "libfoo.so.2" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 1
atf_check -o inline:" 1 $PWD (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L

xbps-create -A noarch -n bar-1.0_1 -s "foo pkg" --shlib-requires "libfoo.so.2" ../pkg_B
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 1
atf_check -o inline:" 2 $PWD (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L

xbps-create -A noarch -n foo-1.2_1 -s "foo pkg" --shlib-provides "libfoo.so.3" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 0
atf_check -o inline:" 2 $PWD (Staged) (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L

xbps-create -A noarch -n bar-1.1_1 -s "foo pkg" --shlib-requires "libfoo.so.3" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 1
atf_check -o inline:" 2 $PWD (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L
}

atf_test_case stage_resolve_bug
Expand Down Expand Up @@ -136,25 +125,25 @@ stage_resolve_bug_body() {
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 1
atf_check -o inline:" 4 $PWD (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L

# 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
atf_check -o inline:" 4 $PWD (Staged) (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L

# 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
atf_check -o inline:" 4 $PWD (Staged) (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L

# resolve staging
# the actual bug appeared here: libfoo.so.1 is still provided by libprovider, but
Expand All @@ -163,8 +152,8 @@ stage_resolve_bug_body() {
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 1
atf_check -o inline:" 4 $PWD (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L
}

atf_init_test_cases() {
Expand Down
10 changes: 5 additions & 5 deletions tests/xbps/xbps-rindex/clean_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ remove_from_stage_body() {
xbps-create -A noarch -n foo-1.1_1 -s "foo pkg" --shlib-provides "foo.so.2" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check -o inline:" 2 $PWD (Staged) (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L
atf_check_equal $? 0
rm foo-1.1_1*
xbps-rindex -c .
atf_check -o inline:" 1 $PWD (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L
cd ..
xbps-rindex -c some_repo
[ -f *-stagedata ]
atf_check_equal $? 1
}

atf_init_test_cases() {
Expand Down
5 changes: 2 additions & 3 deletions tests/xbps/xbps-rindex/remove_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ noremove_stage_body() {
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
[ -f *-stagedata ]
atf_check_equal $? 0
atf_check -o inline:" 2 $PWD (Staged) (RSA unsigned)\n" -- \
xbps-query -r ../root -i --repository=$PWD -L
xbps-rindex -r some_repo
atf_check_equal $? 0
cd some_repo
[ -f foo-1.0_1* ]
atf_check_equal $? 0
[ -f foo-1.1_1* ]
Expand Down

0 comments on commit f49235c

Please sign in to comment.