poldek: poldek/tests/test_patch.sh (NEW), poldek/tests/Makefile.am...
mis
mis at pld-linux.org
Fri Jun 22 12:28:25 CEST 2007
Author: mis Date: Fri Jun 22 10:28:25 2007 GMT
Module: poldek Tag: HEAD
---- Log message:
- synced with current API
- moved test_patch.sh
---- Files affected:
poldek/poldek/tests:
test_patch.sh (NONE -> 1.1) (NEW), Makefile.am (1.7 -> 1.8) , test_match.c (1.3 -> 1.4) , utest_mkidx.sh (1.1 -> 1.2)
---- Diffs:
================================================================
Index: poldek/poldek/tests/test_patch.sh
diff -u /dev/null poldek/poldek/tests/test_patch.sh:1.1
--- /dev/null Fri Jun 22 12:28:25 2007
+++ poldek/poldek/tests/test_patch.sh Fri Jun 22 12:28:20 2007
@@ -0,0 +1,171 @@
+#! /bin/sh
+
+POLDEK_TESTING=1
+export POLDEK_TESTING
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -t )
+ shift; ST=$1; shift ;;
+
+ --distdir )
+ shift; DISTDIR="$1"; shift;;
+
+ --sdir )
+ shift; SRCDIR="$1"; shift;;
+
+ --surl )
+ shift; SRCURL="$1"; shift;;
+
+ --poldek )
+ shift; POLDEK="$1"; shift;;
+
+ --poldekup )
+ shift; POLDEKUP="$1"; shift;;
+
+ *) echo "$1: nknown option"; exit 1; shift ;;
+ esac
+done
+
+ST=${ST:-"pndir"}
+
+if [ -z "$DISTDIR" -o -z "$SRCDIR" -o -z "$SRCURL" ]; then
+ echo "Usage: $(basename $0): [-t INDEXTYPE] --distdir DISTDIR --sdir SRCDIR --surl SRCURL [--poldek POLDEKBIN]"
+ echo "poldek diff/patch tester, script performs:
+
+while true do
+ copy/remove random packages from DISTDIR to SRCDIR
+ poldek -s SRCDIR --mkidx
+ poldek -s SRCURL --up
+done
+
+SRCURL is a remotely accessible SRCDIR of course.
+Example:
+$ test_patch.sh --distdir /cdrom/PLD/RPMS --srcdir=/srv/www/html/rpms --srcurl=http://localhost/html/rpms \\
+ --poldek=~/poldek/cli/poldek
+"
+ exit 1;
+fi
+
+TMPDIR=${TMPDIR:-"/tmp"}
+POLDEK=${POLDEK:-"poldek"}
+[ -z "$POLDEKUP" ] && POLDEKUP="$POLDEK"
+
+echo "Using poldek=$POLDEK, poldekup=$POLDEKUP"
+
+POLDEK018=
+if $POLDEK --noconf --version | grep -q 0.18; then
+ POLDEK018="1"
+fi
+
+POLDEKUP018=
+if $POLDEKUP --noconf --version | grep -q 0.18; then
+ POLDEKUP018="1"
+fi
+
+
+create_index()
+{
+ if [ -n "$POLDEK018" ]; then
+ $POLDEK --noconf -s $SRCDIR --mkidxz
+ else
+ $POLDEK --noconf -s $SRCDIR --mkidx --mt $ST
+ fi
+}
+
+update_index()
+{
+ if [ -n "$POLDEKUP018" ]; then
+ $POLDEKUP --noconf -s $SRCURL --up
+ else
+ $POLDEKUP --noconf --st $ST -s $SRCURL --up -Oautoupa=n
+ fi
+}
+
+
+test_loop()
+{
+ echo -e "\n**** Changing repo"
+
+ nchanges=0
+ nremoved=0
+ nadded=0
+ while [ "$nchanges" = "0" ]; do
+ up_skip=$(perl -e 'print int(rand(2))');
+ toadd=$(perl -e 'print chr(65 + rand(50))');
+ torm=$(perl -e 'print chr(65 + rand(50))');
+ while [ "$toadd" == "$torm" ]; do
+ torm=$(perl -e 'print chr(65 + rand(56))');
+ done
+
+ echo "- adding $toadd\*, removing $torm\*";
+
+
+ for i in $SRCDIR/${torm}*.rpm; do
+ bn=$(basename $i);
+
+ if [ ! -f $i ]; then
+ continue
+ fi
+ rm -f $i
+ nremoved=$(expr $nremoved + 1)
+ done
+
+ for i in $DISTDIR/${toadd}*.rpm; do
+ bn=$(basename $i);
+
+ if [ ! -f $i ]; then
+ continue
+ fi
+
+ if [ -f $SRCDIR/$bn ]; then
+ continue
+ fi
+ nadded=$(expr $n + 1)
+ #echo "ADD $bn"
+ ln -sf $i $SRCDIR/$bn
+ done
+ nchanges=$(expr $nchanges + $nadded + $nremoved)
+ done
+
+ if [ "$nadded" = "0" -a "$nremoved" = "0" ]; then
+ return
+ fi
+
+ echo "Added $nadded and $nremoved removed"
+ echo -e "\n**** Creating index"
+
+ create_index
+
+ if [ $? -ne 0 ]; then
+ echo "MKIDX ERRROR"
+ exit 1;
+ fi
+
+ #up_skip=0
+ if [ ${up_skip} = "0" ]; then
+ echo -e "\n**** Updating on client side"
+ update_index
+
+ if [ $? -ne 0 ]; then
+ echo "ERRROR"
+ exit 1;
+ fi
+ fi
+}
+
+rm -f $SRCDIR/packages.$ST.*
+rm -f $SRCDIR/packages.i/packages.$ST.*
+create_index || exit 1
+
+if [ -n "$POLDEKUP018" ]; then
+ $POLDEKUP --noconf -s $SRCURL --upa
+else
+ $POLDEKUP --noconf --st $ST -s $SRCURL --upa -Oautoupa=n
+fi
+
+for n in $(seq 1 22000); do
+ test_loop
+ sleep 1
+done
+
================================================================
Index: poldek/poldek/tests/Makefile.am
diff -u poldek/poldek/tests/Makefile.am:1.7 poldek/poldek/tests/Makefile.am:1.8
--- poldek/poldek/tests/Makefile.am:1.7 Sat Jun 16 18:27:22 2007
+++ poldek/poldek/tests/Makefile.am Fri Jun 22 12:28:20 2007
@@ -5,7 +5,7 @@
test_poldek_SOURCES = test_poldek.c test_match.c test_env.c \
test_pmdb.c test_op.c test_config.c test.h
-EXTRA_DIST = utest_mkidx.sh httpd.py
+EXTRA_DIST = utest_mkidx.sh httpd.py test_patch.sh
test_poldek_INCLUDES= @CHECK_CFLAGS@
test_poldek_LDADD = @CHECK_LIBS@ ../libpoldek_allsym.la ../vfile/libvfile.la
================================================================
Index: poldek/poldek/tests/test_match.c
diff -u poldek/poldek/tests/test_match.c:1.3 poldek/poldek/tests/test_match.c:1.4
--- poldek/poldek/tests/test_match.c:1.3 Sun Oct 23 10:23:25 2005
+++ poldek/poldek/tests/test_match.c Fri Jun 22 12:28:20 2007
@@ -65,7 +65,7 @@
return -1;
pkg = pkg_new("poo", epoch, ver, rel, NULL, NULL);
- req = capreq_new_evr("poo", n_strdup(evr), relation, 0);
+ req = capreq_new_evr(NULL, "poo", n_strdup(evr), relation, 0);
rc = pkg_xmatch_req(pkg, req, maflags) ? 1 : 0;
msgn_i(1, 2, "%s match%s %s => %s", pkg_evr_snprintf_s(pkg),
@@ -88,11 +88,11 @@
int rc;
if (capevr)
- cap = capreq_new_evr("coo", n_strdup(capevr), REL_EQ, 0);
+ cap = capreq_new_evr(NULL, "coo", n_strdup(capevr), REL_EQ, 0);
else
cap = capreq_new(NULL, "coo", 0, NULL, NULL, 0, 0);
- req = capreq_new_evr("coo", n_strdup(evr), relation, 0);
+ req = capreq_new_evr(NULL, "coo", n_strdup(evr), relation, 0);
rc = cap_xmatch_req(cap, req, maflags) ? 1 : 0;
msgn_i(1, 2, "%s match%s %s => %s", capreq_snprintf_s(cap),
================================================================
Index: poldek/poldek/tests/utest_mkidx.sh
diff -u poldek/poldek/tests/utest_mkidx.sh:1.1 poldek/poldek/tests/utest_mkidx.sh:1.2
--- poldek/poldek/tests/utest_mkidx.sh:1.1 Thu Oct 27 00:34:11 2005
+++ poldek/poldek/tests/utest_mkidx.sh Fri Jun 22 12:28:20 2007
@@ -184,7 +184,7 @@
exit1 "test_g6: mkidx failed"
# run httpd
- ./httpd.py >/dev/null 2>/dev/null &
+ python httpd.py >/dev/null 2>/dev/null &
POLDEK_NOCONF="$POLDEK_NOCONF -Ovfile_retries=1"
$POLDEK_NOCONF --st pndir -s http://localhost:10000/repo/ --mkidx=$TMP
================================================================
---- CVS-web:
http://cvs.pld-linux.org/poldek/poldek/tests/Makefile.am?r1=1.7&r2=1.8&f=u
http://cvs.pld-linux.org/poldek/poldek/tests/test_match.c?r1=1.3&r2=1.4&f=u
http://cvs.pld-linux.org/poldek/poldek/tests/utest_mkidx.sh?r1=1.1&r2=1.2&f=u
More information about the pld-cvs-commit
mailing list