From e48a2d422a6989fc2a03f7847db6cf90f9a54ecf Mon Sep 17 00:00:00 2001 From: mis Date: Thu, 9 Apr 2020 14:58:18 +0200 Subject: [PATCH] tests: fixed up-loop test --- tests/run-sh-tests.sh | 2 +- tests/sh/03-up-loop | 9 +++++++++ tests/sh/lib/repo-setup | 27 ++++++++++++++++++--------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/tests/run-sh-tests.sh b/tests/run-sh-tests.sh index d2a85e6..200c1b3 100755 --- a/tests/run-sh-tests.sh +++ b/tests/run-sh-tests.sh @@ -37,7 +37,7 @@ for i in sh/[0-9][0-9]*; do [ -n "$suffixed" ] && suffix=" (compr=$c)" nth=$(expr $nth + 1) - sh $i -n 4 >> $LOG + sh $i -n 6 >> $LOG if [ $? -eq 0 ]; then nok=$(expr $nok + 1) echo "${GREEN}PASS: $i$suffix$NC" diff --git a/tests/sh/03-up-loop b/tests/sh/03-up-loop index 669c2f2..b4c6de1 100755 --- a/tests/sh/03-up-loop +++ b/tests/sh/03-up-loop @@ -41,6 +41,15 @@ testUpLoop() msg "\n## up" up + # init repo with some packages + n=0 + for i in $SOURCE_REPO/*.rpm; do + bn=$(basename $i) + ln -sf $i $REPO/$bn + n=$(expr $n + 1) + [ $n -gt 4 ] && break + done + nloop=0 maxloop=${MAXLOOP:-"60"} force_msg "# testing in $maxloop iterations" diff --git a/tests/sh/lib/repo-setup b/tests/sh/lib/repo-setup index 279fe9a..c391875 100644 --- a/tests/sh/lib/repo-setup +++ b/tests/sh/lib/repo-setup @@ -18,11 +18,11 @@ abort() { build_repo_packages() { local n=$(find $SOURCE_REPO/ -name \*.rpm | wc -l) if [ $n -lt 20 ]; then - for i in a b c d e f g h i j k l m n o p r s t u w x y z; do rpm="$i-1-1.noarch.rpm" [ -f "$SOURCE_REPO/$rpm" ] && continue ./build-test-rpm.sh -d $SOURCE_REPO/ -n $i -v 1 >/dev/null 2>&1 || abort "build package $i failed" + ./build-test-rpm.sh -d $SOURCE_REPO/ -n "$i$i" -v 1 >/dev/null 2>&1 || abort "build package $i failed" done fi } @@ -179,20 +179,27 @@ remove_package_from_repo() { msg "removed $(basename $package)" } +random_package() { + perl -e '@s=(a..z); print $s[rand(@s)]' +} random_change_repo() { - to_add=$(perl -e '@s=(a..z, A..Z, 0..9); print $s[rand(@s)]') - to_del=$(perl -e '@s=(a..z, A..Z, 0..9); print $s[rand(@s)]') + to_add=$(random_package) + to_del=$(random_package) - while [ "$to_add" == "$to_del" ]; do - to_del=$(perl -e '@s=(a..z, A..Z, 0..9); print $s[rand(@s)]') + while [ -f $REPO/$to_add-*.rpm ]; do + to_add=$(random_package) done - #echo "- adding $to_add\*, removing $to_del\*"; + if [ ! -f $REPO/$to_del-*.rpm ]; then + to_del=$(random_package) + fi + + [ "$to_add" == "$to_del" ] && to_del="none" + msg "adding $to_add, removing $to_del"; nadded=0 nremoved=0 - for i in $SOURCE_REPO/${to_add}*.rpm; do bn=$(basename $i); @@ -212,10 +219,12 @@ random_change_repo() { rm -f $i nremoved=$(expr $nremoved + 1) done - - nchanges=$(expr $nadded + $nremoved) [ "$nchanges" = "0" ] && random_change_repo + # avoid empty repo + n=$(ls $REPO/*.rpm | wc -l) + [ "$n" = "0" ] && random_change_repo + #msg "Added $nadded and $nremoved removed" }