From a4cdc02f0149265769c19ba553570a2e43daf01f Mon Sep 17 00:00:00 2001 From: Miroslav Vadkerti Date: Feb 15 2018 12:42:17 +0000 Subject: Import 3 integration tests systemtap-static-probes-in-ruby: for testing ruby's systemtap api bundler-unit-tests: to run bundler's unit tests run-basic-rails-application: a simple rails application test Signed-off-by: Miroslav Vadkerti --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/bundler-unit-tests/Makefile b/bundler-unit-tests/Makefile new file mode 100644 index 0000000..123c1d6 --- /dev/null +++ b/bundler-unit-tests/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Description: Runs ruby upstream test suite +# Author: Iveta Senfeldova +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/rubygem-bundler/unit-tests +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE builders.patch + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +-include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Iveta Senfeldova " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Runs upstream test suite" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: rubygem-bundler" >> $(METADATA) + @echo "Requires: rubygem-bundler rubygem-thor rubygem-rdoc rubygem-net-http-persistent rubygem-psych rubygems rubygems-devel git ruby ruby-devel" >> $(METADATA) + @echo "RhtsRequires: library(distribution/sundry)" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 1194243" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/bundler-unit-tests/PURPOSE b/bundler-unit-tests/PURPOSE new file mode 100644 index 0000000..e184c3a --- /dev/null +++ b/bundler-unit-tests/PURPOSE @@ -0,0 +1 @@ +Test runs upstream test suite which is disabled in time of building the package because of missing dependencies (these dependencies are not shipped in CentOS/RHEL) diff --git a/bundler-unit-tests/builders.patch b/bundler-unit-tests/builders.patch new file mode 100644 index 0000000..1717976 --- /dev/null +++ b/bundler-unit-tests/builders.patch @@ -0,0 +1,114 @@ +--- builders.rb 2015-07-09 10:50:20.464498376 +0200 ++++ builders-new.rb 2015-07-09 11:13:58.845512475 +0200 +@@ -625,57 +631,59 @@ + end + end + +- TEST_CERT=< +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES=${PACKAGES:-rubygem-bundler} +REQUIRES=${REQUIRES:-rubygem-thor rubygem-net-http-persistent rubygems rubygems-devel rubygem-rdoc ruby ruby-devel} +BUNDLER=$(rpm -qf --queryformat '%{name}\n' $(which bundler)) +COLL_PATH="" +COLL="$(echo $COLLECTIONS|grep -Eo "\b(rh-)?ruby[0-9]*\b"|tail -1)" +RUN_RSPEC="rspec spec" +BUILD_INSTALLED=false + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlRun "rlImport distribution/sundry" 0 "Importing sundry library" || rlDie + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp builders.patch $TmpDir" 0 + rlRun "pushd $TmpDir" + if [[ ! -z $COLLECTIONS ]] + then + rlRun "sundryFetchBuildForInstalledPackage $COLL" 0 "Fetching -build sub-package for $COLL" + rlRun "sundryFetchBuildForInstalledPackage $COLL" 0 "Fetching -build sub-package for $COLL" + rlRun "yum -y localinstall $COLL-build*.rpm && BUILD_INSTALLED=true" 0 "Installing $COLL-build package" + fi + rlRun "useradd rubyuser" 0 "Adding user rubyuser to the system" + rlRun "chown -R rubyuser:rubyuser $TmpDir" 0 + rlRun "rlFetchSrcForInstalled $BUNDLER" 0 "Fetching source package for $BUNDLER" + rlRun "su rubyuser -c \"rpm --define '_topdir $TmpDir' -i $TmpDir/*src.rpm\"" 0 \ + "Installing the source rpm" + rlRun "su rubyuser -c \"rpmbuild --nodeps --define '_topdir $TmpDir' -bc $TmpDir/SPECS/*spec\"" 0 \ + "Building package" + VERSION=$(rpm -q --qf "%{VERSION}\n" $BUNDLER | tail -1) + SRC_PATH="$TmpDir/BUILD/$BUNDLER-$VERSION" + + # if we are in collections we need to set correct path and prepare for enabling ror + if [[ ! -z $COLLECTIONS ]] + then + COLL_PATH=$(which bundler | sed 's/\/usr\/bin\/bundler//') + RUN_RSPEC="scl enable $(echo $COLLECTIONS | grep -Eo '\b(rh-)?ror[0-9]*\b'|tail -1) 'rspec spec'" + fi + rlRun "pushd $SRC_PATH$COLL_PATH/usr/share/gems/gems/bundler-$VERSION/" 0 "Go to gem install dir" + if [[ -z $COLLECTIONS ]] + then + rlRun "su rubyuser -c \"patch spec/support/builders.rb $TmpDir/builders.patch\"" 0 \ + "Patching builders.rb with new valid certificates so some set of tests won't fail" + else + rlRun "su rubyuser -c \"tar xzvf $TmpDir/SOURCES/*-specs.tgz\"" 0 "Unpacking specs into install directory" + fi + # SPEC file steps: + # This test does not work, since ruby is configured with --with-ruby-version='' + # https://github.com/bundler/bundler/issues/2365 + su rubyuser -c "sed -i '/\"fetches gems again after changing the version of Ruby\"/,/end$/{s/^/#/}' spec/install/gems/platform_spec.rb" + + # Test suite needs to run in initialized git repository. + # https://github.com/carlhuda/bundler/issues/2022 + su rubyuser -c "git init" + + if [[ -z $COLLECTIONS ]] + then + # Test with system net-http-persistent and thor + for dependency in net-http-persistent thor + do + for fileordir in \ + /usr/share/gems/gems/$dependency-*/lib/* + do + su rubyuser -c "ln -s -f $fileordir lib/bundler/vendor/$(basename $fileordir)" + done + done + # end of SPEC file steps + + # gems required to run unit tests + # older versions which should be compatible with ruby-2.0.0, but it's currently without effect, rspec fetches newer versions anyway + #GEMS="rspec-mocks3.1.0 rspec-support:3.1.0 rspec-expectations:3.1.0 rspec-core:3.1.0 rspec:3.1.0 diff-lcs rack:1.5.2 rake:10.3.2 sinatra:1.4.5" + GEMS="rspec-mocks rspec-support rspec-expectations rspec-core rspec diff-lcs" + rlRun "gem install $GEMS" 0 "Installing $GEMS" + fi + rlPhaseEnd + + rlPhaseStartTest + rlRun "su rubyuser -c \"$RUN_RSPEC | tee output.log\"" 0 "Run unit tests" + rlAssertGrep "examples, 0 failures," output.log + rlPhaseEnd + + rlPhaseStartCleanup + if [[ -z $COLLECTIONS ]] + then + rlRun "gem uninstall $GEMS -a -I -x --force" 0 "Removing installed gems" + fi + $BUILD_INSTALLED && rlRun "yum -y remove $COLL-build" 0 "Removing $COLL-build package" + rlRun "userdel -r rubyuser" 0 "Removing rubyuser from the system" + rlRun "popd ; popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/run-basic-rails-application/Makefile b/run-basic-rails-application/Makefile new file mode 100644 index 0000000..91938b6 --- /dev/null +++ b/run-basic-rails-application/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/rubygem-rails/run-basic-rails-application +# Description: Test creates new rails application and runs it +# Author: Iveta Senfeldova +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/rubygem-rails/run-basic-rails-application +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +-include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Iveta Senfeldova " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test creates new rails application in collection and runs it" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 60m" >> $(METADATA) + @echo "RunFor: rubygem-rails ruby" >> $(METADATA) + @echo "Requires: rubygems rubygem-rails ruby-devel sqlite-devel libxml2-devel libxslt-devel gcc-c++ net-tools" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/run-basic-rails-application/PURPOSE b/run-basic-rails-application/PURPOSE new file mode 100644 index 0000000..ae007e0 --- /dev/null +++ b/run-basic-rails-application/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /CoreOS/rubygem-rails/run-basic-rails-application +Description: Test creates new rails application and runs it +Author: Iveta Senfeldova + +Test ensure it is possible to create new rails application and run it. diff --git a/run-basic-rails-application/runtest.sh b/run-basic-rails-application/runtest.sh new file mode 100755 index 0000000..141f1a4 --- /dev/null +++ b/run-basic-rails-application/runtest.sh @@ -0,0 +1,101 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/rubygem-rails/run-basic-rails-application +# Description: Test creates new rails application and runs it +# Author: Iveta Senfeldova +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh +. /usr/lib/beakerlib/beakerlib.sh + +PACKAGES=${PACKAGES:-ruby rubygems} +REQUIRES=${REQUIRES:-} +RUBY=${RUBY:-ruby} +RAILS=0 +bundle="" +ARCH=$(uname -m) +RAILSVER="" + +# if in collection get gem dependencies locally not from rubygems.org +[ ! -z "$COLLECTIONS" ] && bundle="--local" + +# version of Ruby on RHEL7 needs older version of rails +if rlIsRHEL 7; then RAILSVER="-v 4.2.7"; NOKOVER="-v 1.6.8"; fi + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlAssertBinaryOrigin $RUBY + rlAssertBinaryOrigin "gem" + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + if ! gem list "^rails \(*\)$" -i + then + # nokogiri gem installed with rails needs to use system libraries + # on arm and ppcle otherwise it fails with bundled libraries + if [ "x$ARCH" = "xaarch64" ] || [ "x$ARCH" = "xppc64le" ] + then + export NOKOGIRI_USE_SYSTEM_LIBRARIES=yes + fi + rlRun "gem install nokogiri $NOKOVER --no-document" 0 "Installing nokogiri $NOKOVER without documentation" + rlRun "gem install rails $RAILSVER --no-document" 0 "Installing rails $RAILSVER without documentation" + RAILS=1 + fi + rlPhaseEnd + + rlPhaseStartTest + rlRun "rails new app | tee bundle.log" 0 "Creating new rails application" + [ ! -z "$COLLECTIONS" ] && rlAssertGrep "bundle install --local" bundle.log || rlAssertNotGrep "bundle install --local" bundle.log + rlRun "pushd app/" + rlAssertExists "app" + + if [[ ! "$COLLECTIONS" =~ "rh-ror50" ]] + then + rlRun "echo \"gem 'therubyracer'\" >> Gemfile" 0 "Adding therubyracer gem into Gemfile" + fi + + if [ -z "$COLLECTIONS" ] + then + rlRun "echo \"gem 'nokogiri', '1.6.8'\" >> Gemfile" 0 "Adding nokogiri gem into Gemfile" + sed -i "s/gem 'spring'/#gem 'spring'/" Gemfile + rlRun "gem pristine nokogiri" 0 "Restore installed nokogiri to pristine condition" + rlRun "bundle config build.nokogiri --use-system-libraries" 0 "Build nokogiri with system libraries" + fi + rlRun "bundle install $bundle" + rlRun "netstat -tulpn | grep 3000" 1 "Check if port 3000 isn't engaged" + rlRun "rails server &" 0 "Running rails server" + sleep 10 + rlRun "wget http://0.0.0.0:3000" 0 "Wgetting running rails application" + PID=`pidof ruby` + rlRun "kill -9 $PID" 0 "Killing rails server" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd; popd" + [ $RAILS == 1 ] && rlRun "gem uninstall rails nokogiri minitest -a -I -x" 0 "Removing rails and nokogiri gem" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/systemtap-static-probes-in-ruby/Makefile b/systemtap-static-probes-in-ruby/Makefile new file mode 100644 index 0000000..1413cdb --- /dev/null +++ b/systemtap-static-probes-in-ruby/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/ruby/Regression/systemtap-static-probes-in-ruby +# Description: It tests there are static probes in ruby package. +# Author: Ales Marecek +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/ruby/Regression/systemtap-static-probes-in-ruby +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +-include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Iveta Senfeldova " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: It tests there are static probes in ruby package." >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: ruby" >> $(METADATA) + @echo "Requires: ruby ruby-doc ruby-libs systemtap grep" >> $(METADATA) + @echo "Releases: RHEL6" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 673162" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/systemtap-static-probes-in-ruby/PURPOSE b/systemtap-static-probes-in-ruby/PURPOSE new file mode 100644 index 0000000..13edbcf --- /dev/null +++ b/systemtap-static-probes-in-ruby/PURPOSE @@ -0,0 +1 @@ +Simple test to exercise ruby's systemtap API. diff --git a/systemtap-static-probes-in-ruby/runtest.sh b/systemtap-static-probes-in-ruby/runtest.sh new file mode 100755 index 0000000..6183ef6 --- /dev/null +++ b/systemtap-static-probes-in-ruby/runtest.sh @@ -0,0 +1,101 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/ruby/Regression/systemtap-static-probes-in-ruby +# Description: It tests there are static probes in ruby package. +# Author: Ales Marecek +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include rhts environment +. /usr/lib/beakerlib/beakerlib.sh + +PACKAGES=${PACKAGES:-ruby ruby-libs} +if rlIsRHEL 7 && [ -z "$COLLECTIONS" ] ; then PACKAGES=$PACKAGES" ruby-doc" ; 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 + +# for ruby on RHEL7 and in collections +PRINT="Kernel::printf" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlAssertBinaryOrigin $RUBY + rlAssertExists "${_STAP_FILE}" + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "pushd ${TmpDir}" + _LOG_FILE="${TmpDir}/${_LOG_FILE}" + touch ${_LOG_FILE} + rlPhaseEnd + + rlPhaseStartTest + # TODO: Systemtap - The test could be enlarged by other methods / functions / objects / ... + 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" + _STAP_PID=$! + echo -e "--_STAP_PID--\n${_STAP_PID}" # info + + rlRun "sleep ${_SLEEP_TIME}" 0 "Waiting \"${_SLEEP_TIME}\" seconds" + + 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" + rlRun "$RUBY -e '(1..10).step(1)'" 0 "Running ruby interpreter: Range test" + 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" + + 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" + 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 + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd