Commit 6aa6c04 update test with changes from Martin Cermak

2 files Authored and Committed by mgahagan a year ago
update test with changes from Martin Cermak
 - run tests as user rather than root

    
 1 @@ -53,8 +53,7 @@
 2   »       @echo "Type:            Regression" >> $(METADATA)
 3   »       @echo "TestTime:        30m" >> $(METADATA)
 4   »       @echo "RunFor:          byacc" >> $(METADATA)
 5 - »       @echo "Requires:        byacc gcc glibc-devel glibc-headers make sed rpm-build" >> $(METADATA)
 6 - »       @echo "Requires:        yum-utils wget" >> $(METADATA)
 7 + »       @echo "Requires:        byacc gcc glibc-devel glibc-headers make sed rpm-build yum-utils" >> $(METADATA)
 8   »       @echo "Priority:        Normal" >> $(METADATA)
 9   »       @echo "License:         GPLv2+" >> $(METADATA)
10   »       @echo "Confidential:    no" >> $(METADATA)
  1 @@ -31,79 +31,48 @@
  2   
  3   PACKAGE="byacc"
  4   REQUIRES="byacc gcc glibc-devel glibc-headers make sed rpm-build"
  5 - myARCH=$(uname -m)
  6 + MY_USER="byacctestuser"
  7 + DOTEST=$(mktemp)
  8   
  9 - function redhat_release()
 10 - {
 11 -     # Extract the first unbroken sequence of digits. So:
 12 -     # "Red Hat Enterprise Linux Server release 7.0 Beta (Maipo)" => '7'
 13 -     cat /etc/redhat-release | sed 's/^[^0-9]\+\([0-9]\+\).*/\1/'
 14 - }
 15 + cat > $DOTEST <<-EOF
 16 + #!/bin/bash
 17 + set -xe
 18 + _BASEDIR=\$1
 19 + _TMP=\$(mktemp -d)
 20 + rpm --define="_topdir \$_TMP" -Uvh \$_BASEDIR/byacc*.src.rpm
 21 + rpmbuild --define="_topdir \$_TMP" -bc \$_TMP/SPECS/byacc.spec
 22 + pushd \$_TMP/BUILD/byacc-*
 23 + # In case the test fails, the existcode of make check is non-zero.
 24 + # In such case this script fails too because of set -e above.
 25 + make check
 26 + popd
 27 + set -xe
 28 + EOF
 29   
 30   rlJournalStart
 31       rlPhaseStartSetup
 32 + »       rlRun "useradd $MY_USER" 0,9
 33 + »       rlRun "chown $MY_USER:$MY_USER $DOTEST"
 34           rlAssertRpm --all
 35 -         rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
 36 -         rlRun "pushd $TmpDir"
 37 - 
 38 -         # Get rid of any existing builds
 39 -         BUILDDIR="$(rpm -E '%{_builddir}')"
 40 -         SPECDIR="$(rpm -E '%{_specdir}')"
 41 -         rlRun "rm -rf $BUILDDIR/byacc*"
 42 -         rlRun "rm -rf $SPECDIR/byacc*.spec"
 43 - 
 44 -         # Download byacc srpm into current directory
 45 -         rlFetchSrcForInstalled byacc || yumdownloader --source byacc
 46 -         rlRun "ls byacc*.src.rpm" # rlAssertExists doesn't accept wildcards
 47 - 
 48 -         # Extract into /root/rpmbuild/
 49 -         rlRun "rpm -Uv --replacepkgs byacc*.src.rpm"
 50 -         rlAssertExists $SPECDIR/byacc.spec
 51 - 
 52 +         rlRun "TMP=\$(mktemp -d)"
 53 + »       rlRun "chmod a+rx $TMP"
 54 +         rlRun "pushd $TMP"
 55 + »       if rlIsRHEL; then
 56 + »           rlFetchSrcForInstalled $PACKAGE
 57 + »       else
 58 + »           yumdownloader --source $PACKAGE
 59 + »       fi
 60 + »       rlRun "chmod a+r byacc*.src.rpm"
 61       rlPhaseEnd
 62   
 63       rlPhaseStartTest
 64 -         BYACC_BUILD_LOG=$(pwd)/byacc-rpmbuild.log
 65 - 
 66 -         rlRun "rpmbuild -bc $SPECDIR/byacc.spec --target=$myARCH &> $BYACC_BUILD_LOG"
 67 -         rlFileSubmit $BYACC_BUILD_LOG "byacc-rpmbuild.log"
 68 - 
 69 -         rlRun "ls $BUILDDIR | grep byacc"
 70 -         BUILD_SUBDIR="$BUILDDIR/$(ls $BUILDDIR | grep byacc)"
 71 -         rlRun "pushd $BUILD_SUBDIR"
 72 - 
 73 -         CHECK_LOG=$(pwd)/check.log
 74 -         rlRun "make -k check &> $CHECK_LOG"
 75 -         rlFileSubmit $CHECK_LOG "byacc-check.log"
 76 - 
 77 -         RH_REL=$(redhat_release)
 78 - 
 79 -         if [ "$RH_REL" == "6" ]; then
 80 -             # There are fewer tests and some failures in RHEL-6
 81 -             rlAssertGreaterOrEqual "At least 8 OK tests" "$(cat $CHECK_LOG | grep '^\.\.\.ok' | wc -l)" "8"
 82 -             rlAssertGreaterOrEqual "At most 4 FAIL tests" "4" "$(cat $CHECK_LOG | grep '^\.\.\.' | grep -v '^\.\.\.ok' | wc -l)"
 83 -         else
 84 -             # RHEL-7 and up (of course, if we run this on RHEL-5, this bit
 85 -             # will run, and FAIL miserably, but we don't care about RHEL-5
 86 -             rlAssertGreaterOrEqual "At least 59 OK tests" "$(cat $CHECK_LOG | grep '^\.\.\.ok' | wc -l)" "59"
 87 -             rlAssertEquals "No FAIL tests" "$(cat $CHECK_LOG | grep '^\.\.\.' | grep -v '^\.\.\.ok' | wc -l)" "0"
 88 -         fi
 89 - 
 90 -         rlRun "popd"
 91 + »       rlRun "su - $MY_USER -c 'bash $DOTEST $(pwd)'"
 92       rlPhaseEnd
 93   
 94       rlPhaseStartCleanup
 95 -         if [ -n "$KEEP_BYACC_RESULTS" ]; then
 96 -             rlLog "Build Directory at: $(ls $BUILDDIR)"
 97 -             rlLog "Spec File at: $(ls $SPECDIR/byacc*.spec)"
 98 -             rlRun "popd"
 99 -         else
100 -             rlRun "rm byacc*.src.rpm"
101 -             rlRun "rm -rf $BUILDDIR/byacc* $SPECDIR/byacc*.spec"
102 -             rlRun "ls"
103 -             rlRun "popd"
104 -             rlRun "rm -r $TmpDir"
105 -         fi
106 + »       rlRun "popd"
107 + »       rlRun "rm -rf $TMP $DOTEST"
108 + »       rlRun "userdel -f $MY_USER"
109       rlPhaseEnd
110   rlJournalPrintText
111   rlJournalEnd