systemtap/tests/Regression/semantic-errors-bz953776/runtest.sh

162 lines
4.9 KiB
Bash
Raw Normal View History

#!/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 <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <<EOF
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <unistd.h>
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
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
)
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
# ( fgrep 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