| |
@@ -41,10 +41,25 @@
|
| |
_STAP_FILE="`rpm -ql $PACKAGES | grep 'ruby-exercise.stp' 2>/dev/null`"
|
| |
_LOG_FILE="ruby.log"
|
| |
_STAP_OUT="stap-out.log"
|
| |
+ _KERNEL_DEVEL="kernel-devel-`uname -r`"
|
| |
|
| |
# for ruby on RHEL7 and in collections
|
| |
PRINT="Kernel::printf"
|
| |
|
| |
+ _run_stap () {
|
| |
+ local t="${1:-2}"
|
| |
+ rlRun "( timeout $t stap -v ${_STAP_FILE} -o ${_LOG_FILE} 1>&2 2>${_STAP_OUT} & )" 0 "Running systemtap in background"
|
| |
+ sleep 1
|
| |
+ # wait for systemtap to start
|
| |
+ rlWaitForCmd "grep 'starting run' ${_STAP_OUT}"
|
| |
+ }
|
| |
+
|
| |
+ _log_file () {
|
| |
+ sleep 1
|
| |
+ echo -e "---${_LOG_FILE}--"
|
| |
+ grep ' -e:1$' ${_LOG_FILE}
|
| |
+ }
|
| |
+
|
| |
rlJournalStart
|
| |
rlPhaseStartSetup
|
| |
rlAssertRpm --all
|
| |
@@ -54,6 +69,9 @@
|
| |
rlRun "pushd ${TmpDir}"
|
| |
_LOG_FILE="${TmpDir}/${_LOG_FILE}"
|
| |
touch ${_LOG_FILE}
|
| |
+ if rlIsRHEL '>=8' || rlIsFedora; then
|
| |
+ rlRun "rpm -q '$_KERNEL_DEVEL' || dnf install -y '$_KERNEL_DEVEL'" 0 'Installing corresponding kernel-devel: $_KERNEL_DEVEL'
|
| |
+ fi
|
| |
rlPhaseEnd
|
| |
|
| |
rlPhaseStartTest
|
| |
@@ -61,45 +79,50 @@
|
| |
rlRun "rpm -ql $PACKAGES | grep 'stp' | grep 'tapset'" 0 "Checking tapset file"
|
| |
rlRun "rpm -ql $PACKAGES | grep 'stp' | grep 'doc'" 0 "Checking doc file"
|
| |
|
| |
- rlRun "{ stap -v ${_STAP_FILE} -o ${_LOG_FILE} |& tee ${_STAP_OUT}; } &" 0 "Running systemtap in background"
|
| |
- _STAP_PID=$!
|
| |
- echo -e "--_STAP_PID--\n${_STAP_PID}" # info
|
| |
+ # stap takes long time to start for the first time
|
| |
+ _run_stap 60
|
| |
+ rlRun "grep -q 'starting run' ${_STAP_OUT}" 0 "Checking stap output."
|
| |
+ _log_file
|
| |
|
| |
- # wait for systemtap to start
|
| |
- rlWaitForCmd "grep 'starting run' ${_STAP_OUT}"
|
| |
+ if rlIsRHEL '<7' && [ -z "$COLLECTIONS" ]
|
| |
+ then
|
| |
+ _run_stap
|
| |
+ rlRun "$RUBY -e '1.0 + 9.0'" 0 "Running ruby interpreter: Float test"
|
| |
+ _log_file
|
| |
+ rlRun "grep -q 'Float::+' ${_LOG_FILE}" 0 "Checking systemtap log: Float test"
|
| |
+ # for ruby on RHEL6
|
| |
+ PRINT="Object::printf"
|
| |
+ fi
|
| |
|
| |
- rlRun "$RUBY -e '1.0 + 9.0'" 0 "Running ruby interpreter: Float test"
|
| |
+ _run_stap
|
| |
rlRun "$RUBY -e '[1, 2, 3].push(4)'" 0 "Running ruby interpreter: Array test"
|
| |
+ _log_file
|
| |
+ rlRun "grep -q 'Array::push -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Array test"
|
| |
+
|
| |
+ _run_stap
|
| |
rlRun "$RUBY -e '(1..10).step(1)'" 0 "Running ruby interpreter: Range test"
|
| |
+ _log_file
|
| |
+ rlRun "grep -q 'Range::step -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Range test"
|
| |
+
|
| |
+ _run_stap
|
| |
rlRun "$RUBY -e 'Hash.new()'" 0 "Running ruby interpreter: Hash test"
|
| |
- rlRun "$RUBY -e '\"abc\".slice!(\"c\")'" 0 "Running ruby interpreter: String test"
|
| |
- rlRun "$RUBY -e '5.times { printf \"Ruby!\n\" }'" 0 "Running ruby interpreter: Cycle and print test"
|
| |
+ _log_file
|
| |
+ rlRun "grep -q 'Hash::initialize -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Hash test"
|
| |
|
| |
- # wait for all output
|
| |
- rlRun "sleep 10" 0 "Waiting \"10\" seconds"
|
| |
+ _run_stap
|
| |
+ rlRun "$RUBY -e '\"abc\".slice!(\"c\")'" 0 "Running ruby interpreter: String test"
|
| |
+ _log_file
|
| |
+ rlRun "grep -q 'String::slice! -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: String test"
|
| |
|
| |
- rlRun "kill ${_STAP_PID}" 0 "Terminating stap"
|
| |
- sleep 1 # No Operation
|
| |
+ _run_stap
|
| |
+ rlRun "$RUBY -e '5.times { printf \"Ruby!\n\" }'" 0 "Running ruby interpreter: Cycle and print test"
|
| |
+ _log_file
|
| |
+ rlRun "grep -q 'Integer::times -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - iteration number"
|
| |
+ rlRun "grep -q '$PRINT -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - printf function"
|
| |
+ rlRun "grep -q 'IO::write -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - IO write"
|
| |
|
| |
- echo -e "---ps-out--" && ps -e | grep stap # info
|
| |
- rlRun "kill -s SIGKILL ${_STAP_PID}" 0,1 "Attempt killing stap"
|
| |
rlRun "pkill stapio" 0,1 "Attempt killing all leftover stapios"
|
| |
echo -e "---ps-out--" && ps -e | grep stap # info
|
| |
-
|
| |
- echo -e "---${_LOG_FILE}--" && cat ${_LOG_FILE} # info
|
| |
- if rlIsRHEL '<7' && [ -z "$COLLECTIONS" ]
|
| |
- then
|
| |
- rlRun "grep -q 'Float::+' ${_LOG_FILE}" 0 "Checking systemtap log: Float test"
|
| |
- # for ruby on RHEL6
|
| |
- PRINT="Object::printf"
|
| |
- fi
|
| |
- rlRun "grep -q 'Array::push' ${_LOG_FILE}" 0 "Checking systemtap log: Array test"
|
| |
- rlRun "grep -q 'Range::step' ${_LOG_FILE}" 0 "Checking systemtap log: Range test"
|
| |
- rlRun "grep -q 'Hash::initialize' ${_LOG_FILE}" 0 "Checking systemtap log: Hash test"
|
| |
- rlRun "grep -q 'String::slice!' ${_LOG_FILE}" 0 "Checking systemtap log: String test"
|
| |
- rlRun "grep -q 'Integer::times' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - iteration number"
|
| |
- rlRun "grep -q '$PRINT' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - printf function"
|
| |
- rlRun "grep -q 'IO::write' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - IO write"
|
| |
rlPhaseEnd
|
| |
|
| |
rlPhaseStartCleanup
|
| |
Tests plan is defined in
rpms/ruby
(PR); if you want to test it it without it, you need to specify you're using beakerlib test suite:Test run: https://gist.github.com/f2e1fb3d4badae291ed18e5471b0d91c
To run the systemtap test only, in container:
Sample run: https://git.io/JJNEH.