2022-01-21 12:51:15 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
#
|
|
|
|
# runtest.sh of /CoreOS/python/Sanity/systemtap
|
|
|
|
# Description: Systemtap static probes test
|
|
|
|
# Author: Petr Splichal <psplicha@redhat.com>
|
|
|
|
#
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
2023-02-21 19:41:54 +00:00
|
|
|
. /etc/os-release || exit 1
|
2022-01-21 12:51:15 +00:00
|
|
|
|
|
|
|
# Packages to be tested
|
|
|
|
PACKAGES="${PACKAGES:-python3}"
|
|
|
|
# Other required packages
|
|
|
|
REQUIRES=${REQUIRES:-}
|
|
|
|
# Binary name parametrized
|
|
|
|
PYTHON="${PYTHON:-python3}"
|
|
|
|
|
|
|
|
package=$(rpm -qf --queryformat '%{name}\n' $(which $PYTHON))
|
|
|
|
collection_path=$(which python | sed 's/\/usr\/bin\/python//')
|
|
|
|
|
|
|
|
rlJournalStart
|
|
|
|
rlPhaseStartSetup
|
2023-05-02 08:47:18 +00:00
|
|
|
# rlAssertRpm --all
|
2022-01-21 12:51:15 +00:00
|
|
|
rlAssertRpm "systemtap"
|
|
|
|
rlLogInfo "Running on kernel: $(uname -r)"
|
|
|
|
rlRun "rpm -qa 'systemtap*'" 0 "Checking systemtap packages"
|
|
|
|
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
|
|
|
|
rlRun "cp list.stp top.stp test.py $TmpDir" 0 "Copying scripts"
|
|
|
|
rlRun "pushd $TmpDir"
|
2023-05-04 15:56:45 +00:00
|
|
|
|
|
|
|
# Install needed debuginfo, best effort
|
2023-05-19 08:34:46 +00:00
|
|
|
rlLogInfo "DEBUGINFOD_URLS=$DEBUGINFOD_URLS"
|
|
|
|
rlLogInfo "DEBUGINFOD_TIMEOUT=$DEBUGINFOD_TIMEOUT"
|
2023-05-04 15:56:45 +00:00
|
|
|
rlRun "L=$(stap -p2 -e 'probe python.function.entry {exit()}' | awk -F\" '/process/ {print $2}')" 0-255
|
2023-05-19 08:34:46 +00:00
|
|
|
rlRun "debuginfo-install -y $L /usr/bin/python\*" 0-255
|
2022-01-21 12:51:15 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "Verifying ELF file for presence of .probes section"
|
|
|
|
for lib in ${collection_path}/usr/lib*/libpython*.so.* ; do
|
|
|
|
rlRun "eu-readelf -x .probes $lib" \
|
|
|
|
0 "Checking for .probes section within $lib"
|
|
|
|
done
|
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
# Note that typically you need to be root to run "stap" (or be within
|
|
|
|
# an appropriate group)
|
|
|
|
for script in list top; do
|
2023-02-21 19:41:54 +00:00
|
|
|
# bz2152970 is a known probem
|
|
|
|
[ "$ID" == "fedora" ] && [ "$script" == "top" ] && continue
|
2022-01-21 12:51:15 +00:00
|
|
|
rlPhaseStartTest "Test $script"
|
|
|
|
rlRun "rm -rf ~/.systemtap/cache" 0 "Cleaning cache"
|
|
|
|
rlRun "stap $script.stp -v -c \"$PYTHON test.py\" > $script" \
|
|
|
|
0 "Testing with $script.stp"
|
|
|
|
rlRun "tail -100 $script | col -b" 0 "Inspecting output"
|
2022-05-26 09:05:48 +00:00
|
|
|
rlRun "grep '/usr/lib.*python.*random.py' '$script'" \
|
|
|
|
0 "Checking for random in the $script output"
|
2022-01-21 12:51:15 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
done
|
|
|
|
|
|
|
|
rlPhaseStartCleanup
|
|
|
|
rlRun "popd"
|
|
|
|
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
|
|
|
rlPhaseEnd
|
|
|
|
rlJournalPrintText
|
|
|
|
rlJournalEnd
|