From 2e9ba6a554892e79b9265de11c584b181d36c0de Mon Sep 17 00:00:00 2001 From: Miroslav Vadkerti Date: Feb 19 2018 13:11:33 +0000 Subject: Add fixes for Fedora, improve waiting for stap This patch fixes the execution of the test for Fedora. It also includes improved waiting for stap, which uses now active waiting instead of static sleep. Signed-off-by: Miroslav Vadkerti --- diff --git a/systemtap-static-probes-in-ruby/Makefile b/systemtap-static-probes-in-ruby/Makefile index 1413cdb..011d562 100644 --- a/systemtap-static-probes-in-ruby/Makefile +++ b/systemtap-static-probes-in-ruby/Makefile @@ -54,7 +54,7 @@ $(METADATA): Makefile @echo "Type: Regression" >> $(METADATA) @echo "TestTime: 5m" >> $(METADATA) @echo "RunFor: ruby" >> $(METADATA) - @echo "Requires: ruby ruby-doc ruby-libs systemtap grep" >> $(METADATA) + @echo "Requires: ruby ruby-doc ruby-libs systemtap grep procps-ng" >> $(METADATA) @echo "Releases: RHEL6" >> $(METADATA) @echo "Priority: Normal" >> $(METADATA) @echo "License: GPLv2" >> $(METADATA) diff --git a/systemtap-static-probes-in-ruby/runtest.sh b/systemtap-static-probes-in-ruby/runtest.sh index 6183ef6..2eee65d 100755 --- a/systemtap-static-probes-in-ruby/runtest.sh +++ b/systemtap-static-probes-in-ruby/runtest.sh @@ -27,15 +27,20 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include rhts environment -. /usr/lib/beakerlib/beakerlib.sh +. /usr/share/beakerlib/beakerlib.sh -PACKAGES=${PACKAGES:-ruby ruby-libs} -if rlIsRHEL 7 && [ -z "$COLLECTIONS" ] ; then PACKAGES=$PACKAGES" ruby-doc" ; fi +PACKAGES=${PACKAGES:-ruby ruby-libs rubypick} +# in RHEL7 and later the stap file is in ruby-doc package +if [ -z "$COLLECTIONS" ]; then + if rlIsRHEL '>=7' || rlIsFedora; then + PACKAGES=$PACKAGES" ruby-doc" + fi +fi REQUIRES=${REQUIRES:-} RUBY=${RUBY:-ruby} _STAP_FILE="`rpm -ql $PACKAGES | grep 'ruby-exercise.stp' 2>/dev/null`" _LOG_FILE="ruby.log" -_SLEEP_TIME=120 +_STAP_OUT="stap-out.log" # for ruby on RHEL7 and in collections PRINT="Kernel::printf" @@ -44,7 +49,7 @@ rlJournalStart rlPhaseStartSetup rlAssertRpm --all rlAssertBinaryOrigin $RUBY - rlAssertExists "${_STAP_FILE}" + rlAssertExists "${_STAP_FILE}" || rlDie rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" rlRun "pushd ${TmpDir}" _LOG_FILE="${TmpDir}/${_LOG_FILE}" @@ -56,11 +61,12 @@ rlJournalStart 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} 2>&1 >${_LOG_FILE} &" 0 "Running systemtap in background" + 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 - rlRun "sleep ${_SLEEP_TIME}" 0 "Waiting \"${_SLEEP_TIME}\" seconds" + # wait for systemtap to start + rlWaitForCmd "grep 'starting run' ${_STAP_OUT}" rlRun "$RUBY -e '1.0 + 9.0'" 0 "Running ruby interpreter: Float test" rlRun "$RUBY -e '[1, 2, 3].push(4)'" 0 "Running ruby interpreter: Array test" @@ -69,16 +75,19 @@ rlJournalStart 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" + # wait for all output rlRun "sleep 10" 0 "Waiting \"10\" seconds" + rlRun "kill ${_STAP_PID}" 0 "Terminating stap" sleep 1 # No Operation + echo -e "---ps-out--" && ps -e | grep stap # info rlRun "kill -s SIGKILL ${_STAP_PID}" 0,1 "Attempt killing stap" - rlRun "killall stapio" 0,1 "Attempt killing all leftover stapios" + 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" ] + if rlIsRHEL '<7' && [ -z "$COLLECTIONS" ] then rlRun "grep -q 'Float::+' ${_LOG_FILE}" 0 "Checking systemtap log: Float test" # for ruby on RHEL6