|
|
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"
|
|
|
3af87f3 |
_KERNEL_DEVEL="kernel-devel-`uname -r`"
|
|
|
a4cdc02 |
|
|
|
a4cdc02 |
# for ruby on RHEL7 and in collections
|
|
|
a4cdc02 |
PRINT="Kernel::printf"
|
|
|
a4cdc02 |
|
|
|
3af87f3 |
_run_stap () {
|
|
|
3af87f3 |
local t="${1:-2}"
|
|
|
3af87f3 |
rlRun "( timeout $t stap -v ${_STAP_FILE} -o ${_LOG_FILE} 1>&2 2>${_STAP_OUT} & )" 0 "Running systemtap in background"
|
|
|
3af87f3 |
sleep 1
|
|
|
3af87f3 |
# wait for systemtap to start
|
|
|
3af87f3 |
rlWaitForCmd "grep 'starting run' ${_STAP_OUT}"
|
|
|
3af87f3 |
}
|
|
|
3af87f3 |
|
|
|
3af87f3 |
_log_file () {
|
|
|
3af87f3 |
sleep 1
|
|
|
3af87f3 |
echo -e "---${_LOG_FILE}--"
|
|
|
3af87f3 |
grep ' -e:1$' ${_LOG_FILE}
|
|
|
3af87f3 |
}
|
|
|
3af87f3 |
|
|
|
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}
|
|
|
3af87f3 |
if rlIsRHEL '>=8' || rlIsFedora; then
|
|
|
3af87f3 |
rlRun "rpm -q '$_KERNEL_DEVEL' || dnf install -y '$_KERNEL_DEVEL'" 0 'Installing corresponding kernel-devel: $_KERNEL_DEVEL'
|
|
|
3af87f3 |
fi
|
|
|
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 |
|
|
|
3af87f3 |
# stap takes long time to start for the first time
|
|
|
3af87f3 |
_run_stap 60
|
|
|
3af87f3 |
rlRun "grep -q 'starting run' ${_STAP_OUT}" 0 "Checking stap output."
|
|
|
3af87f3 |
_log_file
|
|
|
a4cdc02 |
|
|
|
3af87f3 |
if rlIsRHEL '<7' && [ -z "$COLLECTIONS" ]
|
|
|
3af87f3 |
then
|
|
|
3af87f3 |
_run_stap
|
|
|
3af87f3 |
rlRun "$RUBY -e '1.0 + 9.0'" 0 "Running ruby interpreter: Float test"
|
|
|
3af87f3 |
_log_file
|
|
|
3af87f3 |
rlRun "grep -q 'Float::+' ${_LOG_FILE}" 0 "Checking systemtap log: Float test"
|
|
|
3af87f3 |
# for ruby on RHEL6
|
|
|
3af87f3 |
PRINT="Object::printf"
|
|
|
3af87f3 |
fi
|
|
|
a4cdc02 |
|
|
|
3af87f3 |
_run_stap
|
|
|
a4cdc02 |
rlRun "$RUBY -e '[1, 2, 3].push(4)'" 0 "Running ruby interpreter: Array test"
|
|
|
3af87f3 |
_log_file
|
|
|
3af87f3 |
rlRun "grep -q 'Array::push -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Array test"
|
|
|
3af87f3 |
|
|
|
3af87f3 |
_run_stap
|
|
|
a4cdc02 |
rlRun "$RUBY -e '(1..10).step(1)'" 0 "Running ruby interpreter: Range test"
|
|
|
3af87f3 |
_log_file
|
|
|
3af87f3 |
rlRun "grep -q 'Range::step -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Range test"
|
|
|
3af87f3 |
|
|
|
3af87f3 |
_run_stap
|
|
|
a4cdc02 |
rlRun "$RUBY -e 'Hash.new()'" 0 "Running ruby interpreter: Hash test"
|
|
|
3af87f3 |
_log_file
|
|
|
3af87f3 |
rlRun "grep -q 'Hash::initialize -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Hash test"
|
|
|
a4cdc02 |
|
|
|
3af87f3 |
_run_stap
|
|
|
3af87f3 |
rlRun "$RUBY -e '\"abc\".slice!(\"c\")'" 0 "Running ruby interpreter: String test"
|
|
|
3af87f3 |
_log_file
|
|
|
3af87f3 |
rlRun "grep -q 'String::slice! -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: String test"
|
|
|
2e9ba6a |
|
|
|
3af87f3 |
_run_stap
|
|
|
3af87f3 |
rlRun "$RUBY -e '5.times { printf \"Ruby!\n\" }'" 0 "Running ruby interpreter: Cycle and print test"
|
|
|
3af87f3 |
_log_file
|
|
|
3af87f3 |
rlRun "grep -q 'Integer::times -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - iteration number"
|
|
|
3af87f3 |
rlRun "grep -q '$PRINT -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - printf function"
|
|
|
3af87f3 |
rlRun "grep -q 'IO::write -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - IO write"
|
|
|
2e9ba6a |
|
|
|
2e9ba6a |
rlRun "pkill stapio" 0,1 "Attempt killing all leftover stapios"
|
|
|
a4cdc02 |
echo -e "---ps-out--" && ps -e | grep stap # info
|
|
|
a4cdc02 |
rlPhaseEnd
|
|
|
a4cdc02 |
|
|
|
a4cdc02 |
rlPhaseStartCleanup
|
|
|
a4cdc02 |
rlRun "popd"
|
|
|
a4cdc02 |
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
|
|
a4cdc02 |
rlPhaseEnd
|
|
|
a4cdc02 |
rlJournalPrintText
|
|
|
a4cdc02 |
rlJournalEnd
|