diff --git a/.gitignore b/.gitignore index 702599e..c7a87f3 100644 --- a/.gitignore +++ b/.gitignore @@ -105,11 +105,3 @@ /systemtap-5.2~pre17277956g0b7f6722.tar.gz /systemtap-5.2~pre17283218gc5774e18.tar.gz /systemtap-5.2.tar.gz -/systemtap-5.2~pre17373420g1e894ff0.tar.gz -/systemtap-5.3~pre17373422g9a48fbea.tar.gz -/systemtap-5.3~pre17373794g3efe129d.tar.gz -/systemtap-5.3~pre17373816g7a71d34b.tar.gz -/systemtap-5.3.tar.gz -/systemtap-5.4~pre17585473g1fe4178d.tar.gz -/systemtap-5.4~pre17585496g86ab88eb.tar.gz -/systemtap-5.4.tar.gz diff --git a/gating.yaml b/gating.yaml index a2c8282..ff1fcc6 100644 --- a/gating.yaml +++ b/gating.yaml @@ -1,15 +1,7 @@ --- !Policy product_versions: - fedora-* -decision_contexts: [bodhi_update_push_testing] -subject_type: koji_build -rules: - - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} - - !PassingTestCaseRule {test_case_name: baseos-qe.koji-build.scratch-build.validation} ---- !Policy -product_versions: - - fedora-* -decision_contexts: [bodhi_update_push_stable] +decision_context: bodhi_update_push_stable subject_type: koji_build rules: - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} diff --git a/plans/ci.fmf b/plans/ci.fmf index 7009e4e..c4e22c1 100644 --- a/plans/ci.fmf +++ b/plans/ci.fmf @@ -1,9 +1,17 @@ summary: CI Gating Plan +adjust: + - when: distro == fedora + discover+: + filter: 'tier: 1' + environment+: + DEBUGINFOD_URLS: https://debuginfod.fedoraproject.org/ + DEBUGINFOD_TIMEOUT: 300 + - when: distro == rhel + environment+: + DEBUGINFOD_URLS: https://debuginfod.usersys.redhat.com/ + DEBUGINFOD_TIMEOUT: 300 discover: how: fmf - url: https://src.fedoraproject.org/tests/systemtap-gating.git - ref: main - directory: tests prepare: - name: prepare how: shell diff --git a/sources b/sources index a210820..68e20e1 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (systemtap-5.4.tar.gz) = 5869fe3735e44be65ba7895a46b4ea66fcdcc21ed2ab0673c62d822730553837f816d82fd78eeca4bfe6f17fdeaa12eb2f94c0b0b7ebb8c495c961f0b6935785 +SHA512 (systemtap-5.2.tar.gz) = 30137e232e44abe98747ae61a71a162eff5abc89e9a922f86ade834eac2cac1923ae06d4ed17710718adba082ad06d2fb544822003a54e13b97eea9e183bdf9d diff --git a/systemtap-gcc16.patch b/systemtap-gcc16.patch deleted file mode 100644 index c336ce6..0000000 --- a/systemtap-gcc16.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- systemtap-5.4/configure~ 2025-10-30 14:47:35.000000000 +0000 -+++ systemtap-5.4/configure 2026-01-13 18:53:20.466037572 +0000 -@@ -3121,8 +3121,8 @@ - } - { - // Unicode literals -- char const *utf8 = u8"UTF-8 string \u2500"; -- char16_t const *utf16 = u"UTF-8 string \u2500"; -+ auto const *utf8 = u8"UTF-8 string \u2500"; -+ char16_t const *utf16 = u"UTF-16 string \u2500"; - char32_t const *utf32 = U"UTF-32 string \u2500"; - } - ' diff --git a/systemtap.spec b/systemtap.spec index 577dc67..d6fdd7f 100644 --- a/systemtap.spec +++ b/systemtap.spec @@ -13,8 +13,8 @@ %endif %{!?with_rpm: %global with_rpm 1} %{!?elfutils_version: %global elfutils_version 0.179} -%{!?with_boost: %global with_boost 1} -%ifarch x86_64 ppc ppc64 ppc64le aarch64 +%{!?with_boost: %global with_boost 0} +%ifarch %{ix86} x86_64 ppc ppc64 ppc64le aarch64 %{!?with_dyninst: %global with_dyninst 0%{?fedora} >= 18 || 0%{?rhel} >= 7} %else %{!?with_dyninst: %global with_dyninst 0} @@ -45,10 +45,6 @@ %{!?with_httpd: %global with_httpd 0} %{!?with_specific_python: %global with_specific_python 0%{?fedora} >= 31} %{!?with_sysusers: %global with_sysusers 0%{?fedora} >= 32 || 0%{?rhel} >= 9} -# NB: can't turn this on by default on any distro version whose builder system -# may run kernels different than the distro version itself. -%{!?with_check: %global with_check 0} - # Virt is supported on these arches, even on el7, but it's not in core EL7 %if 0%{?rhel} && 0%{?rhel} <= 7 @@ -121,17 +117,11 @@ m stapsys stapsys\ m stapdev stapusr\ m stapdev stapdev -%define _systemtap_server_preinstall_tmpfiles \ -# See systemd-tmpfiles(8) tmpfiles.d(5)\ -d /var/lib/stap-server 0750 stap-server stap-server -\ -d /var/lib/stap-server/.systemtap 0700 stap-server stap-server -\ -d /var/log/stap-server 0755 stap-server stap-server -\ -f /var/log/stap-server/log 0644 stap-server stap-server - Name: systemtap # PRERELEASE -Version: 5.4 -Release: 2%{?release_override}%{?dist} +Version: 5.2 +Release: 1%{?release_override}%{?dist} # for version, see also configure.ac @@ -168,7 +158,6 @@ Summary: Programmable system-wide instrumentation system License: GPL-2.0-or-later URL: https://sourceware.org/systemtap/ Source: ftp://sourceware.org/pub/systemtap/releases/systemtap-%{version}.tar.gz -Patch0: systemtap-gcc16.patch # Build* BuildRequires: make @@ -196,7 +185,9 @@ BuildRequires: pkgconfig(ncurses) BuildRequires: systemd %endif # Needed for libstd++ < 4.0, without +%if %{with_boost} BuildRequires: boost-devel +%endif %if %{with_crash} BuildRequires: crash-devel zlib-devel %endif @@ -218,7 +209,7 @@ BuildRequires: xmlto /usr/share/xmlto/format/fo/pdf %endif %if %{with_emacsvim} # for _emacs_sitelispdir macros etc. -BuildRequires: emacs-common +BuildRequires: emacs %endif %if %{with_java} BuildRequires: java-devel @@ -250,14 +241,8 @@ BuildRequires: libmicrohttpd-devel BuildRequires: libuuid-devel %endif %if %{with_sysusers} -BuildRequires: systemd-rpm-macros +BuildRequires: systemd-rpm-macros %endif -%if %{with_check} -BuildRequires: kernel-devel -# and some of the same Requires: as below -BuildRequires: dejagnu gcc make -%endif - # Install requirements @@ -363,14 +348,12 @@ Requires: mokutil %endif %description client -This package contains/requires only the components needed to -use systemtap scripts by compiling them using a local or a remote -systemtap-server service, then run them using a local or -remote systemtap-runtime. It includes script samples and +This package contains/requires the components needed to develop +systemtap scripts, and compile them using a local systemtap-devel +or a remote systemtap-server installation, then run them using a +local or remote systemtap-runtime. It includes script samples and documentation, and a copy of the tapset library for reference. -It does NOT include all the components for running a systemtap -script in a self-contained fashion; for that, use the -devel -subpackage instead. + %package initscript Summary: Systemtap Initscripts @@ -396,10 +379,6 @@ boot-time probing if supported. Summary: Static probe support header files License: GPL-2.0-or-later AND CC0-1.0 URL: https://sourceware.org/systemtap/ -%if 0%{?rhel} && 0%{?rhel} <= 10 -# for RHEL buildability compatibility, pull in sdt-dtrace at all times -Requires: systemtap-sdt-dtrace = %{version}-%{release} -%endif %description sdt-devel This package includes the header file used for static @@ -614,7 +593,6 @@ or within a container. %prep %setup -q -%patch 0 -p1 %build @@ -742,8 +720,6 @@ mkdir -p %{buildroot}%{_sysusersdir} echo '%_systemtap_runtime_preinstall' > %{buildroot}%{_sysusersdir}/systemtap-runtime.conf echo '%_systemtap_server_preinstall' > %{buildroot}%{_sysusersdir}/systemtap-server.conf echo '%_systemtap_testsuite_preinstall' > %{buildroot}%{_sysusersdir}/systemtap-testsuite.conf -mkdir -p %{buildroot}%{_tmpfilesdir} -echo '%_systemtap_server_preinstall_tmpfiles' > %{buildroot}%{_tmpfilesdir}/systemtap-server.conf %endif @@ -869,18 +845,9 @@ done %py3_shebang_fix %{buildroot}%{python3_sitearch} %{buildroot}%{_bindir}/* %endif -%check -%if %{with_check} -make check RUNTESTFLAGS=environment_sanity.exp -%endif - - %pre runtime %if %{with_sysusers} -%if (0%{?fedora} && 0%{?fedora} < 42) || (0%{?rhel} && 0%{?rhel} < 11) echo '%_systemtap_runtime_preinstall' | systemd-sysusers --replace=%{_sysusersdir}/systemtap-runtime.conf - -exit 0 -%endif %else getent group stapusr >/dev/null || groupadd -f -g 156 -r stapusr getent group stapsys >/dev/null || groupadd -f -g 157 -r stapsys @@ -888,30 +855,23 @@ getent group stapdev >/dev/null || groupadd -f -g 158 -r stapdev getent passwd stapunpriv >/dev/null || \ useradd -c "Systemtap Unprivileged User" -u 159 -g stapunpriv -d %{_localstatedir}/lib/stapunpriv -r -s /sbin/nologin stapunpriv 2>/dev/null || \ useradd -c "Systemtap Unprivileged User" -g stapunpriv -d %{_localstatedir}/lib/stapunpriv -r -s /sbin/nologin stapunpriv -exit 0 %endif +exit 0 %pre server %if %{with_sysusers} -%if (0%{?fedora} && 0%{?fedora} < 42) || (0%{?rhel} && 0%{?rhel} < 11) echo '%_systemtap_server_preinstall' | systemd-sysusers --replace=%{_sysusersdir}/systemtap-server.conf - -echo '%_systemtap_server_preinstall_tmpfiles' | systemd-tmpfiles --replace=%{_tmpfilesdir}/systemtap-server.conf - -exit 0 -%endif %else getent group stap-server >/dev/null || groupadd -f -g 155 -r stap-server getent passwd stap-server >/dev/null || \ useradd -c "Systemtap Compile Server" -u 155 -g stap-server -d %{_localstatedir}/lib/stap-server -r -s /sbin/nologin stap-server 2>/dev/null || \ useradd -c "Systemtap Compile Server" -g stap-server -d %{_localstatedir}/lib/stap-server -r -s /sbin/nologin stap-server -exit 0 %endif +exit 0 %pre testsuite %if %{with_sysusers} -%if (0%{?fedora} && 0%{?fedora} < 42) || (0%{?rhel} && 0%{?rhel} < 11) echo '%_systemtap_testsuite_preinstall' | systemd-sysusers --replace=%{_sysusersdir}/systemtap-testsuite.conf - -exit 0 -%endif %else getent passwd stapusr >/dev/null || \ useradd -c "Systemtap 'stapusr' User" -g stapusr -r -s /sbin/nologin stapusr @@ -919,8 +879,8 @@ getent passwd stapsys >/dev/null || \ useradd -c "Systemtap 'stapsys' User" -g stapsys -G stapusr -r -s /sbin/nologin stapsys getent passwd stapdev >/dev/null || \ useradd -c "Systemtap 'stapdev' User" -g stapdev -G stapusr -r -s /sbin/nologin stapdev -exit 0 %endif +exit 0 %post server @@ -1128,7 +1088,6 @@ exit 0 %if %{with_systemd} %{_unitdir}/stap-server.service %{_tmpfilesdir}/stap-server.conf -%{_tmpfilesdir}/systemtap-server.conf %else %{initdir}/stap-server %dir %{_sysconfdir}/stap-server/conf.d @@ -1182,7 +1141,6 @@ exit 0 # python script to help list python probes. %if %{with_python3_probes} || %{with_python2_probes} %{_libexecdir}/systemtap/python/stap-resolve-module-function.py -%dir %{_libexecdir}/systemtap/python %exclude %{_libexecdir}/systemtap/python/stap-resolve-module-function.py? %endif @@ -1365,62 +1323,6 @@ exit 0 # PRERELEASE %changelog -* Tue Jan 13 2026 Jonathan Wakely - 5.4-2 -- Patched to workaround Autoconf 2.72 incompatiblity with GCC 16 - -* Fri Oct 31 2025 Frank Ch. Eigler - 5.4-1 -- Upstream release, see wiki page below for detailed notes. - https://sourceware.org/systemtap/wiki/SystemTapReleases - -* Mon Sep 22 2025 Frank Ch. Eigler - 5.4-17585496g86ab88eb -- Automated weekly rawhide release -- Applied spec changes from upstream git - -* Mon Sep 22 2025 Frank Ch. Eigler - 5.4-17585473g1fe4178d -- Automated weekly rawhide release -- Applied spec changes from upstream git - -* Fri Sep 19 2025 Python Maint - 5.3-5 -- Rebuilt for Python 3.14.0rc3 bytecode - -* Fri Aug 15 2025 Python Maint - 5.3-4 -- Rebuilt for Python 3.14.0rc2 bytecode - -* Fri Jul 25 2025 Fedora Release Engineering - 5.3-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild - -* Tue Jun 03 2025 Python Maint - 5.3-2 -- Rebuilt for Python 3.14 - -* Fri May 02 2025 Frank Ch. Eigler - 5.3-1 -- Upstream release, see wiki page below for detailed notes. - https://sourceware.org/systemtap/wiki/SystemTapReleases - -* Thu Feb 06 2025 Frank Ch. Eigler - 5.3~pre17373816g7a71d34b.5 -- Respin against dyninst 13 redux - -* Fri Jan 24 2025 Frank Ch. Eigler - 5.3~pre17373816g7a71d34b.3 -- Respin against dyninst 13, sans dyninst on i686. - -* Mon Jan 20 2025 Frank Ch. Eigler - 5.3-17373816g7a71d34b -- Automated weekly rawhide release -- Applied spec changes from upstream git - -* Mon Jan 20 2025 Frank Ch. Eigler - 5.3-17373794g3efe129d -- Automated weekly rawhide release -- Applied spec changes from upstream git - -* Sun Jan 19 2025 Frank Ch. Eigler - 5.3-17373422g9a48fbea -- Automated weekly rawhide release -- Applied spec changes from upstream git - -* Sun Jan 19 2025 Frank Ch. Eigler - 5.2-17373420g1e894ff0 -- Automated weekly rawhide release -- Applied spec changes from upstream git - -* Sun Jan 19 2025 Fedora Release Engineering - 5.2-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild - * Fri Nov 08 2024 Frank Ch. Eigler - 5.2-1 - Upstream release, see wiki page below for detailed notes. https://sourceware.org/systemtap/wiki/SystemTapReleases diff --git a/tests/Install/upstream-systemtap/main.fmf b/tests/Install/upstream-systemtap/main.fmf new file mode 100644 index 0000000..2da67d7 --- /dev/null +++ b/tests/Install/upstream-systemtap/main.fmf @@ -0,0 +1,51 @@ +summary: Build fresh systemtap RPMs from gitcache +description: '' +contact: Martin Cermak +component: + - nothing +test: ./runtest.sh +framework: beakerlib +enabled: false +recommend: + - libstdc++ + - libstdc++-devel + - libstdc++-devel.x86_64 + - libgcc + - glibc-devel + - gcc-c++ + - kernel-devel + - kernel-headers + - git + - curl + - tar + - dejagnu + - elfutils-devel + - gettext + - gettext-devel + - nss-devel + - avahi-devel + - dyninst-devel + - libselinux-devel + - sqlite-devel + - json-c-devel + - ncurses-devel + - crash-devel + - rpm-devel + - rpm-build + - emacs + - jpackage-utils + - java-devel + - libvirt-devel + - libxml2-devel + - readline-devel + - python-devel + - python3-devel + - rpm-build + - python-setuptools + - python2-setuptools + - python2-pyparsing + - dyninst-devel + - elfutils-debuginfod-client-devel +duration: 8h +tag: fedora +order: 1 diff --git a/tests/Install/upstream-systemtap/runtest.sh b/tests/Install/upstream-systemtap/runtest.sh new file mode 100755 index 0000000..9c613a5 --- /dev/null +++ b/tests/Install/upstream-systemtap/runtest.sh @@ -0,0 +1,175 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Install/upstream-head +# Description: create RPMs from the upstream head and install them +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2014 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PATCHURL=${PATCHURL:-https://147.251.27.2/~cermak} +PATCHNAME=${PATCHNAME:-PATCHPATCH7.patch} + +ORIGPWD=$( pwd ) + +# Allow use of debuginfod +# export DEBUGINFOD_URLS=http://debuginfod.usersys.redhat.com:3632/ +# export DEBUGINFOD_PROGRESS=1 + +# if [[ `arch` == *aarch* ]] || [[ `arch` == *s390* ]]; then +# # Definitely do not use debuginfod on aarch64 and s390 +# unset DEBUGINFOD_URLS +# fi + +# https://wiki.test.redhat.com/BaseOs/Tools/SystemTap +TARBALL='systemtap.tar.xz' +# GITCACHE="http://liver2.lab.eng.brq.redhat.com/mcermak/systemtap/gitcache/$TARBALL" +GITCACHE="http://10.43.134.134/systemtap/gitcache/$TARBALL" +export CLONE_CMD='git clone git://sourceware.org/git/systemtap.git' + +PKGMGR="yum --nogpgcheck --enablerepo=\*" +rpm -q dnf && PKGMGR="dnf --setopt=clean_requirements_on_remove=false --setopt=metadata_expire=99999999 --nobest --setopt=strict=0 --nogpgcheck --enablerepo=\*" + +PATCHSOURCES=no +echo $PWD | grep -qF 521-build-stap && PATCHSOURCES=yes +export PATCHSOURCES + +rlJournalStart + rlPhaseStartSetup + rlRun "MY_USER=stapbuilduser" + rlRun "getent passwd ${MY_USER} >/dev/null || useradd ${MY_USER}" + # Work around bz1936469 + rlRun "rpm -q python-unversioned-command && rpm -e python-unversioned-command ||:" + rlRun "env | sort" + rlLogInfo "PATCHSOURCES=$PATCHSOURCES" + rlPhaseEnd + + rlPhaseStart FAIL "Install deps" + rlRun "$PKGMGR clean all" + # rlRun "$PKGMGR -y update" + # rlRun "$PKGMGR -y install $RPM_REQS" + rlRun "$PKGMGR -y install --setopt=multilib_policy=all libgcc glibc-devel gcc-c++ libstdc++-devel" + rlPhaseEnd + + rlPhaseStart FAIL "Build RPMs and install them" + MY_HOME="/home/${MY_USER}" + MY_BUILD="${MY_HOME}/build" + rm -rf /tmp/stap-buildlog /tmp/stap-specfile /tmp/stap-rpms /tmp/stap-git-log +cat > ${MY_BUILD} <<-EOF +set -xe +echo '%_unpackaged_files_terminate_build 0' > ~/.rpmmacros +rm -rf systemtap +( echo attempt-1; $CLONE_CMD) || \ +( echo attempt-2; sleep 20; $CLONE_CMD ) || \ +( echo attempt-3; sleep 90; $CLONE_CMD ) +# tar -xJf /tmp/$TARBALL || curl $GITCACHE | tee /tmp/$TARBALL | tar -xJ +cd systemtap +if test -n "${CHECKOUT_COMMIT}"; then + echo "### ATTEMPTING TO CHECK OUT ${CHECKOUT_COMMIT} ###" + git checkout ${CHECKOUT_COMMIT} || exit 1 +else + echo "### NOT ATTEMPTING TO CHECK OUT SPECIFIC COMMIT ###" +fi +LASTCOMMIT=\$( git log -1 --format=format:'%ct.%h' ) +git log -20 --oneline > /tmp/stap-git-log +sed -i "s/%{?dist}/\.qetst\.\${LASTCOMMIT}%{?dist}/" systemtap.spec +sed -i "s/%{?release_override}//" systemtap.spec +sed -i 's/with_publican\ 1/with_publican\ 0/g' systemtap.spec +sed -i 's/with_docs\ 1/with_docs\ 0/g' systemtap.spec +sed -i 's/with_emacsvim\ 1/with_emacsvim\ 0/' systemtap.spec + +# NB: CONDITIONALLY APPLY THE PATCH +if [ "${PATCHSOURCES}" == "yes" ]; then + wget --no-check-certificate ${PATCHURL}/${PATCHNAME} + patch -p1 < ${PATCHNAME} +fi + +if [[ $(rpm --eval 0%{rhel}) -eq 7 ]]; then + # The upstream specfile tries to require dyninst-devel >= 10.1 on rhel7, which + # is not good for base rhel-7 package (devtoolset-9-dyninst is a special case). + # https://sourceware.org/git/gitweb.cgi?p=systemtap.git;a=blob;f=systemtap.spec;h=670e4010141f5c51e749743bace01815b5585213;hb=HEAD#l134 + sed -i 's/^BuildRequires: dyninst-devel.*/BuildRequires: dyninst-devel/' systemtap.spec + # RHEL-7 doesn't have dyninst on arches other than ppc64 (big endian) and x86_64. + if ! (arch | egrep -q '^(x86_64|ppc64)$'); then + # https://sourceware.org/git/gitweb.cgi?p=systemtap.git;a=blob;f=systemtap.spec;h=670e4010141f5c51e749743bace01815b5585213;hb=HEAD#l18 + sed -i 's/%{!?with_dyninst: %global with_dyninst 0.*/%{!?with_dyninst: %global with_dyninst 0}/' systemtap.spec + fi +fi +git config --global user.name "Martin Cermak" +git config --global user.email mcermak@redhat.com +git commit -am 'Disable publican and emacs, tweak Release.' +cat systemtap.spec > /tmp/stap-specfile +./configure --prefix=/dev/null +make rpm 2>&1 | tee /tmp/stap-buildlog +set +xe +EOF + rlRun "chown ${MY_USER}:${MY_USER} ${MY_BUILD}" + rlRun "su - ${MY_USER} -c 'bash ${MY_BUILD}'" || exit 1 + rlRun "RPMS=\"$( find ${MY_HOME}/rpmbuild/RPMS -type f -name '*rpm' -printf '%p ' )\"" + rlRun "mkdir -p /tmp/stap-rpms /home/stap-rpms" + rlRun "cp $RPMS /tmp/stap-rpms/" + rlRun "cp $RPMS /home/stap-rpms/" + rlRun "$PKGMGR remove -y systemtap-runtime-java systemtap-runtime-virthost \ + systemtap-testsuite systemtap-devel systemtap systemtap-initscript \ + systemtap-runtime systemtap-server systemtap-runtime-virtguest \ + systemtap-sdt-devel systemtap-client systemtap-debuginfo" 0,1 + rlRun "rm -rf /usr/share/systemtap" + rlRun "$PKGMGR clean all" + rlRun "$PKGMGR install -y ${RPMS}" + rlRun "rpm -qa | grep systemtap | sort" + # Test https://bugzilla.redhat.com/show_bug.cgi?id=2012907 + rlRun "rpm -V systemtap-runtime" + RPMVER=$(echo $RPMS | grep -o 'systemtap-[0-9]\+[^\ ]*' | grep -o '.*\.el[0-9]\+') + RPMDIR=/home/.systemtap-upstream-head-rpms/$RPMVER + rm -rf ${RPMDIR}; mkdir -p ${RPMDIR}; + rlRun "cp ${RPMS} ${RPMDIR}/" 0 "Keep built PRMS in ${RPMDIR}" + rlPhaseEnd + + rlPhaseStart WARN "Run stap-prep" + rlRun "rpm -qa | grep ^kernel | grep -v `uname -r` | grep -v headers | xargs rpm -e --nodeps" 0-255 + rlRun "stap-prep" 0-255 + rlPhaseEnd + + rlPhaseStart FAIL "Sanity Check" + rlRun "stap --version" + rlRun "which stap" + rlRun "stap -vve 'probe kernel.function(\"vfs_read\"){ log(\"hey!\"); exit() }'" + rlPhaseEnd + + rlPhaseStart WARN "Submit interesting bits" + rlFileSubmit '/tmp/stap-buildlog' + rlRun 'tar cf /tmp/stap-upstream-rpms.tar /tmp/stap-rpms' + rlRun 'xz /tmp/stap-upstream-rpms.tar' + rlFileSubmit '/tmp/stap-upstream-rpms.tar.xz' + rlRun "rm -rf /tmp/stap-upstream-rpms.tar.xz" + rlFileSubmit '/tmp/stap-specfile' + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "userdel -f ${MY_USER}" + rlRun "rm -rf ${MY_HOME}" + rlPhaseEnd + +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/PR16166/main.fmf b/tests/Regression/PR16166/main.fmf new file mode 100644 index 0000000..43a9c05 --- /dev/null +++ b/tests/Regression/PR16166/main.fmf @@ -0,0 +1,16 @@ +summary: Test for BZ#1054962 (Backport PR16166 stap -vvv causes SIGSEGV when) +description: Backport PR16166 +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - valgrind + - systemtap +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1054962 +extra-summary: /tools/systemtap/Regression/PR16166 +extra-task: /tools/systemtap/Regression/PR16166 +tag: fedora diff --git a/tests/Regression/PR16166/runtest.sh b/tests/Regression/PR16166/runtest.sh new file mode 100755 index 0000000..b2b2258 --- /dev/null +++ b/tests/Regression/PR16166/runtest.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/PR16166 +# Description: Test for BZ#1054962 (Backport PR16166 stap -vvv causes SIGSEGV when) +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2014 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlRun "TMPDIR=\$(mktemp -d)" + rlRun "cp towers.c $TMPDIR/" + rlRun "pushd $TMPDIR" + + rlRun "gcc -g towers.c -o towers.x" + + cat > script.stp <<-EOF +global x + +probe perf.hw.cpu_cycles.process("towers.x").counter("a") {} + +probe process("towers.x").function("main") +{ + # wrong type + x = "b" . @perf("a") +} +EOF + rlRun "which valgrind" + rlRun "valgrind --version" + rlPhaseEnd + + rlPhaseStartTest + # following is expected to fail + rlRun "valgrind --log-file=output.txt stap -vvv script.stp" 1 + # ... but not to segfault + rlRun "grep SIGSEGV output.txt" 1 + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/PR16166/towers.c b/tests/Regression/PR16166/towers.c new file mode 100644 index 0000000..f8a5a20 --- /dev/null +++ b/tests/Regression/PR16166/towers.c @@ -0,0 +1,155 @@ +# include +# include + +#define towersbase 2.39 + +/* Towers */ +#define maxcells 18 +#define stackrange 3 +#define true 1 +#define false 0 + +struct element +{ + int discsize; + int next; +}; + +/* Towers */ +int stack[stackrange + 1]; +struct element cellspace[maxcells + 1]; +int freelist, movesdone; + +/* Program to Solve the Towers of Hanoi */ + +void +error (emsg) + char *emsg; +{ + printf ("Error in Towers: %s\n", emsg); +} + +void +makenull (int s) +{ + stack[s] = 0; +} + +int +get_element () +{ + int temp; + if (freelist > 0) + { + temp = freelist; + freelist = cellspace[freelist].next; + } + else + error ("out of space "); + return (temp); +} + +void +push (i, s) + int i, s; +{ + int errorfound, localel; + errorfound = false; + if (stack[s] > 0) + if (cellspace[stack[s]].discsize <= i) + { + errorfound = true; + error ("disc size error"); + }; + if (!errorfound) + { + localel = get_element (); + cellspace[localel].next = stack[s]; + stack[s] = localel; + cellspace[localel].discsize = i; + } +} + +void +init (s, n) + int s, n; +{ + int discctr; + makenull (s); + for (discctr = n; discctr >= 1; discctr--) + push (discctr, s); +} + +int +pop (s) + int s; +{ + int temp, temp1; + if (stack[s] > 0) + { + temp1 = cellspace[stack[s]].discsize; + temp = cellspace[stack[s]].next; + cellspace[stack[s]].next = freelist; + freelist = stack[s]; + stack[s] = temp; + return (temp1); + } + else + error ("nothing to pop "); + return 0; +} + +void +move (s1, s2) + int s1, s2; +{ + push (pop (s1), s2); + movesdone = movesdone + 1; +} + +void +tower (i, j, k) + int i, j, k; +{ + int other; + if (k == 1) + move (i, j); + else + { + other = 6 - i - j; + tower (i, other, k - 1); + move (i, j); + tower (other, j, k - 1); + } +} + + +void +towers () +{ + int i; + for (i = 1; i <= maxcells; i++) + cellspace[i].next = i - 1; + freelist = maxcells; + init (1, 14); + makenull (2); + makenull (3); + movesdone = 0; + tower (1, 2, 14); + if (movesdone != 16383) + printf (" error in Towers.\n"); +} + +#ifndef LOOP +#define LOOP 500 +#endif + +int +main () +{ + int i; + for (i= 0; i < LOOP; i++) + towers(); + return 0; +} + diff --git a/tests/Regression/RHEL6Feature-cpp-backtraces/README b/tests/Regression/RHEL6Feature-cpp-backtraces/README new file mode 100644 index 0000000..3211489 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-backtraces/README @@ -0,0 +1,31 @@ + +With 5.18.0-0.rc5.20220504git107c948d1d3e61d.42.fc37.x86_64 we have + + + +---------------------8<-------------------------------------------------------- +:: [ 08:26:39 ] :: [ BEGIN ] :: Running 'stap --skip-badvars --ldd backtrackator.stp -c ./classes > output.out' +In file included from /usr/share/systemtap/runtime/linux/../regs.c:20, + from /usr/share/systemtap/runtime/linux/runtime.h:270, + from /usr/share/systemtap/runtime/runtime.h:26, + from /tmp/stap7hYYpn/stap_9beffd9064cc2c18ddd2daf7f47a7e44_5966_src.c:21: +/usr/share/systemtap/runtime/stack.c: In function ‘_stp_stack_unwind_one_kernel’: +/usr/share/systemtap/runtime/linux/../linux/regs.c:23:32: error: ‘struct kretprobe_instance’ has no member named ‘ret_addr’ + 23 | #define _stp_ret_addr_r(ri) (ri->ret_addr) + | ^~ +/usr/share/systemtap/runtime/stack.c:358:47: note: in expansion of macro ‘_stp_ret_addr_r’ + 358 | return (unsigned long)_stp_ret_addr_r(c->ips.krp.pi); + | ^~~~~~~~~~~~~~~ +make[1]: *** [scripts/Makefile.build:288: /tmp/stap7hYYpn/stap_9beffd9064cc2c18ddd2daf7f47a7e44_5966_src.o] Error 1 +make[1]: *** Waiting for unfinished jobs.... +make: *** [Makefile:1844: /tmp/stap7hYYpn] Error 2 +WARNING: kbuild exited with status: 2 +Pass 4: compilation failed. [man error::pass4] +:: [ 08:26:59 ] :: [ FAIL ] :: Command 'stap --skip-badvars --ldd backtrackator.stp -c ./classes > output.out' (Expected 0, got 1) +---------------------8<-------------------------------------------------------- + + +Related to CONFIG_KRETPROBE_ON_RETHOOK https://elixir.bootlin.com/linux/v5.18-rc5/source/include/linux/kprobes.h#L163 + + +Needs fixing on the stap side. diff --git a/tests/Regression/RHEL6Feature-cpp-backtraces/backtrackator.stp b/tests/Regression/RHEL6Feature-cpp-backtraces/backtrackator.stp new file mode 100644 index 0000000..18a4248 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-backtraces/backtrackator.stp @@ -0,0 +1,15 @@ +function mypr:long(){ + printf("================================================================================\n"); + printf("Probed function: [%s]\n\n", probefunc()); + printf ("Backtrace:\n"); + + print_ubacktrace(); + return 0; +} + + + +probe process("classes").function("public*") { mypr(); } +probe process("classes").function("private*") { mypr(); } +probe process("classes").function("recursive*") { mypr(); } +probe process("classes").function("main*") { mypr(); } diff --git a/tests/Regression/RHEL6Feature-cpp-backtraces/classes.cpp b/tests/Regression/RHEL6Feature-cpp-backtraces/classes.cpp new file mode 100644 index 0000000..1c42084 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-backtraces/classes.cpp @@ -0,0 +1,43 @@ +#include "classes.hpp" +#include + +void A::privateA1(){ + std::cout << "privateA1" << std::endl; + this->privateA2(); + +} + +void A::privateA2(){ + std::cout << "privateA2" << std::endl; + this->recursiveA1(3); + +} + +void A::recursiveA1(int count){ + std::cout << "recursiveA1: " << count << std::endl; + if (count == 0) + return; + this->recursiveA1(count-1); + return; +} + +void A::publicA1(){ + std::cout << "publicA1" << std::endl; + this->publicA2(); +} + +void A::publicA2(){ + std::cout << "publicA2" << std::endl; + this->privateA1(); +} + + +void B::privateB1(A a){ + std::cout << "privateB1" << std::endl; + a.publicA1(); +} + +void B::publicB1(A a){ + std::cout << "publicB1" << std::endl; + this->privateB1(a); +} diff --git a/tests/Regression/RHEL6Feature-cpp-backtraces/classes.hpp b/tests/Regression/RHEL6Feature-cpp-backtraces/classes.hpp new file mode 100644 index 0000000..0846ae2 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-backtraces/classes.hpp @@ -0,0 +1,16 @@ +class A{ + private: + void privateA1(); + void privateA2(); + void recursiveA1(int); + public: + void publicA1(); + void publicA2(); +}; + +class B{ + private: + void privateB1(A); + public: + void publicB1(A); +}; diff --git a/tests/Regression/RHEL6Feature-cpp-backtraces/golden.out b/tests/Regression/RHEL6Feature-cpp-backtraces/golden.out new file mode 100644 index 0000000..9f643d6 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-backtraces/golden.out @@ -0,0 +1,77 @@ +================================================================================ +Probed function: [main] +================================================================================ +Probed function: [publicB1] +publicB1 +================================================================================ +Probed function: [privateB1] +privateB1 +publicB1 +================================================================================ +Probed function: [publicA1] +publicA1 +privateB1 +publicB1 +================================================================================ +Probed function: [publicA2] +publicA2 +publicA1 +privateB1 +publicB1 +================================================================================ +Probed function: [privateA1] +privateA1 +publicA2 +publicA1 +privateB1 +publicB1 +================================================================================ +Probed function: [privateA2] +privateA2 +privateA1 +publicA2 +publicA1 +privateB1 +publicB1 +================================================================================ +Probed function: [recursiveA1] +recursiveA1 +privateA2 +privateA1 +publicA2 +publicA1 +privateB1 +publicB1 +================================================================================ +Probed function: [recursiveA1] +recursiveA1 +recursiveA1 +privateA2 +privateA1 +publicA2 +publicA1 +privateB1 +publicB1 +================================================================================ +Probed function: [recursiveA1] +recursiveA1 +recursiveA1 +recursiveA1 +privateA2 +privateA1 +publicA2 +publicA1 +privateB1 +publicB1 +================================================================================ +Probed function: [recursiveA1] +recursiveA1 +recursiveA1 +recursiveA1 +recursiveA1 +privateA2 +privateA1 +publicA2 +publicA1 +privateB1 +publicB1 diff --git a/tests/Regression/RHEL6Feature-cpp-backtraces/main.cpp b/tests/Regression/RHEL6Feature-cpp-backtraces/main.cpp new file mode 100644 index 0000000..69ae514 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-backtraces/main.cpp @@ -0,0 +1,10 @@ +#include "classes.hpp" + +int main(){ + A a; + B b; + + b.publicB1(a); + return 0; +} + diff --git a/tests/Regression/RHEL6Feature-cpp-backtraces/main.fmf b/tests/Regression/RHEL6Feature-cpp-backtraces/main.fmf new file mode 100644 index 0000000..e0b5ee9 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-backtraces/main.fmf @@ -0,0 +1,14 @@ +summary: Tests backtracking in C++ programs +description: '' +contact: Petr Muller +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap + - gcc-c++ +duration: 10m +extra-summary: /tools/systemtap/Regression/RHEL6Feature-cpp-backtraces +extra-task: /tools/systemtap/Regression/RHEL6Feature-cpp-backtraces +tag: fedora diff --git a/tests/Regression/RHEL6Feature-cpp-backtraces/runtest.sh b/tests/Regression/RHEL6Feature-cpp-backtraces/runtest.sh new file mode 100755 index 0000000..629c082 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-backtraces/runtest.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/RHEL6Feature-cpp-backtraces +# Description: Tests backtracking in C++ programs +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/share/beakerlib/beakerlib.sh || exit 1 +. /etc/os-release || exit 1 + +PACKAGE="systemtap" + +rlJournalStart + +rlPhaseStartSetup + rlRun "g++ classes.cpp main.cpp -g -o classes" + rlRun "stap-prep" 0-255 +rlPhaseEnd + +rlPhaseStartTest + rlRun "stap --ldd backtrackator.stp -c ./classes -o output.out" + rlRun "sed -i -r -e 's/_[_A-Za-z0-9]*publicA1[A-Za-z0-9]*/publicA1/g' output.out" + rlRun "sed -i -r -e 's/_[_A-Za-z0-9]*publicA2[A-Za-z0-9]*/publicA2/g' output.out" + rlRun "sed -i -r -e 's/_[_A-Za-z0-9]*privateA1[A-Za-z0-9]*/privateA1/g' output.out" + rlRun "sed -i -r -e 's/_[_A-Za-z0-9]*privateA2[A-Za-z0-9]*/privateA2/g' output.out" + rlRun "sed -i -r -e 's/_[_A-Za-z0-9]*recursiveA1[A-Za-z0-9]*/recursiveA1/g' output.out" + rlRun "sed -i -r -e 's/_[_A-Za-z0-9]*publicB1[A-Za-z0-9]*/publicB1/g' output.out" + rlRun "sed -i -r -e 's/_[_A-Za-z0-9]*privateB1[A-Za-z0-9]*/privateB1/g' output.out" + rlRun "grep -o -e publicA1 -e publicA2 -e privateA1 -e privateA2 -e recursiveA1 \ + -e publicB1 -e privateB1 -e 'Probed function:.*' -e '=*' \ + output.out > output.processed" + rlRun "diff output.processed golden.out" +rlPhaseEnd + +rlPhaseStartCleanup + rlFileSubmit output.out + rlFileSubmit output.processed + rlFileSubmit golden.out + rlRun "rm -f output.out output.processed" +rlPhaseEnd + +rlJournalPrintText + +rlJournalEnd diff --git a/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/classes.cpp b/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/classes.cpp new file mode 100644 index 0000000..cd488c5 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/classes.cpp @@ -0,0 +1,39 @@ +#include + +class Explicit{ + public: + int data; + Explicit(); + Explicit(int argument); + Explicit(const Explicit &original); + ~Explicit(); +}; + +class Implicit{ + public: + int data; +}; + +Explicit::Explicit() { this->data=0; } +Explicit::Explicit(int a) {this->data=0; } +Explicit::Explicit(const Explicit &orig){this->data = orig.data;} +Explicit::~Explicit(){} + +int main(){ + Explicit e1; //static ctor call + Explicit *e2; + + e2 = new Explicit(); //dynamic ctor call + delete e2; //dynamic dtor call + + e2 = new Explicit(2); //dynamic ctor call + Explicit e3 = *e2; //copy ctor + delete e2; //dtor + + Implicit i1; //ctor + Implicit *i2 = new Implicit(); //ctor + Implicit i3 = *i2; //implicit copy ctor + delete i2; //dtor + + return 0; // dtor e1, e3, i1, i3 +} diff --git a/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/golden.out b/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/golden.out new file mode 100644 index 0000000..f45ff90 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/golden.out @@ -0,0 +1,16 @@ +Explicit constructor start +Explicit constructor end +Explicit constructor start +Explicit constructor end +Explicit destructor start +Explicit destructor end +Explicit constructor start +Explicit constructor end +Explicit constructor start +Explicit constructor end +Explicit destructor start +Explicit destructor end +Explicit destructor start +Explicit destructor end +Explicit destructor start +Explicit destructor end diff --git a/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/main.fmf b/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/main.fmf new file mode 100644 index 0000000..940dae3 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/main.fmf @@ -0,0 +1,14 @@ +summary: Tests probing constructors and destructors +description: '' +contact: Petr Muller +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap + - gcc-c++ +duration: 5m +extra-summary: /tools/systemtap/Regression/RHEL6Feature-cpp-ctors-and-dtors +extra-task: /tools/systemtap/Regression/RHEL6Feature-cpp-ctors-and-dtors +tag: fedora diff --git a/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/runtest.sh b/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/runtest.sh new file mode 100755 index 0000000..fc72f6b --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/runtest.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/RHEL6Feature-cpp-ctors-and-dtors +# Description: Tests probing constructors and destructors +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" + +rlJournalStart + +rlPhaseStartSetup + rlRun "g++ classes.cpp -g -o classes" +rlPhaseEnd + +rlPhaseStartTest + rlRun "stap -c ./classes tracker.stp -o output.out" + rlAssertNotDiffer golden.out output.out +rlPhaseEnd + +rlPhaseStartCleanup + rlFileSubmit "output.out" + rlFileSubmit "golden.out" + rlRun "rm -rf classes output.out" +rlPhaseEnd + +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/tracker.stp b/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/tracker.stp new file mode 100644 index 0000000..8ff0bb1 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-ctors-and-dtors/tracker.stp @@ -0,0 +1,23 @@ +probe process("classes").function("Explicit::Explicit"){ + printf("Explicit constructor start\n"); +} + +probe process("classes").function("Explicit::~Explicit"){ + printf("Explicit destructor start\n"); +} + +probe process("classes").function("Explicit::Explicit").return{ + printf("Explicit constructor end\n"); +} + +probe process("classes").function("Explicit::~Explicit").return{ + printf("Explicit destructor end\n"); +} + +//probe process("classes").function("Implicit::Implicit"){ +// printf("Implicitconstructor\n"); +//} + +//probe process("classes").function("Implicit::Implicit"){ +// printf("Implicit constructor\n"); +//} diff --git a/tests/Regression/RHEL6Feature-cpp-inheritance/classes.cpp b/tests/Regression/RHEL6Feature-cpp-inheritance/classes.cpp new file mode 100644 index 0000000..2ab3e54 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-inheritance/classes.cpp @@ -0,0 +1,56 @@ +#include + +class A{ + public: + void one(){ std::cout << "A::one" << std::endl; } + void two(){ std::cout << "A::two" << std::endl; } + virtual void three() { std::cout << "A::three" << std::endl; } + virtual void four() { std::cout << "A::four" << std::endl; } +}; + +class B : public A{ + public: + void one() { std::cout << "B::one" << std::endl; } + int one(int a) { std::cout << "B::one" << std::endl; } + + virtual void three() { std::cout << "B::three" << std::endl; } +}; + +int main(){ + A a; + B b; + + A *ap = new A(); + A *apb = new B(); + + B *bp = new B(); + + + a.one(); + a.two(); + a.three(); + a.four(); + + b.one(); + b.two(); + b.three(); + b.four(); + + ap->one(); + ap->two(); + ap->three(); + ap->four(); + + apb->one(); + apb->two(); + apb->three(); + apb->four(); + + bp->one(); + bp->two(); + bp->three(); + bp->four(); + + + return 0; +} diff --git a/tests/Regression/RHEL6Feature-cpp-inheritance/main.fmf b/tests/Regression/RHEL6Feature-cpp-inheritance/main.fmf new file mode 100644 index 0000000..86d5648 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-inheritance/main.fmf @@ -0,0 +1,14 @@ +summary: Tests systemtap handling inheritance +description: '' +contact: Petr Muller +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap + - gcc-c++ +duration: 10m +extra-summary: /tools/systemtap/Regression/RHEL6Feature-cpp-inheritance +extra-task: /tools/systemtap/Regression/RHEL6Feature-cpp-inheritance +tag: fedora diff --git a/tests/Regression/RHEL6Feature-cpp-inheritance/runtest.sh b/tests/Regression/RHEL6Feature-cpp-inheritance/runtest.sh new file mode 100755 index 0000000..deec9ce --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-inheritance/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/RHEL6Feature-cpp-inheritance +# Description: Tests systemtap handling inheritance +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/share/beakerlib/beakerlib.sh || exit 1 + +# if this testcase caused kernel crash and reboot, don't try to rerun it +[[ $REBOOTCOUNT -gt 0 ]] && exit 1 + +PACKAGE="systemtap" + +rlJournalStart + +rlPhaseStartSetup + rlRun "g++ classes.cpp -o classes -g" + rlRun "./classes > program.out" 0 "Preparing the golden output" +rlPhaseEnd + +rlPhaseStartTest + rlRun "stap -c ./classes tracker.stp -o stap.out" + rlAssertNotDiffer program.out stap.out +rlPhaseEnd + +rlPhaseStartCleanup + rlFileSubmit program.out + rlFileSubmit stap.out + rlRun "rm -f classes stap.out program.out" +rlPhaseEnd + +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/RHEL6Feature-cpp-inheritance/tracker.stp b/tests/Regression/RHEL6Feature-cpp-inheritance/tracker.stp new file mode 100644 index 0000000..525ced5 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-inheritance/tracker.stp @@ -0,0 +1,6 @@ +probe process("classes").function("A::one"){printf("A::one\n");} +probe process("classes").function("A::two"){printf("A::two\n");} +probe process("classes").function("A::three"){printf("A::three\n");} +probe process("classes").function("A::four"){printf("A::four\n");} +probe process("classes").function("B::one"){printf("B::one\n");} +probe process("classes").function("B::three"){printf("B::three\n");} diff --git a/tests/Regression/RHEL6Feature-cpp-methods/classes.cpp b/tests/Regression/RHEL6Feature-cpp-methods/classes.cpp new file mode 100644 index 0000000..e947234 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-methods/classes.cpp @@ -0,0 +1,71 @@ +__attribute__((noinline)) void StandaloneFunction(){ + +} + +class CLASS1{ + private: + void prMethod() {}; + public: + void puMethod() {this->prMethod();}; + static void stMethod() {}; +}; + +namespace inner{ + void StandaloneFunction(){ + } + + class CLASS1{ + private: + void prMethod() {}; + public: + void puMethod() {this->prMethod();}; + static void stMethod() {}; + }; +}; + +namespace moreinner{ + void StandaloneFunction(){ + } + + class CLASS1{ + private: + __attribute__((noinline)) void prMethod() {}; + public: + __attribute__((noinline)) void puMethod() {this->prMethod();}; + __attribute__((noinline)) static void stMethod() {}; + }; +}; + +int main(){ + StandaloneFunction(); + inner::StandaloneFunction(); + moreinner::StandaloneFunction(); + + CLASS1 A; + inner::CLASS1 B; + moreinner::CLASS1 C; + + CLASS1* pA = new CLASS1(); + inner::CLASS1 *pB = new inner::CLASS1(); + moreinner::CLASS1 *pC = new moreinner::CLASS1(); + + A.puMethod(); + A.stMethod(); + + B.puMethod(); + B.stMethod(); + + C.puMethod(); + C.stMethod(); + + pA->puMethod(); + pA->stMethod(); + + pB->puMethod(); + pB->stMethod(); + + pC->puMethod(); + pC->stMethod(); + + return 0; +} diff --git a/tests/Regression/RHEL6Feature-cpp-methods/golden_summary.out b/tests/Regression/RHEL6Feature-cpp-methods/golden_summary.out new file mode 100644 index 0000000..4072ed7 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-methods/golden_summary.out @@ -0,0 +1,13 @@ +__hitcount=70 +__inner_CLASS1_prMethod=0 +__inner_CLASS1_puMethod=0 +__inner_CLASS1_stMethod=0 +__inner_StandaloneFunction=0 +__moreinner_StandaloneFunction=0 +__moreinner_star_prMethod=0 +__moreinner_star_puMethod=0 +__moreinner_star_stMethod=0 +__prMethod=0 +__puMethod=0 +__StandaloneFunction=0 +__stMethod=0 diff --git a/tests/Regression/RHEL6Feature-cpp-methods/main.fmf b/tests/Regression/RHEL6Feature-cpp-methods/main.fmf new file mode 100644 index 0000000..e2d9c88 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-methods/main.fmf @@ -0,0 +1,14 @@ +summary: Tests C++ methods +description: '' +contact: Petr Muller +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap + - gcc-c++ +duration: 120m +extra-summary: /tools/systemtap/Regression/RHEL6Feature-cpp-methods +extra-task: /tools/systemtap/Regression/RHEL6Feature-cpp-methods +tag: fedora diff --git a/tests/Regression/RHEL6Feature-cpp-methods/runtest.sh b/tests/Regression/RHEL6Feature-cpp-methods/runtest.sh new file mode 100755 index 0000000..a019d7a --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-methods/runtest.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/RHEL6Feature-cpp-methods +# Description: Tests C++ methods +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" +export LANG=C + +rlJournalStart + +rlPhaseStartSetup + rlRun "stap-prep" 0-255 + rlRun "g++ -O0 classes.cpp -o classes -g" +rlPhaseEnd + +rlPhaseStartTest + rlRun "stap $COMPAT -c ./classes tracker.stp -o output.out" + # Stop comparing literally against a golden file, + # do a sanity check instead. The literal golden file check + # sort of regressed between rhel-8.2 and rhel-8.3 + # rlRun "diff golden.out output.out" + rlRun "grep ^__ output.out | sort > summary.out" + + # The way sort works across test systems may differ + # esp wrt whether capitals go first or not, so let's sort + # the golden_summary.out first using actual defaults + # slash LANG etc... + rlRun "sort golden_summary.out > golden_summary.sort" + + # RHEL6: covert hex to dec: + rlRun "sed -i 's/0x0/0/' summary.out" + rlRun "sed -i 's/0x46/70/' summary.out" + + # Sanity check + rlRun "diff golden_summary.sort summary.out" || ( + rlRun "cat golden_summary.out" + rlRun "cat summary.out" + ) +rlPhaseEnd + +rlPhaseStartCleanup + rlRun "rm -f golden_summary.sort output.out summary.out classes" +rlPhaseEnd + +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/RHEL6Feature-cpp-methods/tracker.stp b/tests/Regression/RHEL6Feature-cpp-methods/tracker.stp new file mode 100644 index 0000000..54e15b3 --- /dev/null +++ b/tests/Regression/RHEL6Feature-cpp-methods/tracker.stp @@ -0,0 +1,162 @@ +global __hitcount = 0 +global __StandaloneFunction = 0 +global __inner_StandaloneFunction = 0 +global __moreinner_StandaloneFunction = 0 +global __stMethod = 0 +global __inner_CLASS1_stMethod = 0 +global __moreinner_star_stMethod = 0 +global __prMethod = 0 +global __inner_CLASS1_prMethod = 0 +global __moreinner_star_prMethod = 0 +global __puMethod = 0 +global __inner_CLASS1_puMethod = 0 +global __moreinner_star_puMethod = 0 + +probe process("classes").function("StandaloneFunction").call{ + __StandaloneFunction++ + __hitcount++ + printf("StandaloneFunction start: %s\n", probefunc()); +} + +probe process("classes").function("StandaloneFunction").return{ + __StandaloneFunction-- + __hitcount++ + printf("StandaloneFunction end: %s\n", probefunc()); +} + +probe process("classes").function("inner::StandaloneFunction").call{ + __inner_StandaloneFunction++ + __hitcount++ + printf("inner::StandaloneFunction start: %s\n", probefunc()); +} + +probe process("classes").function("inner::StandaloneFunction").return{ + __inner_StandaloneFunction-- + __hitcount++ + printf("inner::StandaloneFunction end: %s\n", probefunc()); +} + +probe process("classes").function("moreinner::StandaloneFunction").call{ + __moreinner_StandaloneFunction++ + __hitcount++ + printf("moreinner::StandaloneFunction start: %s\n", probefunc()); +} + +probe process("classes").function("moreinner::StandaloneFunction").return{ + __moreinner_StandaloneFunction-- + __hitcount++ + printf("moreinner::StandaloneFunction end: %s\n", probefunc()); +} +// ============================================================================ +probe process("classes").function("stMethod").call{ + __stMethod++ + __hitcount++ + printf("stMethod start: %s\n", probefunc()); +} + +probe process("classes").function("stMethod").return{ + __stMethod-- + __hitcount++ + printf("stMethod end: %s\n", probefunc()); +} + +probe process("classes").function("inner::CLASS1::stMethod").call{ + __inner_CLASS1_stMethod++ + __hitcount++ + printf("inner::stMethod start: %s\n", probefunc()); +} + +probe process("classes").function("inner::CLASS1::stMethod").return{ + __inner_CLASS1_stMethod-- + __hitcount++ + printf("inner::stMethod end: %s\n", probefunc()); +} + +probe process("classes").function("moreinner::*::stMethod").call{ + __moreinner_star_stMethod++ + __hitcount++ + printf("moreinner::stMethod start: %s\n", probefunc()); +} + +probe process("classes").function("moreinner::*::stMethod").return{ + __moreinner_star_stMethod-- + __hitcount++ + printf("moreinner::stMethod end: %s\n", probefunc()); +} +//============================================================================= + +probe process("classes").function("prMethod").call{ + __prMethod++ + __hitcount++ + printf("prMethod start: %s\n", probefunc()); +} + +probe process("classes").function("prMethod").return{ + __prMethod-- + __hitcount++ + printf("prMethod end: %s\n", probefunc()); +} + +probe process("classes").function("inner::CLASS1::prMethod").call{ + __inner_CLASS1_prMethod++ + __hitcount++ + printf("inner::prMethod start: %s\n", probefunc()); +} + +probe process("classes").function("inner::CLASS1::prMethod").return{ + __inner_CLASS1_prMethod-- + __hitcount++ + printf("inner::prMethod end: %s\n", probefunc()); +} + +probe process("classes").function("moreinner::*::prMethod").call{ + __moreinner_star_prMethod++ + __hitcount++ + printf("moreinner::prMethod start: %s\n", probefunc()); +} + +probe process("classes").function("moreinner::*::prMethod").return{ + __moreinner_star_prMethod-- + __hitcount++ + printf("moreinner::prMethod end: %s\n", probefunc()); +} + +//============================================================================= + +probe process("classes").function("puMethod").call{ + __puMethod++ + __hitcount++ + printf("puMethod start: %s\n", probefunc()); +} + +probe process("classes").function("puMethod").return{ + __puMethod-- + __hitcount++ + printf("puMethod end: %s\n", probefunc()); +} + +probe process("classes").function("inner::CLASS1::puMethod").call{ + __inner_CLASS1_puMethod++ + __hitcount++ + printf("inner::puMethod start: %s\n", probefunc()); +} + +probe process("classes").function("inner::CLASS1::puMethod").return{ + __inner_CLASS1_puMethod-- + __hitcount++ + printf("inner::puMethod end: %s\n", probefunc()); +} + +probe process("classes").function("moreinner::*::puMethod").call{ + __moreinner_star_puMethod++ + __hitcount++ + printf("moreinner::puMethod start: %s\n", probefunc()); +} + +probe process("classes").function("moreinner::*::puMethod").return{ + __moreinner_star_puMethod-- + __hitcount++ + printf("moreinner::puMethod end: %s\n", probefunc()); +} + + diff --git a/tests/Regression/RHEL7-5-backtraces-no-longer-work-with-systemtap/main.fmf b/tests/Regression/RHEL7-5-backtraces-no-longer-work-with-systemtap/main.fmf new file mode 100644 index 0000000..7078911 --- /dev/null +++ b/tests/Regression/RHEL7-5-backtraces-no-longer-work-with-systemtap/main.fmf @@ -0,0 +1,15 @@ +summary: Test for BZ#1572501 (RHEL7.5 - backtraces no longer work with systemtap) +description: Test for BZ#1572501 +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 48h +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1572501 +extra-summary: /tools/systemtap/Regression/RHEL7-5-backtraces-no-longer-work-with-systemtap +extra-task: /tools/systemtap/Regression/RHEL7-5-backtraces-no-longer-work-with-systemtap +tag: fedora diff --git a/tests/Regression/RHEL7-5-backtraces-no-longer-work-with-systemtap/runtest.sh b/tests/Regression/RHEL7-5-backtraces-no-longer-work-with-systemtap/runtest.sh new file mode 100755 index 0000000..94cf2cc --- /dev/null +++ b/tests/Regression/RHEL7-5-backtraces-no-longer-work-with-systemtap/runtest.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/RHEL7-5-backtraces-no-longer-work-with-systemtap +# Description: Test for BZ#1572501 (RHEL7.5 - backtraces no longer work with systemtap) +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2018 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" + +rlJournalStart + rlPhaseStartTest + if arch | grep -q s390x; then + rlLogWarning "Test not relevant" + else + TEMPFILE=$(mktemp) + rlRun "stap --all-modules -vwe 'probe kernel.function(\"kmem_cache_alloc\")?, kernel.function(\"schedule\") { print_backtrace(); exit() }' >& $TEMPFILE" + # since it's hard to find some reasonable pattern to grep for across arches in the backrtrace + # we'll simply count the lines. We'll want at least 9 lines of output (6 as the results of -v, + # and another at least three coming from the backtrace itself. + rlRun "cat $TEMPFILE" + rlRun "test 9 -le $(wc -l $TEMPFILE | awk '{print $1}')" + rm $TEMPFILE + fi + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz544960-no-cfa_ops-supplied/README b/tests/Regression/bz544960-no-cfa_ops-supplied/README new file mode 100644 index 0000000..f1152ea --- /dev/null +++ b/tests/Regression/bz544960-no-cfa_ops-supplied/README @@ -0,0 +1,63 @@ +Kernel porting needed. + +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Test +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: [ 09:22:47 ] :: [ INFO ] :: Checking whether we might want to try prologue search. +:: [ 09:23:10 ] :: [ BEGIN ] :: Running 'stap -P -vp4 readpages.stp' +Pass 1: parsed user script and 484 library scripts using 122428virt/95036res/15532shr/79120data kb, in 200usr/110sys/315real ms. +WARNING: never-assigned local variable 'nr_pages' (similar: rpages, __page, dev, name, file): identifier 'nr_pages' at readpages.stp:5:26 + source: printf("nr_pages=%d\n", nr_pages); + ^ +WARNING: never-assigned local variable 'rpages' (similar: nr_pages, __page, dev, name, rsize): identifier 'rpages' at :7:24 + source: printf("rpages=%d\n", rpages); + ^ +Pass 2: analyzed script: 2 probes, 17 functions, 3 embeds, 0 globals using 351676virt/327836res/19060shr/308368data kb, in 2880usr/1970sys/4927real ms. +Pass 3: translated to C into "/tmp/stapWU958g/stap_f189533513b6d61221ada924fedfc9c4_6369_src.c" using 351692virt/327964res/19188shr/308384data kb, in 490usr/800sys/1301real ms. +In file included from /usr/share/systemtap/runtime/linux/../regs.c:16, + from /usr/share/systemtap/runtime/linux/runtime.h:270, + from /usr/share/systemtap/runtime/runtime.h:26, + from /tmp/stapWU958g/stap_f189533513b6d61221ada924fedfc9c4_6369_src.c:21: +/tmp/stapWU958g/stap_f189533513b6d61221ada924fedfc9c4_6369_src.c: In function ‘enter_kretprobe_common’: +/tmp/stapWU958g/stap_f189533513b6d61221ada924fedfc9c4_6369_src.c:2499:45: error: ‘struct kretprobe_instance’ has no member named ‘ret_addr’ + 2499 | SET_REG_IP(regs, (unsigned long)inst->ret_addr); + | ^~ +/usr/share/systemtap/runtime/linux/../regs.h:85:44: note: in definition of macro ‘SET_REG_IP’ + 85 | #define SET_REG_IP(regs, x) REG_IP(regs) = x + | ^ +make[1]: *** [scripts/Makefile.build:288: /tmp/stapWU958g/stap_f189533513b6d61221ada924fedfc9c4_6369_src.o] Error 1 +make: *** [Makefile:1844: /tmp/stapWU958g] Error 2 +WARNING: kbuild exited with status: 2 +Pass 4: compiled C into "stap_f189533513b6d61221ada924fedfc9c4_6369.ko" in 1150usr/1910sys/2659real ms. +Pass 4: compilation failed. [man error::pass4] +:: [ 09:23:20 ] :: [ FAIL ] :: Command 'stap -P -vp4 readpages.stp' (Expected 0, got 1) +:: [ 09:23:20 ] :: [ BEGIN ] :: Running 'stap -P -vp4 tcp.sendmsg.stp' +Pass 1: parsed user script and 484 library scripts using 122428virt/95044res/15536shr/79120data kb, in 180usr/130sys/316real ms. +Pass 2: analyzed script: 5 probes, 2 functions, 4 embeds, 3 globals using 202292virt/178300res/19224shr/158984data kb, in 1720usr/1750sys/3531real ms. +Pass 3: translated to C into "/tmp/stapzXlpka/stap_c98d0598383a49c9b0a715336e876a54_18911_src.c" using 202308virt/178492res/19416shr/159000data kb, in 160usr/720sys/899real ms. +In file included from /usr/share/systemtap/runtime/linux/../regs.c:16, + from /usr/share/systemtap/runtime/linux/runtime.h:270, + from /usr/share/systemtap/runtime/runtime.h:26, + from /tmp/stapzXlpka/stap_c98d0598383a49c9b0a715336e876a54_18911_src.c:21: +/tmp/stapzXlpka/stap_c98d0598383a49c9b0a715336e876a54_18911_src.c: In function ‘enter_kretprobe_common’: +/tmp/stapzXlpka/stap_c98d0598383a49c9b0a715336e876a54_18911_src.c:2190:45: error: ‘struct kretprobe_instance’ has no member named ‘ret_addr’ + 2190 | SET_REG_IP(regs, (unsigned long)inst->ret_addr); + | ^~ +/usr/share/systemtap/runtime/linux/../regs.h:85:44: note: in definition of macro ‘SET_REG_IP’ + 85 | #define SET_REG_IP(regs, x) REG_IP(regs) = x + | ^ +make[1]: *** [scripts/Makefile.build:288: /tmp/stapzXlpka/stap_c98d0598383a49c9b0a715336e876a54_18911_src.o] Error 1 +make: *** [Makefile:1844: /tmp/stapzXlpka] Error 2 +WARNING: kbuild exited with status: 2 +Pass 4: compiled C into "stap_c98d0598383a49c9b0a715336e876a54_18911.ko" in 1250usr/1900sys/2762real ms. +Pass 4: compilation failed. [man error::pass4] +:: [ 09:23:28 ] :: [ FAIL ] :: Command 'stap -P -vp4 tcp.sendmsg.stp' (Expected 0, got 1) +:: [ 09:23:28 ] :: [ BEGIN ] :: Running 'stap -P -vp4 bdflush.stp' +Pass 1: parsed user script and 484 library scripts using 122428virt/94968res/15468shr/79120data kb, in 180usr/130sys/317real ms. +Pass 2: analyzed script: 3 probes, 5 functions, 98 embeds, 4 globals using 198116virt/174376res/18956shr/154808data kb, in 1930usr/2660sys/4689real ms. +/root/.systemtap/cache/87/stap_8728db2fdfe761c96d8963fd0c4fffd2_71969.ko +Pass 3: using cached /root/.systemtap/cache/87/stap_8728db2fdfe761c96d8963fd0c4fffd2_71969.c +Pass 4: using cached /root/.systemtap/cache/87/stap_8728db2fdfe761c96d8963fd0c4fffd2_71969.ko +:: [ 09:23:33 ] :: [ PASS ] :: Command 'stap -P -vp4 bdflush.stp' (Expected 0, got 0) + diff --git a/tests/Regression/bz544960-no-cfa_ops-supplied/bdflush.stp b/tests/Regression/bz544960-no-cfa_ops-supplied/bdflush.stp new file mode 100644 index 0000000..e38c685 --- /dev/null +++ b/tests/Regression/bz544960-no-cfa_ops-supplied/bdflush.stp @@ -0,0 +1,8 @@ +probe syscall.bdflush { + printf("%s\n", name) + printf("%s\n", argstr) +} + +probe syscall.bdflush.return { + printf("%s\n", name) +} diff --git a/tests/Regression/bz544960-no-cfa_ops-supplied/main.fmf b/tests/Regression/bz544960-no-cfa_ops-supplied/main.fmf new file mode 100644 index 0000000..bab475f --- /dev/null +++ b/tests/Regression/bz544960-no-cfa_ops-supplied/main.fmf @@ -0,0 +1,14 @@ +summary: bz544960-no-cfa_ops-supplied +description: '' +contact: Martin Hatina +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=544960 +extra-summary: /tools/systemtap/Regression/bz544960-no-cfa_ops-supplied +extra-task: /tools/systemtap/Regression/bz544960-no-cfa_ops-supplied diff --git a/tests/Regression/bz544960-no-cfa_ops-supplied/readpages.stp b/tests/Regression/bz544960-no-cfa_ops-supplied/readpages.stp new file mode 100644 index 0000000..9410376 --- /dev/null +++ b/tests/Regression/bz544960-no-cfa_ops-supplied/readpages.stp @@ -0,0 +1,21 @@ +probe nfs.aop.readpages !, nfs.aop.readpage ? { + log(name); + printf("dev=%d\n", dev); + printf("ino=%d\n", ino); + printf("nr_pages=%d\n", nr_pages); + printf("file=%d\n", file); + printf("rpages=%d\n", rpages); + printf("rsize=%d\n", rsize); + printf("argstr=%s\n", argstr); + printf("size=%d\n", size); + printf("units=%s\n", units); +} + +probe nfs.aop.readpages.return !, nfs.aop.readpage.return ? { + log(name); + printf("retstr=%s\n", retstr); + printf("size=%d\n", size); + printf("units=%s\n", units); +} + +probe oneshot { log("hey!") } diff --git a/tests/Regression/bz544960-no-cfa_ops-supplied/runtest.sh b/tests/Regression/bz544960-no-cfa_ops-supplied/runtest.sh new file mode 100755 index 0000000..9b31b30 --- /dev/null +++ b/tests/Regression/bz544960-no-cfa_ops-supplied/runtest.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/bz544960-no-cfa_ops-supplied +# Description: What the test does +# Author: Martin Hatina +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + + +PACKAGE="systemtap" +_SCRIPTS="readpages.stp tcp.sendmsg.stp bdflush.stp" + +rlJournalStart + rlPhaseStartTest + rlLogInfo "Checking whether we might want to try prologue search." + p="" + for s in $_SCRIPTS; do + stap -vp4 $s >& /dev/null || p="-P" + done + + for s in $_SCRIPTS; do + rlRun "stap $p -vp4 $s" + done + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz544960-no-cfa_ops-supplied/tcp.sendmsg.stp b/tests/Regression/bz544960-no-cfa_ops-supplied/tcp.sendmsg.stp new file mode 100644 index 0000000..1cb95b3 --- /dev/null +++ b/tests/Regression/bz544960-no-cfa_ops-supplied/tcp.sendmsg.stp @@ -0,0 +1,7 @@ +probe tcp.sendmsg { + printf("%d\n", size) +} + +probe tcp.sendmsg.return { + printf("%d\n", size) +} diff --git a/tests/Regression/bz706185-various-build-and-run/main.fmf b/tests/Regression/bz706185-various-build-and-run/main.fmf new file mode 100644 index 0000000..44fc465 --- /dev/null +++ b/tests/Regression/bz706185-various-build-and-run/main.fmf @@ -0,0 +1,15 @@ +summary: bz706185-various-build-and-run +description: bz706185-various-build-and-run +contact: Petr Muller +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 20m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=706185 +extra-summary: /tools/systemtap/Regression/bz706185-various-build-and-run +extra-task: /tools/systemtap/Regression/bz706185-various-build-and-run +tag: fedora diff --git a/tests/Regression/bz706185-various-build-and-run/runtest.sh b/tests/Regression/bz706185-various-build-and-run/runtest.sh new file mode 100755 index 0000000..447c049 --- /dev/null +++ b/tests/Regression/bz706185-various-build-and-run/runtest.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/bz706185-various-build-and-run +# Description: Test containing several build and run testcases. +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 Beaker environment +. /usr/share/beakerlib/beakerlib.sh + +PACKAGE="systemtap" + +rlJournalStart +rlPhaseStartSetup + rlRun "rpm -qf $(which stap)" + rlRun "uname -r" +rlPhaseEnd + +rlPhaseStartTest "Build testcases" + export STAPOUT=`mktemp` + export TRACOUT=`mktemp` + for testcase in *.stp + do + rlLog "Testcase: $testcase" + rlRun "stap -v -p4 $testcase -m testcase --poison-cache &>$STAPOUT" 0 "Building testcase: $testcase" + if [ $? -ne 0 ] + then + rlLog "=== systemtap output start" + while read line + do + rlLog "$line" + done < $STAPOUT + rlLog "=== systemtap output end" + fi + rm -f testcase.ko + rm -f $STAPOUT + done +rlPhaseEnd + +rlPhaseStartTest "Run testcases" + for testcase in *.run + do + rlLog "Testcase: $testcase" + COMMAND="`cat $testcase`" + COMMAND="$COMMAND -o $TRACOUT $testcase --poison-cache &>$STAPOUT" + rlLog "Assembled command: [$COMMAND]" + rlRun "$COMMAND" 0 "Running testcase: $testcase" + if [ $? -ne 0 ] + then + rlLog "=== systemtap output start" + while read line; do rlLog "$line"; done < $STAPOUT + rlLog "=== systemtap output end" + rlLog "" + rlLog "=== tracing output start" + while read line; do rlLog "$line"; done < $TRACOUT + rlLog "=== tracing output end" + fi + rm -f $STAPOUT $TRACOUT + done +rlPhaseEnd + +rlPhaseStartCleanup + rlRun "rm -f $STAPOUT $TRACOUT" +rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz706185-various-build-and-run/softirq.run b/tests/Regression/bz706185-various-build-and-run/softirq.run new file mode 100644 index 0000000..e609cd5 --- /dev/null +++ b/tests/Regression/bz706185-various-build-and-run/softirq.run @@ -0,0 +1 @@ +stap -v softirq.stp diff --git a/tests/Regression/bz706185-various-build-and-run/softirq.stp b/tests/Regression/bz706185-various-build-and-run/softirq.stp new file mode 100644 index 0000000..347b840 --- /dev/null +++ b/tests/Regression/bz706185-various-build-and-run/softirq.stp @@ -0,0 +1,3 @@ +probe softirq.entry { println(">>> softirq") } +probe softirq.exit { println("<<< softirq")} +probe timer.ms(5000) { exit() } diff --git a/tests/Regression/dtrace-create-Wall-Wextra-pedantic-clean-code/main.fmf b/tests/Regression/dtrace-create-Wall-Wextra-pedantic-clean-code/main.fmf new file mode 100644 index 0000000..5354545 --- /dev/null +++ b/tests/Regression/dtrace-create-Wall-Wextra-pedantic-clean-code/main.fmf @@ -0,0 +1,16 @@ +summary: dtrace-create-Wall-Wextra-pedantic-clean-code +description: dtrace-create-Wall-Wextra-pedantic-clean-code +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap + - systemtap-sdt-devel +duration: 5m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=902739 +extra-summary: /tools/systemtap/Regression/dtrace-create-Wall-Wextra-pedantic-clean-code +extra-task: /tools/systemtap/Regression/dtrace-create-Wall-Wextra-pedantic-clean-code +tag: fedora diff --git a/tests/Regression/dtrace-create-Wall-Wextra-pedantic-clean-code/runtest.sh b/tests/Regression/dtrace-create-Wall-Wextra-pedantic-clean-code/runtest.sh new file mode 100755 index 0000000..d76f4c5 --- /dev/null +++ b/tests/Regression/dtrace-create-Wall-Wextra-pedantic-clean-code/runtest.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/dtrace-create-Wall-Wextra-pedantic-clean-code +# Description: dtrace-create-Wall-Wextra-pedantic-clean-code +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlRun "TMPDIR=$(mktemp -d)" + rlRun "pushd $TMPDIR" + rlPhaseEnd + + rlPhaseStart WARN "Info" + rlRun "which dtrace" + rlPhaseEnd + + rlPhaseStartTest + rlRun "printf \"provider xxx { probe xxx(); };\n\" > xxx" + rlRun "dtrace -G -k -s xxx &> dtrace.out" + rlRun "cat dtrace.out" + rlRun "CF=$( awk '/^source:/ {print $2}' dtrace.out )" + rlRun "gcc -c -Wall -Wextra -pedantic $CF 2>&1 | tee gcc.out" + rlRun "grep -i warning gcc.out" 1 + rlRun "grep -i error gcc.out" 1 + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/elfutils-debuginfod-client-not-being-called/dotest.sh b/tests/Regression/elfutils-debuginfod-client-not-being-called/dotest.sh new file mode 100644 index 0000000..a1d48fb --- /dev/null +++ b/tests/Regression/elfutils-debuginfod-client-not-being-called/dotest.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -xe + +rm -rf ~/.cache/debuginfod_client ~/.systemtap ||: + +debuginfod -p 8008 -d $(mktemp) -vvvvv >& debuginfod.log & +PID=$! + +sleep 5 + +export SYSTEMTAP_DEBUGINFO_PATH=/tmp +export DEBUGINFOD_URLS="http://127.0.0.1:8008" + +# The following doesn't work on aarch64 and s390x because of: +# https://sourceware.org/bugzilla/show_bug.cgi?id=25498 +# stap -p2 -e 'probe kernel.function("vfs_read") {println(pp())}' ||: + +stap -p2 -e 'probe process("/bin/true").function("main") {println(pp())}' -c /bin/true ||: + +sleep 5 + +kill -9 $PID + +grep 'started http server on' debuginfod.log +grep 'searching for buildid=[a-z0-9]* artifacttype=debuginfo' debuginfod.log + + diff --git a/tests/Regression/elfutils-debuginfod-client-not-being-called/main.fmf b/tests/Regression/elfutils-debuginfod-client-not-being-called/main.fmf new file mode 100644 index 0000000..0b9f61b --- /dev/null +++ b/tests/Regression/elfutils-debuginfod-client-not-being-called/main.fmf @@ -0,0 +1,15 @@ +summary: elfutils-debuginfod-client-not-being-called +description: '' +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - elfutils-debuginfod +duration: 48h +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1778921 +extra-summary: /tools/systemtap/Regression/elfutils-debuginfod-client-not-being-called +extra-task: /tools/systemtap/Regression/elfutils-debuginfod-client-not-being-called +tag: fedora diff --git a/tests/Regression/elfutils-debuginfod-client-not-being-called/runtest.sh b/tests/Regression/elfutils-debuginfod-client-not-being-called/runtest.sh new file mode 100755 index 0000000..79d9197 --- /dev/null +++ b/tests/Regression/elfutils-debuginfod-client-not-being-called/runtest.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/elfutils-debuginfod-client-not-being-called +# Description: elfutils-debuginfod-client-not-being-called +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TMP=$(mktemp -d)" + rlRun "cp dotest.sh $TMP/" + rlRun "pushd $TMP" + rlPhaseEnd + + rlPhaseStartTest + rlRun "bash dotest.sh" || + rlRun "cat debuginfod.log" + rlFileSubmit debuginfod.log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TMP" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/ftrace-logging-tapset-not-working-as-expected-in/hellotrace.stp b/tests/Regression/ftrace-logging-tapset-not-working-as-expected-in/hellotrace.stp new file mode 100644 index 0000000..e390200 --- /dev/null +++ b/tests/Regression/ftrace-logging-tapset-not-working-as-expected-in/hellotrace.stp @@ -0,0 +1,8 @@ +probe begin +{ + printf ( "hello trace : printf\n") + printk (20,"hello trace : printk") + ftrace ( "hello trace : ftrace\n") + exit () +} + diff --git a/tests/Regression/ftrace-logging-tapset-not-working-as-expected-in/main.fmf b/tests/Regression/ftrace-logging-tapset-not-working-as-expected-in/main.fmf new file mode 100644 index 0000000..370611b --- /dev/null +++ b/tests/Regression/ftrace-logging-tapset-not-working-as-expected-in/main.fmf @@ -0,0 +1,15 @@ +summary: ftrace-logging-tapset-not-working-as-expected-in +description: ftrace-logging-tapset-not-working-as-expected-in +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 48h +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1810216 +extra-summary: /tools/systemtap/Regression/ftrace-logging-tapset-not-working-as-expected-in +extra-task: /tools/systemtap/Regression/ftrace-logging-tapset-not-working-as-expected-in +tag: fedora diff --git a/tests/Regression/ftrace-logging-tapset-not-working-as-expected-in/runtest.sh b/tests/Regression/ftrace-logging-tapset-not-working-as-expected-in/runtest.sh new file mode 100755 index 0000000..dc4c2a2 --- /dev/null +++ b/tests/Regression/ftrace-logging-tapset-not-working-as-expected-in/runtest.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/ftrace-logging-tapset-not-working-as-expected-in +# Description: ftrace-logging-tapset-not-working-as-expected-in +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" + +LOG1=$(mktemp) +LOG2=$(mktemp) + +rlJournalStart + rlPhaseStartTest + rlRun "mount | grep -F -i -e 'debugfs on' -e 'on /sys/kernel/debug type debugfs'" + rlRun "cat /sys/kernel/debug/tracing/tracing_on | grep '^1$'" + rlRun "journalctl > $LOG1" + rlRun "stap -g -k -v hellotrace.stp" + rlRun "journalctl > $LOG2" + rlRun "diff $LOG1 $LOG2 | grep '^>.*hello trace : printk'" + rlRun "rm $LOG1 $LOG2" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/ipv6-tapset-support/main.fmf b/tests/Regression/ipv6-tapset-support/main.fmf new file mode 100644 index 0000000..8104026 --- /dev/null +++ b/tests/Regression/ipv6-tapset-support/main.fmf @@ -0,0 +1,17 @@ +summary: Test for BZ#822503 (ipv6 tapset support) +description: ipv6 tapset support +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap + - nfs-utils + - setup +duration: 50m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=822503 +extra-summary: /tools/systemtap/Regression/ipv6-tapset-support +extra-task: /tools/systemtap/Regression/ipv6-tapset-support +tag: fedora diff --git a/tests/Regression/ipv6-tapset-support/nfsd.proc.lookup.stp b/tests/Regression/ipv6-tapset-support/nfsd.proc.lookup.stp new file mode 100755 index 0000000..86db264 --- /dev/null +++ b/tests/Regression/ipv6-tapset-support/nfsd.proc.lookup.stp @@ -0,0 +1,12 @@ +#!/usr/bin/stap + +# http://sourceware.org/systemtap/examples/network/nfsdtop.stp + +probe nfsd.proc.lookup { + printf("%s %s\n", client_ip, filename); +} + +probe timer.ms(100000) { + exit (); +} + diff --git a/tests/Regression/ipv6-tapset-support/runtest.sh b/tests/Regression/ipv6-tapset-support/runtest.sh new file mode 100755 index 0000000..a05d136 --- /dev/null +++ b/tests/Regression/ipv6-tapset-support/runtest.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/ipv6-tapset-support +# Description: Test for BZ#822503 (ipv6 tapset support) +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 +. /etc/os-release || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlLogInfo "Related bugs: Fedora rawhide 6.2.0-0.rc8.57.fc39.x86_64 bz2177192" + rlAssertRpm nfs-utils + rlRun "uname -r" + rlRun "which stap" + + rlRun "TMPD=$(mktemp -d --tmpdir=$HOME tmp.XXXXXXX)" + rlRun "mkdir $TMPD/{A,B}" + rlRun "chmod --recursive 0777 $TMPD" + rlRun "STAPLOG=$(mktemp)" + + rlServiceStart rpcbind + sleep 5 + NFS_SERVICE=nfs + rlIsRHEL '>=8' && NFS_SERVICE=nfs-server + [ $ID == 'fedora' ] && test $VERSION_ID -ge 38 && NFS_SERVICE=nfs-server + rlServiceStart $NFS_SERVICE + sleep 10 + rlRun "exportfs -ua" + rlRun "exportfs -i -o 'rw,no_root_squash' *:$TMPD/A" + rlPhaseEnd + + rlPhaseStartTest + # ======= work around bz1605574 + rlLogInfo "Let's check if we can compile the module." + rlLogInfo "In case we can't, we'll go ahead with prologue searching." + set -x + EXTRA_SWITCHES='' + stap -p4 nfsd.proc.lookup.stp || EXTRA_SWITCHES="-P" + set +x + # ============================= + + # mount is sufficient to invoke nfsd.proc.lookup + rlRun "stap $EXTRA_SWITCHES -v -c 'mount -t nfs -v [::1]:$TMPD/A $TMPD/B' nfsd.proc.lookup.stp |& tee $STAPLOG" + rlRun "umount $TMPD/B" + rlRun "grep 'Unsupported Address Family' $STAPLOG" 1 + rlRun "grep -E '^\[0000:0000:0000:0000:0000:0000:0000:0001\]:[0-9]+.*$(basename $TMPD)' $STAPLOG" + rlPhaseEnd + + rlPhaseStartCleanup + rlServiceRestore $NFS_SERVICE + rlServiceRestore rpcbind + rlRun "rm -rf $TMPD $STAPLOG" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/irq-vector-tracepoints/main.fmf b/tests/Regression/irq-vector-tracepoints/main.fmf new file mode 100644 index 0000000..1093c2c --- /dev/null +++ b/tests/Regression/irq-vector-tracepoints/main.fmf @@ -0,0 +1,16 @@ +summary: irq-vector-tracepoints +description: irq-vector-tracepoints +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap-devel + - kernel-debuginfo +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1020437 +extra-summary: /tools/systemtap/Regression/irq-vector-tracepoints +extra-task: /tools/systemtap/Regression/irq-vector-tracepoints +tag: fedora diff --git a/tests/Regression/irq-vector-tracepoints/runtest.sh b/tests/Regression/irq-vector-tracepoints/runtest.sh new file mode 100755 index 0000000..6f11faa --- /dev/null +++ b/tests/Regression/irq-vector-tracepoints/runtest.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/irq-vector-tracepoints +# Description: irq-vector-tracepoints +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlRun "TMPDIR=$(mktemp -d)" + rlRun "pushd $TMPDIR" + rlRun "mount -t debugfs /dev/null /sys/kernel/debug" 0-255 + rlRun "test -d /sys/kernel/debug/tracing/events" + rlPhaseEnd + + rlPhaseStart FAIL "Systemtap sanity check" + rlRun "stap --version" + rlRun "stap -v -e 'probe kernel.function(\"vfs_read\"){ exit() }'" + rlPhaseEnd + + rlPhaseStart FAIL "Create list of all kernel tracepoints known to stap" + rlRun "stap -l 'kernel.trace(\"*\")' > tracepoints" + rlFileSubmit tracepoints + rlPhaseEnd + + rlPhaseStart FAIL "Check irq_vectors" + dir='/sys/kernel/debug/tracing/events/irq_vectors' + if test -d $dir; then + for p in $( find $dir -mindepth 1 -type d | awk -F\/ '{print $NF}' ); do + rlLogInfo "Checking $p" + rlRun "grep -q $p tracepoints" + done + # additional checks + rlRun "stap -vp4 -e 'probe kernel.trace(\"local_timer_entry\") {println(pp())}'" + rlRun "stap -vp4 -e 'probe kernel.trace(\"reschedule_entry\") {println(pp())}'" + else + if arch | grep -E 'x86_64|i[36]86'; then + rlLogError "$dir does not exist" + else + rlLogInfo "$dir does not exist" + fi + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/netdev-receive/main.fmf b/tests/Regression/netdev-receive/main.fmf new file mode 100644 index 0000000..a5e9730 --- /dev/null +++ b/tests/Regression/netdev-receive/main.fmf @@ -0,0 +1,15 @@ +summary: netdev.receive +description: bz1518462 netdev.receive +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1518462 +extra-summary: /tools/systemtap/Regression/netdev-receive +extra-task: /tools/systemtap/Regression/netdev-receive +tag: fedora diff --git a/tests/Regression/netdev-receive/runtest.sh b/tests/Regression/netdev-receive/runtest.sh new file mode 100755 index 0000000..b294186 --- /dev/null +++ b/tests/Regression/netdev-receive/runtest.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/netdev-receive +# Description: netdev.receive +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2017 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" + +rlJournalStart + rlPhaseStartTest + rlRun "TMPFILE=$(mktemp)" + rlRun "stap -o $TMPFILE -ve 'probe netdev.receive{log(\"HIT\") exit()}' -c 'ping -c1 localhost'" + rlRun "cat $TMPFILE" + rlRun "grep HIT $TMPFILE" + rlRun "rm $TMPFILE" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/pass-4-failure-netfilter-examples/main.fmf b/tests/Regression/pass-4-failure-netfilter-examples/main.fmf new file mode 100644 index 0000000..b2fb5f9 --- /dev/null +++ b/tests/Regression/pass-4-failure-netfilter-examples/main.fmf @@ -0,0 +1,17 @@ +summary: Test for BZ#1055778 (Pass 4 failure on RHEL7 for examples) +description: Test for BZ#1055778 (Pass 4 failure on RHEL7 for examples) +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - valgrind + - systemtap + - systemtap-testsuite +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1055778 +extra-summary: /tools/systemtap/Regression/pass-4-failure-netfilter-examples +extra-task: /tools/systemtap/Regression/pass-4-failure-netfilter-examples +tag: fedora diff --git a/tests/Regression/pass-4-failure-netfilter-examples/runtest.sh b/tests/Regression/pass-4-failure-netfilter-examples/runtest.sh new file mode 100755 index 0000000..b2d8156 --- /dev/null +++ b/tests/Regression/pass-4-failure-netfilter-examples/runtest.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/pass-4-failure-netfilter-examples +# Description: Test for BZ#1055778 (Pass 4 failure on RHEL7 for examples) +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2014 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" + +rlJournalStart + rlPhaseStartSetup + TESTS=$(mktemp) + rlRun "rpm -qa | grep -F systemtap-testsuite" + rlPhaseEnd + + rpm -qa | grep systemtap-testsuite | xargs rpm -ql \ + | grep -E 'netfilter_drop.stp|netfilter_summary.stp' \ + | while read line; do + rlPhaseStart FAIL "Testing $line" + rlRun "stap -p4 $line -v -g TCP 1" && \ + echo $line >> $TESTS + rlPhaseEnd + done + + rlPhaseStart FAIL "Check what was tested" + rlRun "grep netfilter_drop.stp $TESTS" + rlRun "grep netfilter_summary.stp $TESTS" + rm -f $TESTS + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/python-probing/list.stp b/tests/Regression/python-probing/list.stp new file mode 100755 index 0000000..f68e700 --- /dev/null +++ b/tests/Regression/python-probing/list.stp @@ -0,0 +1,22 @@ +#!/usr/bin/stap -v +/* + Example usage of the Python systemtap tapset to show a nested view of all + Python function calls (and returns) across the whole system. + + Run this using + stap systemtap-example.stp + to instrument all Python processes on the system, or (for example) using + stap systemtap-example.stp -c COMMAND + to instrument a specific program (implemented in Python) +*/ +probe python.function.entry +{ + if ( filename =~ "random" ) + printf("%s => %s in %s:%d\n", thread_indent(1), funcname, filename, lineno); +} + +probe python.function.return +{ + if ( filename =~ "random" ) + printf("%s <= %s in %s:%d\n", thread_indent(-1), funcname, filename, lineno); +} diff --git a/tests/Regression/python-probing/main.fmf b/tests/Regression/python-probing/main.fmf new file mode 100644 index 0000000..c4afdea --- /dev/null +++ b/tests/Regression/python-probing/main.fmf @@ -0,0 +1,30 @@ +summary: Systemtap static probes test +description: Systemtap static probes test +contact: Petr Splichal +component: + - python + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - python + - python-debuginfo + - python3-debuginfo + - python3.9-debuginfo + - systemtap + - python2 + - python3 + - elfutils + - yum-utils +adjust: + - environment: + PYTHON: python3 + when: distro is defined and distro == rhel-9 + because: "Test with python (i.e. python3) on rhel-9" + - enabled: false + when: distro is defined and distro == rhel-10 + because: "Test not relevant for rhel10" +duration: 15m +extra-summary: /CoreOS/python/Sanity/systemtap +extra-task: /CoreOS/python/Sanity/systemtap +tag: fedora diff --git a/tests/Regression/python-probing/runtest.sh b/tests/Regression/python-probing/runtest.sh new file mode 100755 index 0000000..c9cbc40 --- /dev/null +++ b/tests/Regression/python-probing/runtest.sh @@ -0,0 +1,88 @@ +#!/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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 +. /etc/os-release || exit 1 + +# Packages to be tested +PACKAGES="${PACKAGES:-python2}" +# Other required packages +REQUIRES=${REQUIRES:-} +# Binary name parametrized +PYTHON="${PYTHON:-python2}" + +rlJournalStart + rlPhaseStartSetup + # rlAssertRpm --all + 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" + + # Install needed debuginfo, best effort + rlLogInfo "DEBUGINFOD_URLS=$DEBUGINFOD_URLS" + rlLogInfo "DEBUGINFOD_TIMEOUT=$DEBUGINFOD_TIMEOUT" + rlRun "L=$(stap -p2 -e 'probe python.function.entry {exit()}' | awk -F\" '/process/ {print $2}')" 0-255 + rlRun "debuginfo-install -y $L /usr/bin/python\*" 0-255 + rlPhaseEnd + + rlPhaseStartTest "Verifying ELF file for presence of .probes section" + for lib in /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 + # bz2152970 is a known probem + [ "$ID" == "fedora" ] && [ "$script" == "top" ] && continue + 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" + # Checking for random in the list output (python3) + # stap -L 'process("/usr/lib*/libpython*.so*").mark("*")' + # no markers with python3. PViktori mentions that python3 + # is going to use JIT, and that will probably drop the + # markers entirely. + rlRun "grep '/usr/lib.*python.*random.py' '$script'" \ + 0 "Checking for random in the $script output" + rlPhaseEnd + done + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/python-probing/test.py b/tests/Regression/python-probing/test.py new file mode 100755 index 0000000..65cc0b7 --- /dev/null +++ b/tests/Regression/python-probing/test.py @@ -0,0 +1,3 @@ +import random, time +print(random.random()) +time.sleep(3) diff --git a/tests/Regression/python-probing/top.stp b/tests/Regression/python-probing/top.stp new file mode 100755 index 0000000..f32fbf9 --- /dev/null +++ b/tests/Regression/python-probing/top.stp @@ -0,0 +1,19 @@ +#!/usr/bin/stap -v + +global fn_calls; + +probe python.function.entry +{ + fn_calls[pid(), filename, funcname, lineno] += 1; +} + +probe timer.ms(1000) { + foreach ([pid, filename, funcname, lineno] in fn_calls- limit 1000) { + if (filename =~ "random") + printf("%6d %80s %6d %30s %6d\n", + pid, filename, lineno, funcname, + fn_calls[pid, filename, funcname, lineno]); + } + + delete fn_calls; +} diff --git a/tests/Regression/second-command-not-captured/main.fmf b/tests/Regression/second-command-not-captured/main.fmf new file mode 100644 index 0000000..6ade74e --- /dev/null +++ b/tests/Regression/second-command-not-captured/main.fmf @@ -0,0 +1,17 @@ +summary: second-command-not-captured +description: second-command-not-captured +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap + - ruby + - ruby-libs +duration: 48h +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1857749 +extra-summary: /tools/systemtap/Regression/second-command-not-captured +extra-task: /tools/systemtap/Regression/second-command-not-captured +tag: fedora diff --git a/tests/Regression/second-command-not-captured/ruby-exercise.stp b/tests/Regression/second-command-not-captured/ruby-exercise.stp new file mode 100644 index 0000000..8c5f42b --- /dev/null +++ b/tests/Regression/second-command-not-captured/ruby-exercise.stp @@ -0,0 +1,9 @@ +probe ruby.method.entry, ruby.cmethod.entry { + if((classname =~ "Array") && (methodname =~ "push")) + printf("%d -> %s::%s %s:%d\n", tid(), classname, methodname, file, line); +} + +probe ruby.method.return, ruby.cmethod.return { + if((classname =~ "Array") && (methodname =~ "push")) + printf("%d <- %s::%s %s:%d\n", tid(), classname, methodname, file, line); +} diff --git a/tests/Regression/second-command-not-captured/runtest.sh b/tests/Regression/second-command-not-captured/runtest.sh new file mode 100755 index 0000000..6be076b --- /dev/null +++ b/tests/Regression/second-command-not-captured/runtest.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/second-command-not-captured +# Description: second-command-not-captured +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" + +STP_OVERLOAD_THRESHOLD='' +arch | grep -F ppc64le && STP_OVERLOAD_THRESHOLD='-DSTP_OVERLOAD_THRESHOLD=1000000000LL' + +rlJournalStart + rlPhaseStart "WARN" "Attempt to hack around possible ruby tapset problem" + rlRun "rpm -q ruby-libs" + if rpm -V ruby-libs; then + rlLogInfo "Skipping the hack attempt" + else + rlRun "dnf update ruby\* -y" + rlRun "dnf -y reinstall ruby-libs" + rlRun "rpm -q ruby-libs" + rlRun "rpm -V ruby-libs" + fi + rlPhaseEnd + + rlPhaseStartTest + rlLog "`which stap`" + rlLog "`stap -V`" + rlRun "stap $STP_OVERLOAD_THRESHOLD -v ./ruby-exercise.stp -c ./test.sh -o stap.log" + rlRun "grep 'Array::push' stap.log" || + rlFileSubmit "stap.log" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/second-command-not-captured/test.sh b/tests/Regression/second-command-not-captured/test.sh new file mode 100755 index 0000000..d308ba2 --- /dev/null +++ b/tests/Regression/second-command-not-captured/test.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +ruby -e 'puts "ABC"' +ruby -e '[1, 2, 3].push(4)' +sleep 10 diff --git a/tests/Regression/semantic-error-nfs-proc-read_setup/main.fmf b/tests/Regression/semantic-error-nfs-proc-read_setup/main.fmf new file mode 100644 index 0000000..0ea2cab --- /dev/null +++ b/tests/Regression/semantic-error-nfs-proc-read_setup/main.fmf @@ -0,0 +1,15 @@ +summary: semantic-error-nfs-proc-read_setup +description: semantic-error-nfs-proc-read_setup +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 5m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=884951 +extra-summary: /tools/systemtap/Regression/semantic-error-nfs-proc-read_setup +extra-task: /tools/systemtap/Regression/semantic-error-nfs-proc-read_setup +tag: fedora diff --git a/tests/Regression/semantic-error-nfs-proc-read_setup/nfs.proc.read_setup.stp b/tests/Regression/semantic-error-nfs-proc-read_setup/nfs.proc.read_setup.stp new file mode 100644 index 0000000..c6974c7 --- /dev/null +++ b/tests/Regression/semantic-error-nfs-proc-read_setup/nfs.proc.read_setup.stp @@ -0,0 +1,5 @@ +probe nfs.proc.read_setup{ + println("nfs.proc.read_setup server_ip: ", server_ip); + println("nfs.proc.read_setup prot: ", prot); +} + diff --git a/tests/Regression/semantic-error-nfs-proc-read_setup/runtest.sh b/tests/Regression/semantic-error-nfs-proc-read_setup/runtest.sh new file mode 100755 index 0000000..d14e39b --- /dev/null +++ b/tests/Regression/semantic-error-nfs-proc-read_setup/runtest.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/semantic-error-nfs-proc-read_setup +# Description: semantic-error-nfs-proc-read_setup +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlRun "uname -r" + rlRun "rpm -qa | grep ^kernel | sort" + rlRun "rpm -qa | grep systemtap | sort" + rlRun "which stap" + rlPhaseEnd + + rlPhaseStartTest + rlRun "stap -v -p 2 nfs.proc.read_setup.stp" + rlPhaseEnd + +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/semantic-errors-bz1062076/main.fmf b/tests/Regression/semantic-errors-bz1062076/main.fmf new file mode 100644 index 0000000..e5bcbbf --- /dev/null +++ b/tests/Regression/semantic-errors-bz1062076/main.fmf @@ -0,0 +1,15 @@ +summary: semantic-errors-bz1062076 +description: '' +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1062076 +extra-summary: /tools/systemtap/Regression/semantic-errors-bz1062076 +extra-task: /tools/systemtap/Regression/semantic-errors-bz1062076 +tag: fedora diff --git a/tests/Regression/semantic-errors-bz1062076/runtest.sh b/tests/Regression/semantic-errors-bz1062076/runtest.sh new file mode 100755 index 0000000..bd89675 --- /dev/null +++ b/tests/Regression/semantic-errors-bz1062076/runtest.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/semantic-errors-bz1062076 +# Description: semantic-errors-bz1062076 +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2014 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartTest + rlLogInfo "Related bugs: Fedora rawhide 6.2.0-0.rc8.57.fc39.x86_64 bz2177196" + rlLogInfo "Check if we might want to try out prologue search" + p="" + stap -vp4 script.stp >& /dev/null || p="-P" + rlRun "stap $p -vp4 script.stp" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/semantic-errors-bz1062076/script.stp b/tests/Regression/semantic-errors-bz1062076/script.stp new file mode 100644 index 0000000..7527474 --- /dev/null +++ b/tests/Regression/semantic-errors-bz1062076/script.stp @@ -0,0 +1,3 @@ +probe nfsd.close? { printf("%s\n", filename) } probe never { exit() } +probe sunrpc.clnt.clone_client { print(progname) } +probe scsi.iodone { printf("%d, %d, %d, %d, %d, %d, %d, %d\n", host_no, channel, lun, dev_id, device_state, data_direction, req_addr, scsi_timer_pending ) } diff --git a/tests/Regression/semantic-errors-bz953776/main.fmf b/tests/Regression/semantic-errors-bz953776/main.fmf new file mode 100644 index 0000000..9dcb8c8 --- /dev/null +++ b/tests/Regression/semantic-errors-bz953776/main.fmf @@ -0,0 +1,17 @@ +summary: semantic-errors-bz953776 +description: '' +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap + - perf + - gcc +duration: 60m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=953776 +extra-summary: /tools/systemtap/Regression/semantic-errors-bz953776 +extra-task: /tools/systemtap/Regression/semantic-errors-bz953776 +tag: fedora diff --git a/tests/Regression/semantic-errors-bz953776/runtest.sh b/tests/Regression/semantic-errors-bz953776/runtest.sh new file mode 100755 index 0000000..7ea0f29 --- /dev/null +++ b/tests/Regression/semantic-errors-bz953776/runtest.sh @@ -0,0 +1,169 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/semantic-errors-bz953776 +# Description: semantic-errors-bz953776 +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2014 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +_rhelmajor=$(rpm --eval '%{rhel}') +_arch=$(arch) + +function perf_probe_failed () +{ + probe=$1 + perf probe -d $probe ||: + perf probe --add $probe + retval=$? + test $retval -eq 0 && \ + rlLogInfo "Running perf probe --add $probe PASSED" || \ + rlLogInfo "Running perf probe --add $probe FAILED" + perf probe -d $probe ||: + if test $retval -eq 0; then + return 1 + else + return 0 + fi +} + +function perf_found_none_of () +{ + ret=0 + for f in "$@"; do + perf_probe_failed $f || ret=1 + done + return $ret +} + +rlJournalStart + # CHECK FOR PERF ---------------------------------------------- + rlPhaseStart FAIL "CHECK FOR PERF" + rlRun "perf --version" + rlPhaseEnd + + rlPhaseStartSetup + rlRun "TMPDIR=$(mktemp -d)" + rlRun "pushd $TMPDIR" + + # prepare sigaltstack for case-5 + cat > sigaltstack.c < +#include +void handler(int sig) +{ + write(2, "stack overflow\n", 15); + _exit(1); +} +unsigned infinite_recursion(unsigned x) { + return infinite_recursion(x)+1; +} +int main() +{ + static char stack[SIGSTKSZ]; + stack_t ss = { + .ss_size = SIGSTKSZ, + .ss_sp = stack, + }; + struct sigaction sa = { + .sa_handler = handler, + .sa_flags = SA_ONSTACK + }; + sigaltstack(&ss, 0); + sigfillset(&sa.sa_mask); + sigaction(SIGSEGV, &sa, 0); + infinite_recursion(0); +} +EOF + rlRun "gcc -o sigaltstack sigaltstack.c" + rlPhaseEnd + + p="" + uname -m | grep -q ^ppc && p="-P" + p="$p -E 'probe timer.s(900){error(\"probe timeout after 15 minutes\")}'" + + export p + + ( + # Work around rhel10 ppc64le specific error::dwarf + test $_rhelmajor -eq 10 && arch | fgrep ppc64le && exit + rlPhaseStart FAIL 'case-1' + rlRun "stap $p -v -e 'probe syscall.close { println(fd); exit(); }'" + rlPhaseEnd + ) + + # After fixing bz1657681, this constraint can be removed + if [[ $(rpm --eval %rhel) -le 7 ]]; then + if arch | grep -vq ppc; then + rlPhaseStart FAIL 'case-2' + # https://bugzilla.redhat.com/show_bug.cgi?id=1657681 + rlRun "stap $p -v -e 'probe socket.close { print(protocol); print(family); print(state); print(flags); print(type); exit() }'" + rlPhaseEnd + fi + fi + + ( + test $_rhelmajor -le 8 && exit + perf_found_none_of "sys_read" "__arm64_sys_read" "do_syscall_64" && exit + test $_rhelmajor -ge 9 && test $_arch = ppc64le -o $_arch = aarch64 && p="$p -p4" # no hits + rlPhaseStart FAIL 'case-3' + rlRun "stap $p -v -e 'probe kernel.function(\"sys_read\").return!, kernel.function(\"__arm64_sys_read\").return!, kernel.function(\"do_syscall_64\").return { println(probefunc()) exit()}'" + rlPhaseEnd + ) + + ( + # Work around rhel10 ppc64le specific error::dwarf + test $_rhelmajor -eq 10 && arch | fgrep ppc64le && exit + rlPhaseStart FAIL 'case-4' + rlRun "stap $p -v -e 'probe syscall.open, syscall.openat { if (\"open\" == execname()) println(argstr); exit() }'" + rlPhaseEnd + ) + + rlPhaseStart FAIL 'case-5' + rlRun "stap $p -ve 'probe syscall.sigaltstack { println(name); exit() }' -c './sigaltstack || true'" + rlPhaseEnd + + # gcc 8.2.1->8.3.1 change related to systemtap debuginfo regression in rhel-8.1.0, kernel -84 -> -85 + # https://bugzilla.redhat.com/show_bug.cgi?id=1709831#c17 + # ( grep -F RESULT: /tmp/typescript | sort -u ) + rlPhaseStart FAIL 'case-6' + rlRun "stap $p -vp4 -e 'probe sunrpc.clnt.shutdown_client { println(servername) }'" + rlPhaseEnd + + rlPhaseStart FAIL 'case-7' + rlRun "stap $p -vp4 -e 'probe sunrpc.clnt.bind_new_program { println(servername) }'" + rlPhaseEnd + + rlPhaseStart FAIL 'case-8' + rlRun "stap $p -vp4 -e 'probe sunrpc.clnt.bind_new_program { println(servername, vers) }'" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/small-tests/main.fmf b/tests/Regression/small-tests/main.fmf new file mode 100644 index 0000000..43e6b7d --- /dev/null +++ b/tests/Regression/small-tests/main.fmf @@ -0,0 +1,16 @@ +summary: Small tests +description: '' +contact: Martin Cermak +component: +- systemtap +test: ./runtest.sh +framework: beakerlib +recommend: +- systemtap +- systemtap-testsuite +- perf +- psmisc +duration: 300m +extra-summary: /tools/systemtap/Regression/small-tests +extra-task: /tools/systemtap/Regression/small-tests +tag: fedora diff --git a/tests/Regression/small-tests/runtest.sh b/tests/Regression/small-tests/runtest.sh new file mode 100755 index 0000000..31be18b --- /dev/null +++ b/tests/Regression/small-tests/runtest.sh @@ -0,0 +1,224 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/small-tests +# Description: suns small tests +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2014 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 +. /etc/os-release ||: + +PACKAGE="systemtap" + +_rhelmajor=$(rpm --eval '%{rhel}') +_arch=$(arch) + +function perf_probe_failed () +{ + probe=$1 + perf probe -d $probe ||: + perf probe --add $probe + retval=$? + test $retval -eq 0 && \ + rlLogInfo "Running perf probe --add $probe PASSED" || \ + rlLogInfo "Running perf probe --add $probe FAILED" + perf probe -d $probe ||: + if test $retval -eq 0; then + return 1 + else + return 0 + fi +} + +function perf_found_none_of () +{ + ret=0 + for f in "$@"; do + perf_probe_failed $f || ret=1 + done + return $ret +} + +rlJournalStart + # Check the environment --------------------------------------- + rlPhaseStart WARN "Check the environment" + rlRun "rpm -qa | grep -E '^(kernel|systemtap|perf)' | sort" + rlRun "uname -r" + rlRun "perf --version" + rlLogInfo "DEBUGINFOD_URLS=$DEBUGINFOD_URLS" + rlLogInfo "DEBUGINFOD_TIMEOUT=$DEBUGINFOD_TIMEOUT" + rlPhaseEnd + + # bz1162939 --------------------------------------------------- + ( + perf_probe_failed "vfs_read" && exit + rlPhaseStart FAIL "test 1 bz1162939" + rlRun "stap -e 'probe vfs.read{println(\"hit\"); exit()}' -c 'head -1 /etc/hosts' | grep -F hit" + rlPhaseEnd + ) + # bz1119335 --------------------------------------------------- + rlPhaseStart FAIL "test 2 bz1119335" + rlRun "man 8 staprun | grep 'STAP_FIPS_OVERRIDE'" + rlPhaseEnd + + # bz1153673 --------------------------------------------------- + ( + # Work around rhel10 ppc64le specific error::dwarf + test $_rhelmajor -eq 10 && arch | fgrep ppc64le && exit + rlPhaseStart FAIL "test 3 bz1153673" + _tested=0 + for _pkg in $( rpm -qa | grep systemtap-testsuite ); do + for _tc in $( rpm -ql $_pkg | grep 'alias_suffixes.stp$' ); do + stap -p4 $_tc && p="" || p="-P" + rlRun "stap $p -p4 $_tc" + _tested=1 + done + done + [[ $_tested -eq 0 ]] && rlFail "Not tested" + rlPhaseEnd + ) + + # bz1160837 --------------------------------------------------- + ( + perf_probe_failed "sd_init_command" && exit + rlPhaseStart FAIL "test 4 bz1160837" + _tested=0 + _prologue_search='' + for _pkg in $( rpm -qa | grep systemtap-testsuite ); do + for _tc in $( rpm -ql $_pkg | grep 'iostat-scsi.stp$' ); do + test $_arch = ppc64le && _prologue_search='-P' + rlRun "stap -g $_prologue_search $_tc 1 -c 'sleep 1'" + _tested=1 + done + done + [[ $_tested -eq 0 ]] && rlFail "Not tested" + rlPhaseEnd + ) + + # bz1203808 --------------------------------------------------- + rlPhaseStart FAIL "test 5 bz1203808" + _tested=0 + for _pkg in $( rpm -qa | grep systemtap-testsuite ); do + for _tc in $( rpm -ql $_pkg | grep 'vfs-all-probes.stp$' ); do + stap -wp4 $_tc && p="" || p="-P" + rlRun "stap $p -w -p4 $_tc" + _tested=1 + done + done + [[ $_tested -eq 0 ]] && rlFail "Not tested" + rlPhaseEnd + + # bz1269062 --------------------------------------------------- + rlPhaseStart FAIL "test 6 bz1269062" + rlRun "stap -c sync --suppress-handler-errors -e 'probe ioscheduler.elv_add_request{println(elevator_name) exit()}'" + rlPhaseEnd + + # bz528792 --------------------------------------------------- + ( + # Not relevant on rhel-9 because of kernel commit cad6967ac10843a70842cd39c7b53412901dd21f that removes + # _do_fork() and replaces it with new kernel_clone() + perf_found_none_of "_do_fork" "do_fork" "sys_clone" && exit + + rlPhaseStart FAIL "test 7 bz528792" + if test $_arch = ppc64le; then + # https://bugzilla.redhat.com/show_bug.cgi?id=1652740#c4 - We can not reach any function parameters, namely $clone_flags + rlRun "stap -ve 'probe kernel.function(\"_do_fork\")!, kernel.function(\"do_fork\")!, kernel.function(\"sys_clone\") { println(pp()) exit() }' -c \"bash -c 'while sleep 1; do /bin/true; done'\"" + else + rlRun "stap -ve 'probe kernel.function(\"_do_fork\")!, kernel.function(\"do_fork\")!, kernel.function(\"sys_clone\") { printf(\"%x\n\",\$clone_flags) exit() }' -c \"bash -c 'while sleep 1; do /bin/true; done'\"" + fi + rlPhaseEnd + ) + + # bz1890702 --------------------------------------------------- + ( + perf_probe_failed "vfs_open" && exit + rlPhaseStart FAIL "test 8 bz1890702" + rlRun "stap -g --suppress-time-limits -e 'probe kernel.function(\"vfs_open\") { printf(\"%s(path: %s)\", ppfunc(), \$path\$) ; exit() }' -c 'cat /etc/hosts'" + rlPhaseEnd + ) + + # bz1904216 --------------------------------------------------- + rlPhaseStart FAIL "test 9 bz1904216" + rlRun "stap -p4 -DSTP_NO_OVERLOAD -t -c 'sleep 0.25' -e 'probe kernel.trace(\"bcache:bcache_btree_set_root\") { if (pid() == 0) printf(\"probe hit\n\"); }'" + rlPhaseEnd + + # bz1940804 --------------------------------------------------- + rlPhaseStart FAIL "test 10 bz1940804" + rlRun "stap -e 'probe process(\"/bin/bash\").function(\"main\") {println(pn()) }' -c '/bin/bash --help'" + rlPhaseEnd + + # bz1940945 --------------------------------------------------- + rlPhaseStart FAIL "test 11 bz1940945" + rlRun "stap -c sync --suppress-handler-errors -e 'probe ioscheduler.elv_add_request{println(elevator_name) exit()}'" + rlPhaseEnd + + # bz1940761 --------------------------------------------------- + rlPhaseStart FAIL "test 12 bz1940761" + rlRun "stap -v /usr/share/systemtap/examples/process/strace.stp -w -c \"echo hello world\"" + rlPhaseEnd + + # broken-tapset-print-ubacktrace ------------------------------ + rlPhaseStart FAIL "test 13 broken-tapset-print-ubacktrace" + rlRun "stap -p4 -e 'probe begin { print_ubacktrace() }'" + rlPhaseEnd + + # Protected from elision -------------------------------------- + rlPhaseStart FAIL "test 14 protected from elision" + rlRun "stap -v -e 'probe nfs.fop.fsync {} probe begin {print(\"Protected from elision\")}' -c true |\ + grep -F 'Protected from elision'" + rlPhaseEnd + + # bz544207 ---------------------------------------------------- + rlPhaseStart FAIL "test 15 bz544207" + extra_opts="" + stap -vp4 -e 'probe nfs.proc.write_setup{ println(how) }' || extra_opts="-P" + rlRun "stap $extra_opts -vp4 -e 'probe nfs.proc.write_setup{ println(how) }'" + rlPhaseEnd + + # bz544209 ---------------------------------------------------- + rlPhaseStart FAIL "test 16 bz544209" + rlRun "stap -vp2 -e 'probe sunrpc.clnt.create_client.return {}'" + rlPhaseEnd + + # bz592830 ---------------------------------------------------- + rlPhaseStart FAIL "test 17 bz592830" + rlRun "stap -vp2 -e 'probe signal.check_ignored.return {println(1)}'" + rlPhaseEnd + + # caller-does-not-work ---------------------------------------- + rlPhaseStart FAIL "test 18 caller-does-not-work" + rlRun "stap -ve 'probe kernel.function(\"vfs_read\") \ + { printf(\"%s\n\", caller()); exit() }' 2>&1 | tee strace.log" + rlPhaseEnd + + # missing-rpc-tracepoints ------------------------------------- + rlPhaseStart FAIL "test 19 missing-rpc-tracepoints" + rlRun "stap -L 'kernel.trace(\"rpc*\")'" + rlPhaseEnd + + rlPhaseStart WARN "Check for stuff we failed to clean up" + rlRun "pstree -p $$" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/stap-ERROR-Build-id-mismatch-with/main.fmf b/tests/Regression/stap-ERROR-Build-id-mismatch-with/main.fmf new file mode 100644 index 0000000..2a96a6c --- /dev/null +++ b/tests/Regression/stap-ERROR-Build-id-mismatch-with/main.fmf @@ -0,0 +1,15 @@ +summary: Test for BZ#1566422 (stap ERROR Build-id mismatch with) +description: '' +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 48h +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1566422 +extra-summary: /tools/systemtap/Regression/stap-ERROR-Build-id-mismatch-with +extra-task: /tools/systemtap/Regression/stap-ERROR-Build-id-mismatch-with +tag: fedora diff --git a/tests/Regression/stap-ERROR-Build-id-mismatch-with/runtest.sh b/tests/Regression/stap-ERROR-Build-id-mismatch-with/runtest.sh new file mode 100755 index 0000000..f026393 --- /dev/null +++ b/tests/Regression/stap-ERROR-Build-id-mismatch-with/runtest.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/stap-ERROR-Build-id-mismatch-with +# Description: Test for BZ#1566422 (stap ERROR Build-id mismatch with) +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2018 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" + +rlJournalStart + rlPhaseStartTest + if arch | grep -q s390x; then + rlLogWarning "Test not relevant" + else + rlRun "sudo modprobe igb" + rlRun "stap -e 'probe module(\"igb\").function(\"igb_*_module\") { printf(\"%s: %s.\n\", ctime(gettimeofday_s()), ppfunc()); }' -c \"bash -c 'sudo rmmod igb; sudo modprobe igb'\"" + fi + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/stapio-possible-circular-locking-dependency/main.fmf b/tests/Regression/stapio-possible-circular-locking-dependency/main.fmf new file mode 100644 index 0000000..de6de2e --- /dev/null +++ b/tests/Regression/stapio-possible-circular-locking-dependency/main.fmf @@ -0,0 +1,15 @@ +summary: Test for BZ#1020207 (stapio possible circular locking dependency) +description: '' +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 4h +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1020207 +extra-summary: /tools/systemtap/Regression/stapio-possible-circular-locking-dependency +extra-task: /tools/systemtap/Regression/stapio-possible-circular-locking-dependency +tag: fedora diff --git a/tests/Regression/stapio-possible-circular-locking-dependency/runtest.sh b/tests/Regression/stapio-possible-circular-locking-dependency/runtest.sh new file mode 100755 index 0000000..856197c --- /dev/null +++ b/tests/Regression/stapio-possible-circular-locking-dependency/runtest.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/stapio-possible-circular-locking-dependency +# Description: Test for BZ#1020207 (stapio possible circular locking dependency) +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2014 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlRun "TMPDIR=\$(mktemp -d)" + rlRun "pushd $TMPDIR" + cat > test5.stap < reproduce.sh < /proc/sys/vm/drop_caches + stap test5.stap -c "sleep 2" + if dmesg 2>&1 | grep "possible circular locking dependency detected"; then + dmesg + exit 1 + fi +done +exit 0 +EOF + + rlRun "chmod +x reproduce.sh" + rlPhaseEnd + + rlPhaseStartTest + TO=180 # timeout seconds + # when timeout TO is hit, exitcode 124 is returned + rlRun "timeout $TO ./reproduce.sh" 0,124 + # if issue doesn't get reproduced within TO, the test will pass + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/suspicious-RCU-usage/main.fmf b/tests/Regression/suspicious-RCU-usage/main.fmf new file mode 100644 index 0000000..aff4cb7 --- /dev/null +++ b/tests/Regression/suspicious-RCU-usage/main.fmf @@ -0,0 +1,15 @@ +summary: suspicious-RCU-usage +description: '' +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 48h +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1788662 +extra-summary: /tools/systemtap/Regression/suspicious-RCU-usage +extra-task: /tools/systemtap/Regression/suspicious-RCU-usage +tag: fedora diff --git a/tests/Regression/suspicious-RCU-usage/runtest.sh b/tests/Regression/suspicious-RCU-usage/runtest.sh new file mode 100755 index 0000000..8c8af00 --- /dev/null +++ b/tests/Regression/suspicious-RCU-usage/runtest.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/suspicious-RCU-usage +# Description: suspicious-RCU-usage +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" + +rlJournalStart + rlPhaseStartTest + dmesg1=$(mktemp) + dmesg2=$(mktemp) + diff=$(mktemp) + dmesg > $dmesg1 + rlRun "stap -e 'probe kernel.trace(\"*\"){}' -t -u -v -c '/bin/true'" + sleep 10 + dmesg > $dmesg2 + rlRun "diff $dmesg1 $dmesg2 |& tee $diff" + # Reproduced on hpe-moonshot-02-c02.hpe1.lab.eng.bos.redhat.com + # using kernel-4.18.0-167.el8.aarch64+debug and systemtap-4.2-1.el8.aarch64. + rlRun "grep -F -i rcu $diff" 1 + rm $dmesg{1,2} $diff + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/syscall-get-arguments-returning-wrong-value/main.fmf b/tests/Regression/syscall-get-arguments-returning-wrong-value/main.fmf new file mode 100644 index 0000000..12e3a31 --- /dev/null +++ b/tests/Regression/syscall-get-arguments-returning-wrong-value/main.fmf @@ -0,0 +1,16 @@ +summary: Test for BZ#1004059 (syscall_get_arguments() returning wrong value) +description: '' +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap + - perf +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1004059 +extra-summary: /tools/systemtap/Regression/syscall-get-arguments-returning-wrong-value +extra-task: /tools/systemtap/Regression/syscall-get-arguments-returning-wrong-value +tag: fedora diff --git a/tests/Regression/syscall-get-arguments-returning-wrong-value/runtest.sh b/tests/Regression/syscall-get-arguments-returning-wrong-value/runtest.sh new file mode 100755 index 0000000..3c81142 --- /dev/null +++ b/tests/Regression/syscall-get-arguments-returning-wrong-value/runtest.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/syscall-get-arguments-returning-wrong-value +# Description: Test for BZ#1004059 (syscall_get_arguments() returning wrong value) +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2014 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +_rhelmajor="0$(rpm --eval '%{rhel}')" + +ASMLINKAGE=''; +uname -m | grep -E 'i[36]86' && \ + ASMLINKAGE='asmlinkage();' + +SCRIPT=$( mktemp ) +cat > $SCRIPT <<-EOF +probe kernel.function("sys_open") { + $ASMLINKAGE + if (\$filename == pointer_arg(1)) { + exit(); + } else { + error("Possible manifestation of rhbz1004059."); + } +} +EOF + +function perf_probe_failed () +{ + probe=$1 + perf probe -d $probe ||: + perf probe --add $probe + retval=$? + test $retval -eq 0 && \ + rlLogInfo "Running perf probe --add $probe PASSED" || \ + rlLogInfo "Running perf probe --add $probe FAILED" + perf probe -d $probe ||: + if test $retval -eq 0; then + return 1 + else + return 0 + fi +} + +rlJournalStart + rlPhaseStartTest + ( + # Work around rhel10 ppc64le specific error::dwarf + test $_rhelmajor -eq 10 && arch | fgrep ppc64le && exit + perf_probe_failed "sys_open" && exit + stap -p4 $SCRIPT >&/dev/null && p="" || p='-P' + rlRun "stap $p -v $SCRIPT -c 'cat /dev/null'" + ) + rm $SCRIPT + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/main.fmf b/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/main.fmf new file mode 100644 index 0000000..9713fb6 --- /dev/null +++ b/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/main.fmf @@ -0,0 +1,15 @@ +summary: task-cwd-path-results-in-an-in-kernel-memory-leak +description: '' +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 48h +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1412691 +extra-summary: /tools/systemtap/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak +extra-task: /tools/systemtap/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak +tag: fedora diff --git a/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/reproducer.stp b/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/reproducer.stp new file mode 100644 index 0000000..ff15bbb --- /dev/null +++ b/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/reproducer.stp @@ -0,0 +1,10 @@ +probe kprocess.exit +{ + path=fullpath_struct_path(task_cwd_path(task_current())) + printf("%s\n", path) +} + +#probe timer.s(240) +#{ +# exit() +#} diff --git a/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/runtest.sh b/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/runtest.sh new file mode 100755 index 0000000..1a742f2 --- /dev/null +++ b/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/runtest.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak +# Description: task-cwd-path-results-in-an-in-kernel-memory-leak +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2017 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" + +rlJournalStart + rlPhaseStartTest + EXTRA="" + arch | grep -F ppc64le && EXTRA='-P' + + # We rely on (and check for) units to be kB + rlRun "test \"$( awk '/KernelStack/ {print $3}' /proc/meminfo )\" == \"kB\"" + rlRun "STACK1=$(awk '/KernelStack/ {print $2}' /proc/meminfo)" + rlRun "stap $EXTRA -w reproducer.stp -c 'bash ./trigger.sh' -o /dev/null" + rlRun "STACK2=$(awk '/KernelStack/ {print $2}' /proc/meminfo)" + rlRun "test $((STACK2 - 1000)) -le $STACK1" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/trigger.sh b/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/trigger.sh new file mode 100755 index 0000000..165bd9a --- /dev/null +++ b/tests/Regression/task-cwd-path-results-in-an-in-kernel-memory-leak/trigger.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +for i in `seq 1 2000`; do + ls / > /dev/null +done + + diff --git a/tests/Regression/task-exe-file-results-in-an-file-struct-leak/main.fmf b/tests/Regression/task-exe-file-results-in-an-file-struct-leak/main.fmf new file mode 100644 index 0000000..d3da75c --- /dev/null +++ b/tests/Regression/task-exe-file-results-in-an-file-struct-leak/main.fmf @@ -0,0 +1,15 @@ +summary: task-exe-file-results-in-an-file-struct-leak +description: '' +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 48h +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1430861 +extra-summary: /tools/systemtap/Regression/task-exe-file-results-in-an-file-struct-leak +extra-task: /tools/systemtap/Regression/task-exe-file-results-in-an-file-struct-leak +tag: fedora diff --git a/tests/Regression/task-exe-file-results-in-an-file-struct-leak/reproducer.stp b/tests/Regression/task-exe-file-results-in-an-file-struct-leak/reproducer.stp new file mode 100644 index 0000000..2dd39bb --- /dev/null +++ b/tests/Regression/task-exe-file-results-in-an-file-struct-leak/reproducer.stp @@ -0,0 +1,6 @@ +probe kprocess.exit +{ + t=task_current() + path=fullpath_struct_file(t, task_exe_file(t)) + printf("%s\n", path) +} diff --git a/tests/Regression/task-exe-file-results-in-an-file-struct-leak/reproducer2.stp b/tests/Regression/task-exe-file-results-in-an-file-struct-leak/reproducer2.stp new file mode 100644 index 0000000..f26764a --- /dev/null +++ b/tests/Regression/task-exe-file-results-in-an-file-struct-leak/reproducer2.stp @@ -0,0 +1,5 @@ +probe kprocess.exit +{ + path=fullpath_struct_path(task_cwd_path(task_current())) + printf("%s\n", path) +} diff --git a/tests/Regression/task-exe-file-results-in-an-file-struct-leak/runtest.sh b/tests/Regression/task-exe-file-results-in-an-file-struct-leak/runtest.sh new file mode 100755 index 0000000..67d8be4 --- /dev/null +++ b/tests/Regression/task-exe-file-results-in-an-file-struct-leak/runtest.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/task-exe-file-results-in-an-file-struct-leak +# Description: task-exe-file-results-in-an-file-struct-leak +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2017 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="systemtap" + +rlJournalStart + rlPhaseStartTest + EXTRA='' + arch | grep -F ppc64le && EXTRA="-P" + rlRun "FILE_NR1=$(awk '{print $1}' /proc/sys/fs/file-nr)" + REPRODUCER=reproducer.stp + rlRun "stap -g -w $EXTRA --dump-functions | grep -F task_exe_file || REPRODUCER=reproducer2.stp" + rlRun "stap -w $EXTRA $REPRODUCER -c 'bash ./trigger.sh' -o /dev/null" + rlRun "FILE_NR2=$(awk '{print $1}' /proc/sys/fs/file-nr)" + rlRun "test $((FILE_NR2 - 1000)) -le $FILE_NR1" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/task-exe-file-results-in-an-file-struct-leak/trigger.sh b/tests/Regression/task-exe-file-results-in-an-file-struct-leak/trigger.sh new file mode 100755 index 0000000..31ee2bb --- /dev/null +++ b/tests/Regression/task-exe-file-results-in-an-file-struct-leak/trigger.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +for i in `seq 1 100000`; do + /bin/true +done + + diff --git a/tests/Regression/upstream-testsuite/main.fmf b/tests/Regression/upstream-testsuite/main.fmf new file mode 100644 index 0000000..1bae9d8 --- /dev/null +++ b/tests/Regression/upstream-testsuite/main.fmf @@ -0,0 +1,54 @@ +summary: upstream-testsuite +enabled: true +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - libstdc++ + - libstdc++-devel + - libgcc + - glibc-devel + - gcc-c++ + - kernel-devel + - kernel-headers + - git + - curl + - tar + - dejagnu + - elfutils-devel + - gettext + - gettext-devel + - nss-devel + - avahi-devel + - dyninst-devel + - libselinux-devel + - sqlite-devel + - json-c-devel + - ncurses-devel + - crash-devel + - rpm-devel + - emacs + - jpackage-utils + - java-devel + - libvirt-devel + - libxml2-devel + - readline-devel + - python-devel + - python3-devel + - rpm-build + - python-setuptools + - python2-setuptools + - python2-pyparsing + - dyninst-devel + - elfutils-debuginfod-client-devel +duration: 72h +tag: fedora +order: 9999 +# check: +# - how: watchdog +# interval: 2 +# reboot: true +# ping: true +# ping-packets: 1 +# ping-threshold: 3 diff --git a/tests/Regression/upstream-testsuite/my_environment_sanity.exp b/tests/Regression/upstream-testsuite/my_environment_sanity.exp new file mode 100644 index 0000000..0af241a --- /dev/null +++ b/tests/Regression/upstream-testsuite/my_environment_sanity.exp @@ -0,0 +1,6 @@ +set test "my_environment_sanity_test" + +environment_sanity_test +print_system_info + +pass $test diff --git a/tests/Regression/upstream-testsuite/runtest.sh b/tests/Regression/upstream-testsuite/runtest.sh new file mode 100755 index 0000000..2b7ba6d --- /dev/null +++ b/tests/Regression/upstream-testsuite/runtest.sh @@ -0,0 +1,102 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/testsuite-upstream-raw +# Description: testsuite-upstream-raw +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2014 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +SUITERPM=${SUITERPM:-systemtap-testsuite} +SUITELOC=${SUITELOC:-/usr/share/systemtap/testsuite/} +PKGMGR=${PKGMGR:-dnf} +ORIGWD=$(pwd) + +export SUITELOC + +rlJournalStart + rlPhaseStart WARN "Install" + # Try to free disk space by uninstalling unneeded kernel packages + rlRun "rpm -qa | grep ^kernel | grep -v `uname -r` | grep -v headers | xargs rpm -e --nodeps" 0-255 + # https://github.com/teemtee/tmt/issues/2762 + # rlRun "$PKGMGR -y install --setopt=multilib_policy=all libstdc++ libgcc glibc-devel gcc-c++ libstdc++-devel" + rlRun "stap-prep" + rlPhaseEnd + + rlPhaseStartSetup + rlServiceStop firewalld + rlServiceStop iptables + rlServiceStop ip6tables + rlServiceStop kdump + rlServiceStart avahi-daemon + rlRun "sysctl -w kernel.panic=1" + rlRun "sysctl -w kernel.panic_on_oops=1" + rlPhaseEnd + + rlPhaseStart WARN "Info" + rlLogInfo "SUITERPM=${SUITERPM}" + rlLogInfo "SUITELOC=${SUITELOC}" + rlLogInfo "PKGMGR=${PKGMGR}" + rlRun "uname -a" + rlRun "rpm -q $SUITERPM" + rlRun "cat /etc/os-release" + rlRun "stap-report" + rlPhaseEnd + + rlPhaseStart FAIL "sanity check" + rlRun "stap -vve 'probe kernel.function(\"vfs_read\"){ log(\"hey!\"); exit() } probe timer.s(60){log(\"timeout\"); exit()}'" + rlPhaseEnd + + rlPhaseStartTest + rlRun "pushd $SUITELOC" + rlRun "$ORIGWD/trimsuite" + rm -f /tmp/stopwatchdog + $ORIGWD/watchdog.sh & + watchdog_pid=$! + + # Make sure we always have the system identification print_system_info() + # Work around removal of print_system_info() from environment_sanity.exp + rlRun "cp $ORIGWD/my_environment_sanity.exp $SUITELOC/systemtap/" + + # Test primary arch only. The CI test systems have notorious problems + # with repos having i686 and x86_64 packages whose NVRs do not match. + # It's a PITA. Work it around. + rlRun "sed -i '/^proc arch_compile_flags/,/^}/d' $SUITELOC/lib/compile_flags.exp" + rlRun "echo 'proc arch_compile_flags {} { return 1 }' >> $SUITELOC/lib/compile_flags.exp" + + rlRun "make installcheck 2>&1" 0-255 + touch /tmp/stopwatchdog + wait + rlPhaseEnd + + rlPhaseStartCleanup + rlServiceRestore firewalld + rlServiceRestore iptables + rlServiceRestore ip6tables + rlServiceRestore kdump + rlServiceRestore avahi-daemon + rlRun popd + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/upstream-testsuite/trimsuite b/tests/Regression/upstream-testsuite/trimsuite new file mode 100755 index 0000000..a178cc0 --- /dev/null +++ b/tests/Regression/upstream-testsuite/trimsuite @@ -0,0 +1,40 @@ +#!/bin/bash + +set -xe + +cd /usr/share/systemtap/testsuite + +# Remove slow tests + +for i in systemtap.base/listing_mode_sanity.exp \ +systemtap.base/rlimit.exp \ +systemtap.onthefly/kprobes_onthefly.exp \ +systemtap.syscall/nd_syscall.exp \ +systemtap.syscall/tp_syscall.exp \ +systemtap.base/listing_mode.exp \ +systemtap.base/tracepoints_list.exp \ +systemtap.onthefly/hrtimer_onthefly.exp \ +systemtap.pass1-4/parse-semok.exp \ +systemtap.syscall/syscall.exp \ +systemtap.base/sdt_misc.exp \ +systemtap.base/sdt_buildid.exp \ +systemtap.pass1-4/buildok-interactive.exp \ +systemtap.unprivileged/unprivileged_myproc.exp \ +systemtap.pass1-4/buildok.exp \ +systemtap.examples/check.exp; do + rm -rf $i +done + +# # Remove whole directories +# +# for i in systemtap.analysis systemtap.apps systemtap.base systemtap.bpf \ +# systemtap.clone systemtap.context systemtap.examples systemtap.exelib \ +# systemtap.http_exporter systemtap.http_server systemtap.interactive \ +# systemtap.language_server systemtap.maps systemtap.onthefly systemtap.pass1-4 \ +# systemtap.printf systemtap.python systemtap.samples systemtap.server \ +# systemtap.speculate systemtap.stress systemtap.string systemtap.syscall \ +# systemtap.unprivileged; \ +# do +# echo $i | grep -q "systemtap.base" && continue +# rm -rf $i +# done diff --git a/tests/Regression/upstream-testsuite/watchdog.sh b/tests/Regression/upstream-testsuite/watchdog.sh new file mode 100755 index 0000000..c92de6d --- /dev/null +++ b/tests/Regression/upstream-testsuite/watchdog.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +PROCESSES='stap staprun stapio' +TIMEOUT_MIN=17 +SUITELOC=${SUITELOC:-/root/build/testsuite} +LOG_PREFIX="WATCHDOG" +SIGNAL="-9" + +# set -x +killcount=0 +while true; do + date +"${LOG_PREFIX}: %a %F %H:%M: " | tr -d '\n' + echo "Alive (pid $$)" + for p in $PROCESSES; do + for pid in `pgrep $p`; do + test -f /proc/$pid/status || continue + grep -q "State.*zombie" /proc/$pid/status && continue + # echo "Checking process $p, pid $pid" + start_datetime=`ps --no-headers -o lstart -p $pid` + start_stamp=`date -d "$start_datetime" +"%s"` + now=`date +%s` + runtime=$(( (now - start_stamp) / 60 )) + # echo "Started $start_stamp, now is $now, tzn runtime=${runtime}min" + if test $runtime -ge $TIMEOUT_MIN; then + echo + grep '^Running' $SUITELOC/systemtap.sum | tail -3 | sed "s/.*/${LOG_PREFIX}: SUM:\ \0/" + tail -10 $SUITELOC/systemtap.log | sed "s/.*/${LOG_PREFIX}: LOG:\ \0/" + dmesg | tail -30 | sed "s/.*/${LOG_PREFIX}: DMESG:\ \0/" + date +"${LOG_PREFIX}: %a %F %H:%M: " | tr -d '\n' + echo -n "Checking process $p pid $pid, runtime $runtime min. " + if kill $SIGNAL $pid; then + killcount=$((killcount + 1)) + echo "Killed (killcount=$killcount)." + # Killing one process sometimes affects others, so + # we break and recollect the PIDs in next iteration. + break + else + echo "${LOG_PREFIX}: Kill attempted, but failed." + fi + fi + done + done + test -f /tmp/stopwatchdog && break + sleep 60 +done diff --git a/tests/Regression/utrace-taskfinder-misses-events/main.fmf b/tests/Regression/utrace-taskfinder-misses-events/main.fmf new file mode 100644 index 0000000..a8fed74 --- /dev/null +++ b/tests/Regression/utrace-taskfinder-misses-events/main.fmf @@ -0,0 +1,17 @@ +summary: Test for BZ#876848 (utrace taskfinder misses events when main thread) +description: '' +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap + - gcc-c++ + - kernel-debuginfo +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=876848 +extra-summary: /tools/systemtap/Regression/utrace-taskfinder-misses-events +extra-task: /tools/systemtap/Regression/utrace-taskfinder-misses-events +tag: fedora diff --git a/tests/Regression/utrace-taskfinder-misses-events/pthreadtestcase.cpp b/tests/Regression/utrace-taskfinder-misses-events/pthreadtestcase.cpp new file mode 100644 index 0000000..30a8215 --- /dev/null +++ b/tests/Regression/utrace-taskfinder-misses-events/pthreadtestcase.cpp @@ -0,0 +1,35 @@ +#include +#include +#include + +int square (int x) +{ + return (x * x); +} + +void *my_thread(void *arg) +{ + int x = 0; + int sqr; + + while (true) { + sqr = square(5); + sleep(1); + } + return NULL; +} + +int main() +{ + pthread_t thread_id; + if (pthread_create(&thread_id, NULL, my_thread, NULL)) { + fprintf(stderr, "Error creating thread\n"); + return 1; + } + if (pthread_join(thread_id, NULL)) { + fprintf(stderr, "Error joining thread\n"); + return 2; + } + return 0; +} + diff --git a/tests/Regression/utrace-taskfinder-misses-events/pthreadtestcase.stp b/tests/Regression/utrace-taskfinder-misses-events/pthreadtestcase.stp new file mode 100644 index 0000000..d6ab354 --- /dev/null +++ b/tests/Regression/utrace-taskfinder-misses-events/pthreadtestcase.stp @@ -0,0 +1,28 @@ +#! /usr/bin/env stap + +probe timer.sec(180) +{ + printf("EXITONTIMEOUT\n"); + exit() +} + +probe process("./pthreadtestcase").function("square") +{ + printf("USERSPACEFUNCTIONENTER\n") + printf("=> %s(%s)\n", probefunc(), $$parms) +} + +probe process("./pthreadtestcase").function("square").return +{ + printf("USERSPACEFUNCTIONLEAVE\n") + printf("<= %s\n", probefunc()) + exit() +} + +probe process("./pthreadtestcase").statement("*@pthreadtestcase.cpp:7") +{ + printf("USERSPACEREACHEDLINE\n") + #printf(" x=%d, sqr=%d\n\n", $x, $sqr) + printf(" x=%d\n\n", $x) +} + diff --git a/tests/Regression/utrace-taskfinder-misses-events/runtest.sh b/tests/Regression/utrace-taskfinder-misses-events/runtest.sh new file mode 100755 index 0000000..c20788c --- /dev/null +++ b/tests/Regression/utrace-taskfinder-misses-events/runtest.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/utrace-taskfinder-misses-events +# Description: Test for BZ#876848 (utrace taskfinder misses events when main thread) +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +# if this testcase caused kernel crash and reboot, don't try to rerun it +[[ $REBOOTCOUNT -gt 0 ]] && exit 1 + +rlJournalStart + rlPhaseStartSetup + rlRun "TMPDIR=\$(mktemp -d)" + rlRun "cp pthreadtestcase.cpp pthreadtestcase.stp $TMPDIR" + rlRun "pushd $TMPDIR" + rlPhaseEnd + + rlPhaseStart FAIL "Systemtap sanity check" + rlRun "stap --version" + rlRun "stap -v -e 'probe kernel.function(\"vfs_read\"){ exit() }'" + rlPhaseEnd + + rlPhaseStart FAIL "Prepare pthreadtestcase, run it" + rlRun "g++ -g -o pthreadtestcase pthreadtestcase.cpp -lpthread" + killall -9 pthreadtestcase &> /dev/null + ./pthreadtestcase & + MYPID=$! + sleep 3 + rlRun "ps | grep '$MYPID.*pthreadtestcase$'" + rlPhaseEnd + + rlPhaseStartTest + rlRun "stap -v pthreadtestcase.stp 2>&1 | tee mylog.txt" + rlRun "grep EXITONTIMEOUT mylog.txt" 1 + for token in USERSPACEFUNCTIONENTER \ + USERSPACEREACHEDLINE \ + USERSPACEFUNCTIONLEAVE + do + rlRun "grep ^$token$ mylog.txt" 0 + done + rlPhaseEnd + + rlPhaseStart FAIL "Shut pthreadtestcase down" + # pthreadtestcase should still be running + # so killing it should certsinly succeed + rlRun "kill $MYPID" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TMPDIR" + rlPhaseEnd +rlJournalEnd diff --git a/tests/Regression/wrong-data-returned-by-nfs-commit-done/main.fmf b/tests/Regression/wrong-data-returned-by-nfs-commit-done/main.fmf new file mode 100644 index 0000000..2542286 --- /dev/null +++ b/tests/Regression/wrong-data-returned-by-nfs-commit-done/main.fmf @@ -0,0 +1,15 @@ +summary: wrong-data-returned-by-nfs-commit-done +description: '' +contact: Martin Cermak +component: + - systemtap +test: ./runtest.sh +framework: beakerlib +recommend: + - systemtap +duration: 2h +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=920444 +extra-summary: /tools/systemtap/Regression/wrong-data-returned-by-nfs-commit-done +extra-task: /tools/systemtap/Regression/wrong-data-returned-by-nfs-commit-done +tag: fedora diff --git a/tests/Regression/wrong-data-returned-by-nfs-commit-done/nfs.proc.commit_done.c b/tests/Regression/wrong-data-returned-by-nfs-commit-done/nfs.proc.commit_done.c new file mode 100644 index 0000000..f7b5e9b --- /dev/null +++ b/tests/Regression/wrong-data-returned-by-nfs-commit-done/nfs.proc.commit_done.c @@ -0,0 +1,84 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define TEST_DIR "/systemtap-sts-nfs-share-and-mount-tmpdir2/sts_mount" + +static int create_and_write(char *file_name); +static int read_file(char *file_name); + +int main(int argc, char *argv[]) +{ + char tmp_path[1024]; + char tmp_file[1024]; + char new_file[1024]; + + strcpy(tmp_path, getenv("HOME")); + strcat(tmp_path, TEST_DIR); + strcat(tmp_path, "/sts_tmp"); + strcpy(tmp_file, tmp_path); + strcpy(new_file, tmp_path); + strcat(tmp_file, "/tmp.txt"); + strcat(new_file, "/tmp2.txt"); + + if (mkdir(tmp_path, 0777) == -1) { + fprintf(stderr, "Create tmp path failed! %d\n", errno); + return -1; + } + if (create_and_write(tmp_file)) + return -1; + + if (rename(tmp_file, new_file) == -1) { + fprintf(stderr, "Rename failed! %d\n", errno); + return -1; + } + read_file(new_file); + if (remove(new_file) == -1) { + fprintf(stderr, "Remove file failed! %d\n", errno); + return -1; + } + + remove(tmp_path); + + return 0; +} + +static int create_and_write(char *file_name) +{ + char buf[] = "abcdefg123"; + int i; + int fd; + + fd = open(file_name, O_RDWR | O_CREAT, 00777); + if (!fd) { + fprintf(stderr, "Create tmp file failed!\n"); + return -1; + } + + for (i = 0; i < 1024 * 1024; i++){ + if (write(fd, buf, 10) != 10) { + fprintf(stderr, "Write error!\n"); + return -1; + } + } + + close(fd); + return 0; +} + +static int read_file(char *file_name) +{ + char buf[1024]; + int fd; + + fd = open(file_name, O_RDONLY); + lseek(fd, 1024 * 10, SEEK_SET); + read(fd, buf, 1024); + close(fd); + return 0; +} diff --git a/tests/Regression/wrong-data-returned-by-nfs-commit-done/nfs.proc.commit_done.stp b/tests/Regression/wrong-data-returned-by-nfs-commit-done/nfs.proc.commit_done.stp new file mode 100644 index 0000000..8de8be0 --- /dev/null +++ b/tests/Regression/wrong-data-returned-by-nfs-commit-done/nfs.proc.commit_done.stp @@ -0,0 +1,3 @@ +probe nfs.proc.commit_done{ + printf("nfs.proc.commit_done server_ip: %s\n", %( systemtap_v >= "4.3" %? server_ip %: ip_ntop(server_ip) %)); +} diff --git a/tests/Regression/wrong-data-returned-by-nfs-commit-done/runtest.sh b/tests/Regression/wrong-data-returned-by-nfs-commit-done/runtest.sh new file mode 100755 index 0000000..b33b035 --- /dev/null +++ b/tests/Regression/wrong-data-returned-by-nfs-commit-done/runtest.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Regression/wrong-data-returned-by-nfs-commit-done +# Description: wrong-data-returned-by-nfs-commit-done +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 +. /etc/os-release || exit 1 + +PACKAGE="systemtap" +export NFS_TMP="$HOME/systemtap-sts-nfs-share-and-mount-tmpdir2" + +rlJournalStart + rlPhaseStartSetup + rlRun "rpm -qf $(which --skip-alias stap)" + rlRun "TMPDIR=$(mktemp -d)" + rlRun "cp nfs.proc.commit_done.c nfs.proc.commit_done.stp $TMPDIR/" + rlRun "pushd $TMPDIR" + rlRun "mkdir -p ${NFS_TMP}/sts_share ${NFS_TMP}/sts_mount" + rlPhaseEnd + + rlPhaseStart FAIL "Build testing binary, prepare nfs environment" + rlRun "systemctl stop nfs-server.service" + rlRun "systemctl stop rpcbind.service" + rlRun "sleep 3" + rlRun "systemctl start rpcbind.service" + rlRun "sleep 3" + rlRun "systemctl start nfs-server.service" + rlRun "sleep 3" + rlRun "systemctl status nfs-server.service" + rlRun "systemctl status rpcbind.service" + rlRun "exportfs -i -o 'rw,async,no_root_squash' 127.0.0.1:${NFS_TMP}/sts_share" + rlRun "mount -vvvvv -t nfs 127.0.0.1:${NFS_TMP}/sts_share ${NFS_TMP}/sts_mount" + rlRun "gcc nfs.proc.commit_done.c -o nfs.proc.commit_done" + rlPhaseEnd + + rlPhaseStartTest + ps="-P" + stap -p2 nfs.proc.commit_done.stp >&/dev/null && ps='' + rlRun "stap $ps --poison-cache -vc './nfs.proc.commit_done' nfs.proc.commit_done.stp 2>&1 | tee testout.log" + rlRun "grep -qP 'nfs.proc.commit_done server_ip:\ \d+\.\d+\.\d+\.\d+' testout.log" + rlPhaseEnd + + rlPhaseStart WARN "Clean the nfs environment up" + rlRun "umount -l ${NFS_TMP}/sts_mount" + rlRun "systemctl stop nfs-server.service" + rlRun "systemctl stop rpcbind.service" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TMPDIR $NFS_TMP" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/byteman-java-methods-probing/ThreadedExample.java b/tests/Sanity/byteman-java-methods-probing/ThreadedExample.java new file mode 100644 index 0000000..8aa0f83 --- /dev/null +++ b/tests/Sanity/byteman-java-methods-probing/ThreadedExample.java @@ -0,0 +1,60 @@ +package foo.bar; + +import java.lang.*; +import java.util.*; + +class ThreadedExample +{ + + public static void printMessage(int message) { + System.out.println("message: " + message); + } + + public static void printMessage(long message) { + System.out.println("message: " + message); + } + + public static void main(String[] args) { + + // sleep so that stap can start and byteman agent gets installed + try { + Thread.sleep(30000); + } catch(InterruptedException ex) { + Thread.currentThread().interrupt(); + } + + + try { + String[] inputs = new String[] {"int", "foo", "long"}; + for (String next : inputs) { + + final String arg = next; + final int i = 42; + final long j = 987234864; + Thread thread = new Thread(arg) { + public void run() { + if(arg.equals("int")) + printMessage(i); + else if(arg.equals("long")) + printMessage(j); + else + System.out.println("Neither of the types"); + } + }; + thread.start(); + try { + thread.join(); + } catch (Exception e){} + } + } catch (Exception e){} + + + // sleep so that stap can finish still while probed java program still runs + try { + Thread.sleep(80000); + } catch(InterruptedException ex) { + Thread.currentThread().interrupt(); + } + } +} + diff --git a/tests/Sanity/byteman-java-methods-probing/ThreadedExample.stp b/tests/Sanity/byteman-java-methods-probing/ThreadedExample.stp new file mode 100644 index 0000000..2aaa08c --- /dev/null +++ b/tests/Sanity/byteman-java-methods-probing/ThreadedExample.stp @@ -0,0 +1,18 @@ +probe java("foo.bar.ThreadedExample").class("ThreadedExample").method("printMessage(int)") +{ + printf("Hit printMessage(int): %s\n", arg1) +} + +probe java("foo.bar.ThreadedExample").class("ThreadedExample").method("printMessage(long)") +{ + printf("Hit printMessage(long): %s\n", arg1) + exit() +} + +probe timer.ms(100000) +{ + error("Exit on timeout") + exit() +} + + diff --git a/tests/Sanity/byteman-java-methods-probing/main.fmf b/tests/Sanity/byteman-java-methods-probing/main.fmf new file mode 100644 index 0000000..3e1dd29 --- /dev/null +++ b/tests/Sanity/byteman-java-methods-probing/main.fmf @@ -0,0 +1,13 @@ +summary: byteman-java-methods-probing +description: '' +contact: Martin Cermak +test: ./runtest.sh +framework: beakerlib +recommend: +- java-devel +- systemtap +- systemtap-runtime-java +duration: 15m +extra-summary: /tools/systemtap/Sanity/byteman-java-methods-probing +extra-task: /tools/systemtap/Sanity/byteman-java-methods-probing +tag: fedora diff --git a/tests/Sanity/byteman-java-methods-probing/runtest.sh b/tests/Sanity/byteman-java-methods-probing/runtest.sh new file mode 100755 index 0000000..aa424fc --- /dev/null +++ b/tests/Sanity/byteman-java-methods-probing/runtest.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Sanity/byteman-java-methods-probing +# Description: byteman-java-methods-probing +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlLogInfo "DEBUGINFOD_URLS=$DEBUGINFOD_URLS" + rlLogInfo "DEBUGINFOD_TIMEOUT=$DEBUGINFOD_TIMEOUT" + + # At this point we simply rely on that the %triggerin scriptlet from + # systemtap-runtime-java did it's job well. There was a hack to force + # trigger it here, but commit respective to this comment removes it. + # https://bugzilla.redhat.com/show_bug.cgi?id=1732514#c11 + + rlRun "rpm -qa | grep -F -e systemtap-runtime-java -e byteman -e openjdk | sort" + + rlRun "stap-prep" + + for BINARY in java javac; do + rlRun "alternatives --display $BINARY | grep -v slave" + rlRun "$BINARY -version" + done + + rlRun "TMPDIR=$( mktemp -d )" + rlRun "mkdir -p $TMPDIR/foo/bar" + rlRun "cp ThreadedExample.java $TMPDIR/foo/bar/" + rlRun "cp ThreadedExample.stp $TMPDIR/" + rlRun "pushd $TMPDIR" + rlPhaseEnd + + rlPhaseStart FAIL 'Prepare bytecode class' + rlRun "javac foo/bar/ThreadedExample.java" + rlPhaseEnd + + rlPhaseStart FAIL 'Prepare the LKML' + rlRun "stap -p4 -m ThreadedExample ThreadedExample.stp" + rlPhaseEnd + + rlPhaseStart FAIL 'Check the Feature' + java foo.bar.ThreadedExample & + rlRun "jps -l | grep 'foo.bar.ThreadedExample'" + export STAPBM_VERBOSE=yes + # rlRun "stap --poison-cache -vv ThreadedExample.stp 2>&1 | tee testout.log" + # Speed the stap startup up by pre-compiling the module within separate + # phase 'Prepare the LKML' above. + rlRun "staprun -v -R ThreadedExample.ko 2>&1 | tee testout.log" + rlRun "grep -q 'Hit printMessage(int): 42' testout.log" + rlRun "grep -q 'Hit printMessage(long): 987234864' testout.log" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/kernel-modules/Makefile.template b/tests/Sanity/kernel-modules/Makefile.template new file mode 100644 index 0000000..a8bfffb --- /dev/null +++ b/tests/Sanity/kernel-modules/Makefile.template @@ -0,0 +1,3 @@ +obj-m := MODULENAME.o +module: + make -C /lib/modules/$(shell uname -r)/build KBUILD_EXTMOD=DIRECTORY SUBDIRS=DIRECTORY modules diff --git a/tests/Sanity/kernel-modules/main.fmf b/tests/Sanity/kernel-modules/main.fmf new file mode 100644 index 0000000..8fb98dc --- /dev/null +++ b/tests/Sanity/kernel-modules/main.fmf @@ -0,0 +1,18 @@ +summary: Tests systemtap working with kernel modules +description: '' +contact: Petr Muller +component: +- systemtap +test: ./runtest.sh +framework: beakerlib +recommend: +- systemtap +- kernel-devel +- bison +- flex +- openssl-devel +- elfutils-libelf-devel +duration: 10m +extra-summary: /tools/systemtap/Sanity/kernel-modules +extra-task: /tools/systemtap/Sanity/kernel-modules +tag: fedora diff --git a/tests/Sanity/kernel-modules/module.c b/tests/Sanity/kernel-modules/module.c new file mode 100644 index 0000000..427ddbc --- /dev/null +++ b/tests/Sanity/kernel-modules/module.c @@ -0,0 +1,20 @@ +#include /* Needed by all modules */ +#include /* Needed for KERN_INFO */ + +int init_module(void) +{ + printk(KERN_INFO "Hello world 1.\n"); + return 0; +} + +int some_method(void){ + printk(KERN_INFO "Some method called\n"); + return 0; +} + +void cleanup_module(void) +{ + printk(KERN_INFO "Goodbye world 1.\n"); +} + +MODULE_LICENSE("GPL"); diff --git a/tests/Sanity/kernel-modules/runtest.sh b/tests/Sanity/kernel-modules/runtest.sh new file mode 100755 index 0000000..b8d32d8 --- /dev/null +++ b/tests/Sanity/kernel-modules/runtest.sh @@ -0,0 +1,123 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Sanity/kernel-modules +# Description: Tests systemtap working with kernel modules +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 +. /usr/share/beakerlib/beakerlib.sh + +PACKAGE="systemtap" + +check_probes(){ + FAIL="" + rlAssertGrep init_module $1 || FAIL='yes' + rlAssertGrep cleanup_module $1 || FAIL='yes' + rlAssertGrep some_method $1 || FAIL='yes' + + if [ -n "$FAIL" ] + then + rlFileSubmit $1 $2.out + fi +} + +rlJournalStart + +rlPhaseStartSetup "Preparing modules" + rlRun "mkdir -p 'stap-underscore' 'stap-dash' 'stap-none'" + rlRun "cp module.c stap-underscore/test_module.c" + rlRun "cp module.c stap-dash/test-module.c" + rlRun "cp module.c stap-none/testmodule.c" + + cat Makefile.template | sed -e 's/MODULENAME/test_module/g' \ + | sed -e "s|DIRECTORY|$PWD/stap-underscore|g" > stap-underscore/Makefile + rlAssert0 "Creating Makefile for underscore variant" $? + cat Makefile.template | sed -e 's/MODULENAME/test-module/g' \ + | sed -e "s|DIRECTORY|$PWD/stap-dash|g" > stap-dash/Makefile + rlAssert0 "Creating Makefile for dash variant" $? + + cat Makefile.template | sed -e 's/MODULENAME/testmodule/g' \ + | sed -e "s|DIRECTORY|$PWD/stap-none|g" > stap-none/Makefile + rlAssert0 "Creating Makefile for no character variant" $? + + if [ -n "$ARCH" ] + then + rlLog "ARCH is set to: [$ARCH]" + rlLog "This interferes with 'make module', so it needs to be unset." + ARCHOLD="$ARCH" + unset ARCH + rlLog "ARCH is set to: [$ARCH]" + fi + rlRun "make -C stap-underscore module" + rlRun "make -C stap-dash module" + rlRun "make -C stap-none module" + if [ -n "$ARCHOLD" ] + then + rlLog "Restoring ARCH" + export ARCH="$ARCHOLD" + rlLog "ARCH is set to: [$ARCH]" + fi + +rlPhaseEnd + +rlPhaseStartTest "Testing underscore variant" + rlRun "cp stap-underscore/test_module.ko /lib/modules/$(uname -r)/" + rlRun "insmod stap-underscore/test_module.ko" + stap -L 'module("test_module").function("*")' -v > stap.out + check_probes stap.out "module-und-probe-und" + stap -L 'module("test-module").function("*")' -v > stap.out + check_probes stap.out "module-und-probe-dash" + sleep 1 + rlRun "rmmod test_module" + rlRun "rm -f /lib/modules/$(uname -r)/test_module.ko" +rlPhaseEnd + +rlPhaseStartTest "Testing dash variant" + rlRun "cp stap-dash/test-module.ko /lib/modules/$(uname -r)/" + rlRun "insmod stap-dash/test-module.ko" + stap -L 'module("test_module").function("*")' -v > stap.out + check_probes stap.out "module-dash-probe-und" + stap -L 'module("test-module").function("*")' -v > stap.out + check_probes stap.out "module-dash-probe-dash" + sleep 1 + rlRun "rmmod test-module" + rlRun "rm -f /lib/modules/$(uname -r)/test-module.ko" +rlPhaseEnd + +rlPhaseStartTest "Testing no separator variant" + rlRun "cp stap-none/testmodule.ko /lib/modules/$(uname -r)/" + rlRun "insmod stap-none/testmodule.ko" + stap -L 'module("testmodule").function("*")' -v > stap.out + check_probes stap.out "module-none-probe-none" + sleep 1 + rlRun "rmmod testmodule" + rlRun "rm -f /lib/modules/$(uname -r)/testmodule.ko" +rlPhaseEnd + +rlPhaseStartCleanup + rlRun "rm -rf stap-underscore stap-dash stap-none stap.out" +rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/quick-smoke-test/main.fmf b/tests/Sanity/quick-smoke-test/main.fmf new file mode 100644 index 0000000..f40c03b --- /dev/null +++ b/tests/Sanity/quick-smoke-test/main.fmf @@ -0,0 +1,17 @@ +summary: Quick test that systemtap generally works +description: '' +contact: +- Petr Muller +component: +- systemtap +test: ./runtest.sh +framework: beakerlib +recommend: +- koji +- systemtap +- kernel-devel +duration: 1h +extra-summary: /tools/systemtap/Sanity/quick-smoke-test +extra-task: /tools/systemtap/Sanity/quick-smoke-test +tag: fedora +tier: 1 diff --git a/tests/Sanity/quick-smoke-test/runtest.sh b/tests/Sanity/quick-smoke-test/runtest.sh new file mode 100755 index 0000000..35f0313 --- /dev/null +++ b/tests/Sanity/quick-smoke-test/runtest.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# runtest.sh of /tools/systemtap/Sanity/quick-smoke-test + +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart +rlPhaseStartTest + rlLogInfo "DEBUGINFOD_URLS=$DEBUGINFOD_URLS" + rlLogInfo "DEBUGINFOD_TIMEOUT=$DEBUGINFOD_TIMEOUT" + rlRun "rpm -qa | grep -E '^(kernel|systemtap)' | sort" + rlRun "uname -r" + rlRun "stap-prep" + rlRun "stap -L 'process(\"stap\").mark(\"*\")' | grep pass" + rlRun "stap -v --example helloworld.stp" + rlRun "stap -v -T 10 -p4 -e 'probe kernel.function(\"do_exit\") {println(\$\$vars)}'" + rlRun "stap -v -T 60 -e 'probe kernel.function(\"vfs_read\"){ println(\$\$vars); exit() }'" +rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/stap-server-basic-sanity/main.fmf b/tests/Sanity/stap-server-basic-sanity/main.fmf new file mode 100644 index 0000000..84da959 --- /dev/null +++ b/tests/Sanity/stap-server-basic-sanity/main.fmf @@ -0,0 +1,18 @@ +summary: stap-server-basic-sanity +description: '' +contact: Martin Cermak +component: +- systemtap +test: ./runtest.sh +framework: beakerlib +recommend: +- systemtap +- kernel-debuginfo +- avahi +- systemtap-server +- dbus +- net-tools +duration: 45m +extra-summary: /tools/systemtap/Sanity/stap-server-basic-sanity +extra-task: /tools/systemtap/Sanity/stap-server-basic-sanity +tag: fedora diff --git a/tests/Sanity/stap-server-basic-sanity/runtest.sh b/tests/Sanity/stap-server-basic-sanity/runtest.sh new file mode 100755 index 0000000..7c40bad --- /dev/null +++ b/tests/Sanity/stap-server-basic-sanity/runtest.sh @@ -0,0 +1,97 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/systemtap/Sanity/stap-server-basic-sanity +# Description: stap-server-basic-sanity +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +CMD='stap' +BIN=$(which --skip-alias $CMD) +PACKAGE="${PACKAGE:-$(rpm -qf --qf='%{name}\n' $BIN | head -1)}" + +function service_stap_server() { + action=$1 + retval=${2:-0} + sleep 5 + rlLogInfo "PACKAGE=$PACKAGE" + if echo $PACKAGE | grep -q devtoolset; then + __i=$(echo $PACKAGE | awk -F- '{print $2}') + rlRun "service devtoolset-$__i-stap-server $action" $retval + elif echo $PACKAGE | grep -q gcc-toolset; then + __i=$(echo $PACKAGE | awk -F- '{print $3}') + rlRun "service gcc-toolset-$__i-stap-server $action" $retval + else + rlRun "service stap-server $action" $retval + fi + sleep 5 +} + +_rhelmajor=$(rpm --eval '%{rhel}') + +rlJournalStart + rlPhaseStartSetup + rlLogInfo "DEBUGINFOD_URLS=$DEBUGINFOD_URLS" + rlLogInfo "DEBUGINFOD_TIMEOUT=$DEBUGINFOD_TIMEOUT" + rlRun "TMPDIR=$(mktemp -d)" + rlRun "pushd $TMPDIR" + rlAssertRpm dbus + rlAssertRpm avahi + rlAssertRpm net-tools # because of netstat + rlPhaseEnd + + rlPhaseStart FAIL "sanity check" + rlRun "stap -v -e 'probe begin { log(\"hello\"); exit() }'" + rlPhaseEnd + + rlPhaseStartTest + rlRun "service iptables stop" 0-255 + rlRun "service firewalld stop" 0-255 + service_stap_server stop + test $_rhelmajor -le 8 && \ + rlRun "service messagebus restart" + rlRun "service avahi-daemon restart" + service_stap_server start + + rlRun "netstat -tlp | grep stap" + rlRun "SERVER_PORT=$( netstat -tlpn | awk '/stap/ {print $4}' | grep -o '[0-9]*$' )" + + for SERVER_IP in '127.0.0.1' '[::1]'; do + rlLogInfo "Testing SERVER_IP=$SERVER_IP" + rlRun "stap --trust-servers=ssl,signer,all-users,no-prompt --use-server=$SERVER_IP:$SERVER_PORT" + rlRun "stap --use-server=$SERVER_IP:$SERVER_PORT -v -e 'probe begin { log(\"hello\"); exit() }' 2>&1 | tee output.log" + rlRun "grep 'Using a compile server' output.log" + rlRun "grep '^hello$' output.log" + done + rlPhaseEnd + + rlPhaseStartCleanup + service_stap_server stop + rlRun "popd" + rlRun "rm -r $TMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/userspace-probes/hello.c b/tests/Sanity/userspace-probes/hello.c new file mode 100644 index 0000000..60dac5b --- /dev/null +++ b/tests/Sanity/userspace-probes/hello.c @@ -0,0 +1,7 @@ +#include + +int main(void) { + printf("Hello world!\n"); + return 0; +} + diff --git a/tests/Sanity/userspace-probes/main.fmf b/tests/Sanity/userspace-probes/main.fmf new file mode 100644 index 0000000..07fb48c --- /dev/null +++ b/tests/Sanity/userspace-probes/main.fmf @@ -0,0 +1,18 @@ +summary: userspace-probes +description: '' +contact: Martin Cermak +component: +- systemtap +test: ./runtest.sh +framework: beakerlib +recommend: +- systemtap +- dyninst-devel +- gawk +duration: 5m +link: +- relates: https://bugzilla.redhat.com/show_bug.cgi?id=855981 +extra-summary: /CoreOS/systemtap/Sanity/userspace-probes +extra-task: /CoreOS/systemtap/Sanity/userspace-probes +enabled: true +tag: fedora diff --git a/tests/Sanity/userspace-probes/runtest.sh b/tests/Sanity/userspace-probes/runtest.sh new file mode 100755 index 0000000..52fb25d --- /dev/null +++ b/tests/Sanity/userspace-probes/runtest.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/systemtap/Sanity/userspace-probes +# Description: userspace-probes +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="$(rpm -qf $( which stap ) | head -n 1 )" +WORKDIR=$( mktemp -d ) +TESTUSER=mytestuser + + + +rlJournalStart + rlPhaseStart WARN "Check the environment" + rlLogInfo "DEBUGINFOD_URLS=$DEBUGINFOD_URLS" + rlLogInfo "DEBUGINFOD_TIMEOUT=$DEBUGINFOD_TIMEOUT" + if ! stap -V 2>&1 | grep -q 'enabled features:.*DYNINST'; then + rlLogWarning "No dyninst available in $PACKAGE" + rlPhaseEnd + rlJournalPrintText + rlJournalEnd + exit 0 + fi + rlRun "useradd $TESTUSER" 0,9 + rlRun "su $TESTUSER -c 'which stap'" + rlRun "rpm -qa | grep -F -e dyninst -e systemtap | sort" + rlPhaseEnd + + rlPhaseStartSetup + rlRun "cp hello.c testcase*.sh $WORKDIR" + rlRun "chown -R $TESTUSER:$TESTUSER $WORKDIR" + rlPhaseEnd + + rlPhaseStart FAIL "Testcase 1" + rlRun "which gcc" + rlRun "su $TESTUSER -c 'gcc -g -o $WORKDIR/hello $WORKDIR/hello.c'" + rlRun "su $TESTUSER -c '$WORKDIR/hello'" + rlRun "chmod a+x $WORKDIR/testcase1.sh" + rlRun "su $TESTUSER -c '$WORKDIR/testcase1.sh $WORKDIR'" + + LOG="$WORKDIR/stapout.log" + + rlRun "cat $LOG" + rlRun "grep '^process(\"$WORKDIR/hello\").function(\"main@$WORKDIR/hello.c:3\")$' $LOG" + rlRun "grep -i error $LOG" 1 + rlPhaseEnd + + rlPhaseStart FAIL "Testcase 2" + rlRun "chmod a+x $WORKDIR/testcase2.sh" + rlRun "su $TESTUSER -c '$WORKDIR/testcase2.sh $WORKDIR'" + + LOG="$WORKDIR/stapout.log" + + rlRun "cat $LOG" + rlRun "grep '^\*\*\*\ exiting\ \*\*\*$' $LOG" + rlRun "grep -E -i 'error|warning' $LOG" 1 + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "userdel $TESTUSER" 0-255 + rlRun "rm -rf /home/$TESTUSER $WORKDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/userspace-probes/testcase1.sh b/tests/Sanity/userspace-probes/testcase1.sh new file mode 100755 index 0000000..818d2cd --- /dev/null +++ b/tests/Sanity/userspace-probes/testcase1.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +stap -e "probe process(\"$1/hello\").function(\"main\") { println(pn()) }" --runtime=dyninst -c "$1/hello" -o "$1/stapout.log" diff --git a/tests/Sanity/userspace-probes/testcase2.sh b/tests/Sanity/userspace-probes/testcase2.sh new file mode 100755 index 0000000..d270d09 --- /dev/null +++ b/tests/Sanity/userspace-probes/testcase2.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +stap --runtime=dyninst -e 'probe end { printf("*** exiting ***\n"); exit() }' -c "$1/hello" -o "$1/stapout.log" +