|
|
a4cdc02 |
#!/bin/bash
|
|
|
a4cdc02 |
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
|
|
a4cdc02 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
a4cdc02 |
#
|
|
|
a4cdc02 |
# runtest.sh of /CoreOS/ruby/Regression/systemtap-static-probes-in-ruby
|
|
|
a4cdc02 |
# Description: It tests there are static probes in ruby package.
|
|
|
a4cdc02 |
# Author: Ales Marecek <amarecek@redhat.com>
|
|
|
a4cdc02 |
#
|
|
|
a4cdc02 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
a4cdc02 |
#
|
|
|
a4cdc02 |
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
|
|
|
a4cdc02 |
#
|
|
|
a4cdc02 |
# This copyrighted material is made available to anyone wishing
|
|
|
a4cdc02 |
# to use, modify, copy, or redistribute it subject to the terms
|
|
|
a4cdc02 |
# and conditions of the GNU General Public License version 2.
|
|
|
a4cdc02 |
#
|
|
|
a4cdc02 |
# This program is distributed in the hope that it will be
|
|
|
a4cdc02 |
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
a4cdc02 |
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
a4cdc02 |
# PURPOSE. See the GNU General Public License for more details.
|
|
|
a4cdc02 |
#
|
|
|
a4cdc02 |
# You should have received a copy of the GNU General Public
|
|
|
a4cdc02 |
# License along with this program; if not, write to the Free
|
|
|
a4cdc02 |
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
a4cdc02 |
# Boston, MA 02110-1301, USA.
|
|
|
a4cdc02 |
#
|
|
|
a4cdc02 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
a4cdc02 |
|
|
|
a4cdc02 |
# Include rhts environment
|
|
|
2e9ba6a |
. /usr/share/beakerlib/beakerlib.sh
|
|
|
a4cdc02 |
|
|
|
2e9ba6a |
PACKAGES=${PACKAGES:-ruby ruby-libs rubypick}
|
|
|
2e9ba6a |
# in RHEL7 and later the stap file is in ruby-doc package
|
|
|
2e9ba6a |
if [ -z "$COLLECTIONS" ]; then
|
|
|
2e9ba6a |
if rlIsRHEL '>=7' || rlIsFedora; then
|
|
|
2e9ba6a |
PACKAGES=$PACKAGES" ruby-doc"
|
|
|
2e9ba6a |
fi
|
|
|
2e9ba6a |
fi
|
|
|
a4cdc02 |
REQUIRES=${REQUIRES:-}
|
|
|
a4cdc02 |
RUBY=${RUBY:-ruby}
|
|
|
a4cdc02 |
_STAP_FILE="`rpm -ql $PACKAGES | grep 'ruby-exercise.stp' 2>/dev/null`"
|
|
|
a4cdc02 |
_LOG_FILE="ruby.log"
|
|
|
2e9ba6a |
_STAP_OUT="stap-out.log"
|
|
|
a4cdc02 |
|
|
|
a4cdc02 |
# for ruby on RHEL7 and in collections
|
|
|
a4cdc02 |
PRINT="Kernel::printf"
|
|
|
a4cdc02 |
|
|
|
a4cdc02 |
rlJournalStart
|
|
|
a4cdc02 |
rlPhaseStartSetup
|
|
|
a4cdc02 |
rlAssertRpm --all
|
|
|
a4cdc02 |
rlAssertBinaryOrigin $RUBY
|
|
|
2e9ba6a |
rlAssertExists "${_STAP_FILE}" || rlDie
|
|
|
a4cdc02 |
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
|
|
|
a4cdc02 |
rlRun "pushd ${TmpDir}"
|
|
|
a4cdc02 |
_LOG_FILE="${TmpDir}/${_LOG_FILE}"
|
|
|
a4cdc02 |
touch ${_LOG_FILE}
|
|
|
a4cdc02 |
rlPhaseEnd
|
|
|
a4cdc02 |
|
|
|
a4cdc02 |
rlPhaseStartTest
|
|
|
a4cdc02 |
# TODO: Systemtap - The test could be enlarged by other methods / functions / objects / ...
|
|
|
a4cdc02 |
rlRun "rpm -ql $PACKAGES | grep 'stp' | grep 'tapset'" 0 "Checking tapset file"
|
|
|
a4cdc02 |
rlRun "rpm -ql $PACKAGES | grep 'stp' | grep 'doc'" 0 "Checking doc file"
|
|
|
a4cdc02 |
|
|
|
2e9ba6a |
rlRun "{ stap -v ${_STAP_FILE} -o ${_LOG_FILE} |& tee ${_STAP_OUT}; } &" 0 "Running systemtap in background"
|
|
|
a4cdc02 |
_STAP_PID=$!
|
|
|
a4cdc02 |
echo -e "--_STAP_PID--\n${_STAP_PID}" # info
|
|
|
a4cdc02 |
|
|
|
2e9ba6a |
# wait for systemtap to start
|
|
|
2e9ba6a |
rlWaitForCmd "grep 'starting run' ${_STAP_OUT}"
|
|
|
a4cdc02 |
|
|
|
a4cdc02 |
rlRun "$RUBY -e '1.0 + 9.0'" 0 "Running ruby interpreter: Float test"
|
|
|
a4cdc02 |
rlRun "$RUBY -e '[1, 2, 3].push(4)'" 0 "Running ruby interpreter: Array test"
|
|
|
a4cdc02 |
rlRun "$RUBY -e '(1..10).step(1)'" 0 "Running ruby interpreter: Range test"
|
|
|
a4cdc02 |
rlRun "$RUBY -e 'Hash.new()'" 0 "Running ruby interpreter: Hash test"
|
|
|
a4cdc02 |
rlRun "$RUBY -e '\"abc\".slice!(\"c\")'" 0 "Running ruby interpreter: String test"
|
|
|
a4cdc02 |
rlRun "$RUBY -e '5.times { printf \"Ruby!\n\" }'" 0 "Running ruby interpreter: Cycle and print test"
|
|
|
a4cdc02 |
|
|
|
2e9ba6a |
# wait for all output
|
|
|
a4cdc02 |
rlRun "sleep 10" 0 "Waiting \"10\" seconds"
|
|
|
2e9ba6a |
|
|
|
a4cdc02 |
rlRun "kill ${_STAP_PID}" 0 "Terminating stap"
|
|
|
a4cdc02 |
sleep 1 # No Operation
|
|
|
2e9ba6a |
|
|
|
a4cdc02 |
echo -e "---ps-out--" && ps -e | grep stap # info
|
|
|
a4cdc02 |
rlRun "kill -s SIGKILL ${_STAP_PID}" 0,1 "Attempt killing stap"
|
|
|
2e9ba6a |
rlRun "pkill stapio" 0,1 "Attempt killing all leftover stapios"
|
|
|
a4cdc02 |
echo -e "---ps-out--" && ps -e | grep stap # info
|
|
|
a4cdc02 |
|
|
|
a4cdc02 |
echo -e "---${_LOG_FILE}--" && cat ${_LOG_FILE} # info
|
|
|
2e9ba6a |
if rlIsRHEL '<7' && [ -z "$COLLECTIONS" ]
|
|
|
a4cdc02 |
then
|
|
|
a4cdc02 |
rlRun "grep -q 'Float::+' ${_LOG_FILE}" 0 "Checking systemtap log: Float test"
|
|
|
a4cdc02 |
# for ruby on RHEL6
|
|
|
a4cdc02 |
PRINT="Object::printf"
|
|
|
a4cdc02 |
fi
|
|
|
a4cdc02 |
rlRun "grep -q 'Array::push' ${_LOG_FILE}" 0 "Checking systemtap log: Array test"
|
|
|
a4cdc02 |
rlRun "grep -q 'Range::step' ${_LOG_FILE}" 0 "Checking systemtap log: Range test"
|
|
|
a4cdc02 |
rlRun "grep -q 'Hash::initialize' ${_LOG_FILE}" 0 "Checking systemtap log: Hash test"
|
|
|
a4cdc02 |
rlRun "grep -q 'String::slice!' ${_LOG_FILE}" 0 "Checking systemtap log: String test"
|
|
|
a4cdc02 |
rlRun "grep -q 'Integer::times' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - iteration number"
|
|
|
a4cdc02 |
rlRun "grep -q '$PRINT' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - printf function"
|
|
|
a4cdc02 |
rlRun "grep -q 'IO::write' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - IO write"
|
|
|
a4cdc02 |
rlPhaseEnd
|
|
|
a4cdc02 |
|
|
|
a4cdc02 |
rlPhaseStartCleanup
|
|
|
a4cdc02 |
rlRun "popd"
|
|
|
a4cdc02 |
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
|
|
a4cdc02 |
rlPhaseEnd
|
|
|
a4cdc02 |
rlJournalPrintText
|
|
|
a4cdc02 |
rlJournalEnd
|