diff options
author | Clark Williams <williams@redhat.com> | 2007-12-13 17:38:52 -0600 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2007-12-13 17:38:52 -0600 |
commit | f496f29335f7b22b307c6b9173d2e31af6162fd0 (patch) | |
tree | ff92a96fadb699619568b0c3ea0368b2ffb052f4 | |
parent | 6b2d14f9afb39a955331f4a52a597b122f585166 (diff) | |
parent | 3ea2ef74a181a32583b3a35dae386a1701a5a89d (diff) | |
download | mock-f496f29335f7b22b307c6b9173d2e31af6162fd0.tar.gz mock-f496f29335f7b22b307c6b9173d2e31af6162fd0.tar.xz mock-f496f29335f7b22b307c6b9173d2e31af6162fd0.zip |
resolved merge with master
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | docs/daemontest.c | 1 | ||||
-rwxr-xr-x | docs/releasetests.sh | 164 | ||||
-rwxr-xr-x | docs/runtests.sh | 172 |
4 files changed, 178 insertions, 162 deletions
diff --git a/Makefile.am b/Makefile.am index c40f6d2..12559d3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,6 +18,9 @@ PACKAGE = $(RELEASE_NAME) CLEANFILES=mock-*.tar.gz mock-*.tar.bz2 mock-*.rpm _buildtemp version docs/daemontest DISTCLEANFILES=*~ +docs/runtests.sh: srpm +TESTS=./docs/runtests.sh + EXTRA_DIST = bin_PROGRAMS= CLEANFILES += $(EXTRA_PROGRAMS) diff --git a/docs/daemontest.c b/docs/daemontest.c index 5f63e7a..3a31825 100644 --- a/docs/daemontest.c +++ b/docs/daemontest.c @@ -98,6 +98,7 @@ int main() // run for roughly 5 mins then exit. No need to stick around if unit test fails. int i=0; for( i=0; i<300; i++ ) sleep(1); + return 0; } /* EOF */ diff --git a/docs/releasetests.sh b/docs/releasetests.sh index 55ed545..ba29c20 100755 --- a/docs/releasetests.sh +++ b/docs/releasetests.sh @@ -22,169 +22,9 @@ DIR=$(cd $(dirname $0); pwd) TOP_SRCTREE=$DIR/../ cd $TOP_SRCTREE -./autogen.sh make distclean ||: +./autogen.sh ./configure make distcheck make srpm -gcc -o docs/daemontest docs/daemontest.c - -# -# most tests below will use this mock command line -# -testConfig=fedora-8-x86_64 -uniqueext="$$-$RANDOM" -MOCKCMD="sudo ./py/mock.py --resultdir=$TOP_SRCTREE/mock-unit-test --uniqueext=$uniqueext -r $testConfig $MOCK_EXTRA_ARGS" -CHROOT=/var/lib/mock/${testConfig}-$uniqueext/root - -# clear out any old test results -sudo rm -rf $TOP_SRCTREE/mock-unit-test - -# clear out root cache so we get at least run without root cache present -sudo rm -rf /var/lib/mock/cache/${testConfig}/root_cache - -# -# pre-populate yum cache for the rest of the commands below -# -time $MOCKCMD --init -time $MOCKCMD --installdeps mock-*.src.rpm -if [ ! -e $CHROOT/usr/include/python* ]; then - echo "installdeps test FAILED. could not find /usr/include/python*" - exit 1 -fi - -# test the copyout command -time $MOCKCMD --copyout /etc/passwd /tmp/my-copyout-passwd -if [ ! -f /tmp/my-copyout-passwd ]; then - echo "copyout test FAILED! could not find /tmp/my-copyout-passwd" -fi -mkdir /tmp/$uniqueext -time $MOCKCMD --copyout /etc/passwd /etc/fstab /tmp/$uniqueext -if [ ! -f /tmp/$uniqueext/passwd -o ! -f /tmp/$uniqueext/fstab ]; then - echo "multiple copyout failed!" -fi - -# -# Test that chroot return code is properly passed up -# -set +e -time $MOCKCMD --offline --chroot -- bash -c "exit 5" -if [ $? -ne 5 ]; then - echo "'mock --chroot' return code not properly passed back." - exit 1 -fi -set -e - -# -# test mock shell (interactive) and return code passing -# -set +e -echo exit 5 | time $MOCKCMD --offline --shell -if [ $? -ne 5 ]; then - echo "'mock --chroot' return code not properly passed back." - exit 1 -fi -set -e - -# -# Test that chroot with one arg is getting passed though a shell (via os.system()) -# -time $MOCKCMD --offline --chroot 'touch /tmp/{foo,bar,baz}' -if [ ! -f $CHROOT/tmp/foo ] || [ ! -f $CHROOT/tmp/bar ] || [ ! -f $CHROOT/tmp/baz ]; then - echo "'mock --chroot' with one argument is not being passed to os.system()" - exit 1 -fi - -# -# Test that chroot with more than one arg is not getting passed through a shell -# -time $MOCKCMD --offline --chroot touch '/tmp/{quux,wibble}' -if [ ! -f $CHROOT/tmp/\{quux,wibble\} ] || [ -f $CHROOT/tmp/quux ] || [ -f $CHROOT/tmp/wibble ]; then - echo "'mock --chroot' with more than one argument is being passed to os.system()" - exit 1 -fi - -# -# Test offline build -# -time $MOCKCMD --offline --rebuild mock-*.src.rpm -if [ ! -e mock-unit-test/mock-*.x86_64.rpm ]; then - echo "rebuild test FAILED. could not find mock-unit-test/mock-*.x86_64.rpm" - exit 1 -fi - -# -# Test orphanskill feature (std) -# (also tests the --copyin feature) -# -if pgrep daemontest; then - echo "Exiting because there is already a daemontest running." - exit 1 -fi -time $MOCKCMD --offline --init -time $MOCKCMD --copyin docs/daemontest /tmp -time $MOCKCMD --offline --chroot -- /tmp/daemontest -if pgrep daemontest; then - echo "Daemontest FAILED. found a daemontest process running after exit." - exit 1 -fi - -# -# Test orphanskill feature (explicit) -# (also tests --copyin) -# -time $MOCKCMD --offline --init -time $MOCKCMD --copyin docs/daemontest /tmp -echo -e "#!/bin/sh\n/tmp/daemontest\nsleep 60\n" >> $CHROOT/tmp/try -# the following should launch about three processes in the chroot: bash, sleep, daemontest -$MOCKCMD --offline --chroot -- bash /tmp/try & -mockpid=$! -sleep 1 -# now we 'prematurely' kill mock. This should leave the three orphans above -sudo kill -9 $mockpid -if ! pgrep daemontest; then - echo "Daemontest failed. daemontest should be running now but is not." - exit 1 -fi -$MOCKCMD --offline --orphanskill -if pgrep daemontest; then - echo "Daemontest FAILED. found a daemontest process running after exit." - exit 1 -fi - - -# -# test init/clean -# -time $MOCKCMD --offline --clean -if [ -e $CHROOT ]; then - echo "clean test FAILED. still found $CHROOT dir." - exit 1 -fi - -time $MOCKCMD --offline --init -time $MOCKCMD --offline --install ccache -if [ ! -e $CHROOT/usr/bin/ccache ]; then - echo "init/clean test FAILED. ccache not found." - exit 1 -fi - -# -# test old-style cmdline options -# -time $MOCKCMD --offline clean -time $MOCKCMD --offline init -time $MOCKCMD --offline install ccache -if [ ! -e $CHROOT/usr/bin/ccache ]; then - echo "init/clean test FAILED. ccache not found." - exit 1 -fi - -# -# Test build all configs we ship. -# -for i in $(ls etc/mock | grep .cfg | grep -v default | grep -v ppc); do - time sudo ./py/mock.py --resultdir=$TOP_SRCTREE/mock-unit-test --uniqueext=$uniqueext rebuild mock-*.src.rpm -r $(basename $i .cfg) $MOCK_EXTRA_ARGS -done - - +make check diff --git a/docs/runtests.sh b/docs/runtests.sh new file mode 100755 index 0000000..66c40ff --- /dev/null +++ b/docs/runtests.sh @@ -0,0 +1,172 @@ +#!/bin/sh +# vim:tw=0:ts=4:sw=4 + +# this is a test script to run everything through its paces before you do a +# release. The basic idea is: + +# 1) make distcheck to ensure that all autoconf stuff is setup properly +# 2) run some basic tests to test different mock options. +# 3) rebuild mock srpm using this version of mock under all distributed configs + +# This test will only run on a machine with full access to internet. +# might work with http_proxy= env var, but I havent tested that. +# +# This test script expects to be run on an x86_64 machine. It will *not* run +# properly on an i386 machine. +# + +set -e +set -x + +DIR=$(cd $(dirname $0); pwd) +TOP_SRCTREE=$DIR/../ +cd $TOP_SRCTREE + +gcc -Wall -o docs/daemontest docs/daemontest.c + +# +# most tests below will use this mock command line +# +testConfig=fedora-8-x86_64 +uniqueext="$$-$RANDOM" +MOCKCMD="sudo ./py/mock.py --resultdir=$TOP_SRCTREE/mock-unit-test --uniqueext=$uniqueext -r $testConfig $MOCK_EXTRA_ARGS" +CHROOT=/var/lib/mock/${testConfig}-$uniqueext/root + +# clear out any old test results +sudo rm -rf $TOP_SRCTREE/mock-unit-test + +# clear out root cache so we get at least run without root cache present +sudo rm -rf /var/lib/mock/cache/${testConfig}/root_cache + +# +# pre-populate yum cache for the rest of the commands below +# +time $MOCKCMD --init +time $MOCKCMD --installdeps mock-*.src.rpm +if [ ! -e $CHROOT/usr/include/python* ]; then + echo "installdeps test FAILED. could not find /usr/include/python*" + exit 1 +fi + +# +# Test that chroot return code is properly passed up +# +set +e +time $MOCKCMD --offline --chroot -- bash -c "exit 5" +if [ $? -ne 5 ]; then + echo "'mock --chroot' return code not properly passed back." + exit 1 +fi +set -e + +# +# test mock shell (interactive) and return code passing +# +set +e +echo exit 5 | time $MOCKCMD --offline --shell +if [ $? -ne 5 ]; then + echo "'mock --chroot' return code not properly passed back." + exit 1 +fi +set -e + +# +# Test that chroot with one arg is getting passed though a shell (via os.system()) +# +time $MOCKCMD --offline --chroot 'touch /tmp/{foo,bar,baz}' +if [ ! -f $CHROOT/tmp/foo ] || [ ! -f $CHROOT/tmp/bar ] || [ ! -f $CHROOT/tmp/baz ]; then + echo "'mock --chroot' with one argument is not being passed to os.system()" + exit 1 +fi + +# +# Test that chroot with more than one arg is not getting passed through a shell +# +time $MOCKCMD --offline --chroot touch '/tmp/{quux,wibble}' +if [ ! -f $CHROOT/tmp/\{quux,wibble\} ] || [ -f $CHROOT/tmp/quux ] || [ -f $CHROOT/tmp/wibble ]; then + echo "'mock --chroot' with more than one argument is being passed to os.system()" + exit 1 +fi + +# +# Test offline build +# +time $MOCKCMD --offline --rebuild mock-*.src.rpm +if [ ! -e mock-unit-test/mock-*.x86_64.rpm ]; then + echo "rebuild test FAILED. could not find mock-unit-test/mock-*.x86_64.rpm" + exit 1 +fi + +# +# Test orphanskill feature (std) +# +if pgrep daemontest; then + echo "Exiting because there is already a daemontest running." + exit 1 +fi +time $MOCKCMD --offline --init +cp docs/daemontest $CHROOT/tmp +time $MOCKCMD --offline --chroot -- /tmp/daemontest +if pgrep daemontest; then + echo "Daemontest FAILED. found a daemontest process running after exit." + exit 1 +fi + +# +# Test orphanskill feature (explicit) +# +time $MOCKCMD --offline --init +cp docs/daemontest $CHROOT/tmp +echo -e "#!/bin/sh\n/tmp/daemontest\nsleep 60\n" >> $CHROOT/tmp/try +# the following should launch about three processes in the chroot: bash, sleep, daemontest +$MOCKCMD --offline --chroot -- bash /tmp/try & +mockpid=$! +sleep 1 +# now we 'prematurely' kill mock. This should leave the three orphans above +sudo kill -9 $mockpid +if ! pgrep daemontest; then + echo "Daemontest failed. daemontest should be running now but is not." + exit 1 +fi +$MOCKCMD --offline --orphanskill +if pgrep daemontest; then + echo "Daemontest FAILED. found a daemontest process running after exit." + exit 1 +fi + + +# +# test init/clean +# +time $MOCKCMD --offline --clean +if [ -e $CHROOT ]; then + echo "clean test FAILED. still found $CHROOT dir." + exit 1 +fi + +time $MOCKCMD --offline --init +time $MOCKCMD --offline --install ccache +if [ ! -e $CHROOT/usr/bin/ccache ]; then + echo "init/clean test FAILED. ccache not found." + exit 1 +fi + +# +# test old-style cmdline options +# +time $MOCKCMD --offline clean +time $MOCKCMD --offline init +time $MOCKCMD --offline install ccache +if [ ! -e $CHROOT/usr/bin/ccache ]; then + echo "init/clean test FAILED. ccache not found." + exit 1 +fi + +# +# Test build all configs we ship. +# +for i in $(ls etc/mock | grep .cfg | grep -v default | grep -v ppc); do + time sudo ./py/mock.py --resultdir=$TOP_SRCTREE/mock-unit-test --uniqueext=$uniqueext rebuild mock-*.src.rpm -r $(basename $i .cfg) $MOCK_EXTRA_ARGS +done + + |