systemtap/tests/Sanity/userspace-probes/runtest.sh
Martin Cermak 91acc811a1 CI Tests: Set DEBUGINFOD_URLS based on test FMF context.
Tests are supposed to be executed within defined context, such as e.g.
tmt --root . -c arch=x86_64 -c distro=fedora-38 -c trigger=build run ...

FTR: https://tmt.readthedocs.io/en/stable/spec/plans.html#context

This update sets DEBUGINFOD_URLS based on the provided distro
via the ci.fmf file.
2023-05-19 10:34:46 +02:00

90 lines
3.0 KiB
Bash
Executable File

#!/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 <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 | fgrep -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 "egrep -i 'error|warning' $LOG" 1
rlPhaseEnd
rlPhaseStartCleanup
rlRun "userdel $TESTUSER" 0-255
rlRun "rm -rf /home/$TESTUSER $WORKDIR"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd