From a369f27b2022dd994a33fdf52e5f8d95831a44b2 Mon Sep 17 00:00:00 2001 From: Bill Peck Date: Mon, 28 Oct 2013 14:28:13 -0400 Subject: Updated tracepoints test --- kernel/tracepoints/operational/Makefile | 55 ++++++++++ kernel/tracepoints/operational/runtest.sh | 162 ++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 kernel/tracepoints/operational/Makefile create mode 100755 kernel/tracepoints/operational/runtest.sh diff --git a/kernel/tracepoints/operational/Makefile b/kernel/tracepoints/operational/Makefile new file mode 100644 index 0000000..f20170e --- /dev/null +++ b/kernel/tracepoints/operational/Makefile @@ -0,0 +1,55 @@ +# The name of the package under test +PACKAGE_NAME=kernel + +# The toplevel namespace within which the test lives. +TOPLEVEL_NAMESPACE=/$(PACKAGE_NAME) + +# The version of the test rpm that gets +# created / submitted +export TESTVERSION=1.0 + +# The path of the test below the package +RELATIVE_PATH=tracepoints/operational + +# The relative path name to the test +export TEST=$(TOPLEVEL_NAMESPACE)/$(RELATIVE_PATH) + +# All files you want bundled into your rpm +FILES= $(METADATA) \ + runtest.sh \ + Makefile + +clean: + $(RM) *~ $(METADATA) + $(RM) rh-tests-kernel*.rpm + +run: $(METADATA) + ./runtest.sh + +# Include a global make rules file +include /usr/share/rhts/lib/rhts-make.include + +showmeta: $(METADATA) + @cat $(METADATA) + @rhts-lint $(METADATA) + +$(METADATA): + touch $(METADATA) + @echo "Name: $(TEST)" > $(METADATA) + @echo "Description: Ensure tracepoints are working" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "TestTime: 150m" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Releases: RHELServer5 RHEL6 Fedora16 RHEL7 RedHatEnterpriseLinux7" >> $(METADATA) + @echo "#Architectures: All" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "Type: KernelTier1" >> $(METADATA) + @echo "Requires: kernel-devel" >> $(METADATA) + @echo "Requires: systemtap" >> $(METADATA) + @echo "RunFor: kernel" >> $(METADATA) + @echo "RunFor: kernel-devel" >> $(METADATA) + @echo "RunFor: systemtap" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Owner: Jeff Burke " >> $(METADATA) diff --git a/kernel/tracepoints/operational/runtest.sh b/kernel/tracepoints/operational/runtest.sh new file mode 100755 index 0000000..2daeac2 --- /dev/null +++ b/kernel/tracepoints/operational/runtest.sh @@ -0,0 +1,162 @@ +#!/bin/sh + +# Source the common test script helpers +. /usr/bin/rhts-environment.sh + +# Helper functions +function resultFail() +{ + echo "***** End of runtest.sh *****" | tee -a $OUTPUTFILE + report_result $1 FAIL $2 + echo "" | tee -a $OUTPUTFILE +} + +function resultPass () +{ + echo "***** End of runtest.sh *****" | tee -a $OUTPUTFILE + report_result $1 PASS $2 + echo "" | tee -a $OUTPUTFILE +} + +function submitLog () +{ + LOG=$1 + if [ -z "$TESTPATH" ]; then + echo "Running in developer mode" + else + rhts_submit_log -S $RESULT_SERVER -T $TESTID -l $LOG + fi +} + +function testHeader () +{ + echo "***** Starting the runtest.sh script *****" | tee $OUTPUTFILE + echo "***** Current Running Kernel Package = "$kernbase" *****" | tee -a $OUTPUTFILE + echo "***** Installed systemtap version = "$stapbase" *****" | tee -a $OUTPUTFILE + echo "***** Current Running Distro = "$installeddistro" *****" | tee -a $OUTPUTFILE +} + +function timeCalc () +{ + # end & test time + ETIME=`date +%s` + TTIME=`expr $ETIME - $STIME` +} + +function isCpuFamilyModel () +{ + local CPU=$1 + local FAMILY=$2 + local MODEL=$3 + + cat /proc/cpuinfo | awk "BEGIN {CPU=\"NO\"; FAMILY=\"NO\"; MODEL=\"NO\"; MATCH=1} /^vendor_id/ { CPU = \$3 }; /^cpu family/ { FAMILY=\$4}; /^model\t/ { MODEL=\$3}; (CPU == \"$CPU\") && (FAMILY == \"$FAMILY\") && (MODEL == \"$MODEL\") { MATCH=0}; END {exit MATCH}" + return $? +} + +function testList () +{ + local TESTLIST="$1" + local GROUP_SIZE="$2" + local COUNT=0 + local PROBE_COUNT=`echo $TESTLIST | wc -w` + local PROBES_FILE=`mktemp -p /tmp -t group.XXXXXX` + local PROBES_NAME_FILE=`mktemp -p /tmp -t group_probe_names.XXXXXX` + for i in $TESTLIST; do + + # Create unique log for verbose tracepoint logging + COUNT=`expr $COUNT + 1` + STIME=`date +%s` + + echo "$i" | tr -d '\"' >> $PROBES_NAME_FILE + echo 'probe kernel.trace('$i') { dummy = dummy + 1; }' >> $PROBES_FILE + + if [ $((COUNT % GROUP_SIZE)) == 0 -o $COUNT == $PROBE_COUNT ]; then + + testHeader + echo "------------------------------------------------------------" | tee -a $OUTPUTFILE + echo " Start of SystemTap Kernel Tracepoint Test " | tee -a $OUTPUTFILE + echo " $STIME " | tee -a $OUTPUTFILE + echo " Testing: " | tee -a $OUTPUTFILE + cat $PROBES_FILE | tee -a $OUTPUTFILE + echo "------------------------------------------------------------" | tee -a $OUTPUTFILE + + echo "global dummy" > group.stap + echo "probe end { printf(\"dummy: %d\n\", dummy); }" >> group.stap + cat $PROBES_FILE >> group.stap + + local firstp=`head -1 $PROBES_NAME_FILE` + local lastp=`tail -1 $PROBES_NAME_FILE` + local VAR="$firstp" + if [ ! "$firstp" == "$lastp" ]; then + local VAR="${firstp}__to__${lastp}" + fi + local VERBOSETRACELOG=`mktemp -p /mnt/testarea -t $VAR-TraceLog.XXXXXX` + + stap -DSTP_NO_OVERLOAD $XTRA -t -c "sleep 1" -vvvv group.stap > $VERBOSETRACELOG 2>&1 + local rc=$? + timeCalc + if [ $rc -eq 0 ] ; then + echo " Result testing : Test Passed " | tee -a $OUTPUTFILE + echo " Test run time : $TTIME seconds " | tee -a $OUTPUTFILE + echo "------------------------------------------------------------" | tee -a $OUTPUTFILE + resultPass $VAR $COUNT + else + echo " Result testing : Test Failed " | tee -a $OUTPUTFILE + echo " Test run time : $TTIME seconds " | tee -a $OUTPUTFILE + echo "------------------------------------------------------------" | tee -a $OUTPUTFILE + submitLog $VERBOSETRACELOG + resultFail $VAR $COUNT + fi + rm -f $PROBES_FILE + rm -f $PROBES_NAME_FILE + fi + done +} + +function runTest () +{ + local TESTLIST=`/usr/bin/stap -L 'kernel.trace("*")' | grep -o "\".*\""` + if [ -z "$TESTLIST" ] ; then + resultFail TESTLIST_EMPTY 99 + exit 0 + fi + + # Additional argumewnt to stap if Family is RHEL5 and CPU/Family/Model match + [ "$FAMILY" == "RedHatEnterpriseLinuxServer5" ] && isCpuFamilyModel AuthenticAMD 21 2 + if [ "$?" == 0 ]; then + XTRA="-DTRYLOCKDELAY=300" + fi + stap --clean-cache + testList "$TESTLIST" 32 +} + +# Setup some variables +if [ -e /etc/redhat-release ] ; then + installeddistro=`cat /etc/redhat-release` +else + installeddistro=unknown +fi + +kernbase=$(rpm -q --queryformat '%{name}-%{version}-%{release}.%{arch}\n' -qf /boot/config-$(uname -r)) +stapbase=$(rpm -q --queryformat '%{name}-%{version}-%{release}.%{arch}\n' -qf /usr/bin/stap) + +# Skip test if we are in FIPS mode, unsigned modules will cause kernel panic +grep "1" /proc/sys/crypto/fips_enabled > /dev/null +if [ $? -eq 0 ]; then + echo "***** Running in FIPS mode, stap modules would cause kernel panic ****" | tee -a $OUTPUTFILE + report_result Test_Skipped PASS 1 + exit 0 +fi + +# Skip test if we are running an earlier distro (Supported in RHEL5.4) +KERNVER=`/bin/uname -r | /bin/awk -F- {'print $2'} | /bin/awk -F. {'print $1'}` +if uname -r | grep -q 'el[67]' || [ "$KERNVER" -ge "156" ]; then + runTest +else + echo "***** tracepoint not enabled in this kernel *****" | tee -a $OUTPUTFILE + echo "***** End of runtest.sh *****" | tee -a $OUTPUTFILE + echo"" | tee -a $OUTPUTFILE + report_result Test_Skipped PASS 99 + echo "" | tee -a $OUTPUTFILE + exit 0 +fi -- cgit