summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Peck <bpeck@redhat.com>2014-11-24 11:12:04 -0500
committerBill Peck <bpeck@redhat.com>2014-11-24 11:12:04 -0500
commit23d68bad44d1b0e5e1c9da8c93f050b59c1b373b (patch)
tree68a421da68284df76c322a670214ed7ee20211b2
parent58ce7234de6c4c582f4a7a2af6a9b7da124da537 (diff)
downloadtests-23d68bad44d1b0e5e1c9da8c93f050b59c1b373b.tar.gz
tests-23d68bad44d1b0e5e1c9da8c93f050b59c1b373b.tar.xz
tests-23d68bad44d1b0e5e1c9da8c93f050b59c1b373b.zip
Update common code
-rw-r--r--kernel/include/Makefile5
-rwxr-xr-xkernel/include/runtest.sh359
2 files changed, 316 insertions, 48 deletions
diff --git a/kernel/include/Makefile b/kernel/include/Makefile
index 6b73226..447ad5c 100644
--- a/kernel/include/Makefile
+++ b/kernel/include/Makefile
@@ -1,5 +1,3 @@
-# Include Common Makefile
-include /usr/share/rhts/lib/rhts-make.include
# The version of the test rpm that gets created/submitted.
export TESTVERSION=1.0
@@ -16,6 +14,9 @@ RELATIVE_PATH=include
# The relative path name to the test
export TEST=$(TOPLEVEL_NAMESPACE)/$(RELATIVE_PATH)
+# Include common global make rules file
+include /usr/share/rhts/lib/rhts-make.include
+
# All files you want bundled into your rpm:
# data files, scripts, and anything needed to either
# compile the test and/or run it.
diff --git a/kernel/include/runtest.sh b/kernel/include/runtest.sh
index 94a2ff1..005a9a8 100755
--- a/kernel/include/runtest.sh
+++ b/kernel/include/runtest.sh
@@ -1,8 +1,11 @@
#!/bin/sh
-#
-### Kernel Testing Include File
-### Include these variables
+# Kernel Testing Include File:
+# This include file contains common variables and
+# functions for "KT1" and "Secondary" kernel testing tasks.
+
+#
+# Variables
#
# control where to log debug messages to:
# devnull = 1 : log to /dev/null
@@ -11,58 +14,87 @@ devnull=0
# Create debug log
DEBUGLOG=`mktemp -p /mnt/testarea -t DeBug.XXXXXX`
+K_DEBUGLOG=`mktemp -p /mnt/testarea -t K_DeBug.XXXXXX`
+
+# In the event your not running automated Beaker job
+if [ -z "$OUTPUTFILE" ]; then
+ echo ""
+ echo "***** \$OUTPUTFILE is not defined *****"
+ echo "***** This is generally do to a *****"
+ echo "***** manual testing setup *****"
+ echo "***** Creating: \$OUTPUTFILE *****"
+ echo ""
+ export OUTPUTFILE=`mktemp /mnt/testarea/tmp.XXXXXX`
+fi
+# ToDo: $RESULT_SERVER $TESTID also need workaround
+
+OUTPUTDIR=/mnt/testarea
+if [ ! -d "$OUTPUTDIR" ]; then
+
+ echo ""
+ echo "***** OUTPUTDIR is not defined *****"
+ echo "***** Creating: $OUTPUTDIR *****"
+ echo ""
+ mkdir -p $OUTPUTDIR
+fi
# locking to avoid races
lck=$OUTPUTDIR/$(basename $0).lck
+K_LCK=$OUTPUTDIR/$(basename $0).lck
+
+TESTAREA="/mnt/testarea"
+K_TESTAREA="/mnt/testarea"
+TEST_VER=$(rpm -qf $0)
+K_TEST_VER=$(rpm -qf $0)
# Kernel Variables
K_NAME=`rpm -q --queryformat '%{name}\n' -qf /boot/config-$(uname -r)`
-# example output: kernel
+# example output: kernel
K_VER=`rpm -q --queryformat '%{version}\n' -qf /boot/config-$(uname -r)`
-# example output: 2.6.32
+# example output: 2.6.32
+K_VARIANT=$(echo $K_NAME | sed -e "s/kernel//g")
+# are we a DEBUG kernel?
K_REL=`rpm -q --queryformat '%{release}\n' -qf /boot/config-$(uname -r)`
-# example output: 220.el6
+# example output: 220.el6
K_SRC=`rpm -q --queryformat 'kernel-%{version}-%{release}.src.rpm\n' -qf /boot/config-$(uname -r)`
-# example output: kernel-2.6.32-220.el6.src.rpm
+# example output: kernel-2.6.32-220.el6.src.rpm
K_BASE=`rpm -q --queryformat '%{name}-%{version}-%{release}.%{arch}\n' -qf /boot/config-$(uname -r)`
-# example output: kernel-2.6.32-220.el6.x86_64
+# example output: kernel-2.6.32-220.el6.x86_64
K_ARCH=$(rpm -q --queryformat '%{arch}' -f /boot/config-$(uname -r))
-# example output: x86_64
-# example output: armv7hl
-# example output: armv7l
+# example output: x86_64
+# example output: armv7hl
+# example output: armv7l
K_RUNNING=$(uname -r)
-# example output: 2.6.32-220.el6.x86_64
-K_RUNNING_VR=$(uname -r | sed -e "s/\.${K_ARCH}//")
-# example output: 3.6.10-8.fc18.highbank
+# example output: 2.6.32-220.el6.x86_64
+# We removed the dot between release and variant because kernels built
+# under rhel5 did not include this dot and will make comparing difficult.
+# Release and variant on fedora kernels can use also + sign,
+# example input: 3.15.0-0.rc5.git0.1.el7.x86_64+debug
+K_RUNNING_VR=$(uname -r | sed -e "s/\.${K_ARCH}[.+]*//")
+# example output: 3.6.10-8.fc18highbank
+K_DOWNLOAD="http://download.lab.bos.redhat.com/brewroot/packages/kernel/"
#
RH_REL=`cat /etc/redhat-release | cut -d" " -f7`
-# example output: 6.2
-TESTAREA="/mnt/testarea"
+# example output: 6.2
+K_CONFIG="kernel-$K_VER-$K_ARCH$K_VARIANT.config"
+# example output: kernel-2.6.32-x86_64.config
-### Include these functions
#
-# Print out a header
-function DefaultHeader ()
-{
- echo "*********************************************"
- echo "** Sourcing: /kernel/include **"
- echo "*********************************************"
-
-}
-
+# Functions
+#
# Log a message to the ${DEBUGLOG} or to /dev/null
function DeBug ()
{
- local msg="$1"
+ local msg=$1
local timestamp=$(date '+%F %T')
if [ "$devnull" = "0" ]; then
(
flock -x 200 2>/dev/null
- echo -n "${timestamp}: " >>$DEBUGLOG 2>&1
- echo "${msg}" >>$DEBUGLOG 2>&1
- ) 200>$lck
+ echo -n "${timestamp}: " >> $DEBUGLOG 2>&1
+ echo "${msg}" >> $DEBUGLOG 2>&1
+ ) 200>$lck
else
- echo "${msg}" >/dev/null 2>&1
+ echo "${msg}" > /dev/null 2>&1
fi
}
@@ -71,40 +103,275 @@ function RprtRslt ()
echo "" | tee -a $OUTPUTFILE
echo "***** End of runtest.sh *****" | tee -a $OUTPUTFILE
- TEST=$1
+ local task=$1
# Default result to FAIL
- export RESULT="FAIL"
+ local result="FAIL"
- # SCORE of 0 is PASS. SCORE of 99 is PASS, as test is skipped
- # If no SCORE is given, default to fail and count the reported fails
+ # score of 0 is PASS. score of 99 is PASS, as test is skipped
+ # If no score is given, default to fail and count the reported fails
# Then post-process the results to find the regressions
- if test -z "$2" ; then
- export SCORE=`cat $OUTPUTFILE | grep "FAILED: " | wc -l`
+ if [ -z "$2" ]; then
+ local score=`cat $OUTPUTFILE | grep "FAILED: " | wc -l`
else
- export SCORE=$2
+ local score=$2
fi
- if test ! -s "$OUTPUTFILE" ; then
- export RESULT="FAIL"
+ if [ ! -s "$OUTPUTFILE" ]; then
+ local result="FAIL"
else
- if [ "$SCORE" -eq "0" ] || [ "$SCORE" -eq "99" ]; then
- export RESULT="PASS"
+ if [ "$score" -eq "0" ] || [ "$score" -eq "99" ]; then
+ local result="PASS"
else
- export RESULT="FAIL"
+ local result="FAIL"
fi
fi
# File the results in the database
- report_result $TEST $RESULT $SCORE
+ report_result $task $result $score
SubmitLog $DEBUGLOG
exit 0
}
function SubmitLog ()
{
- LOG=$1
- rhts_submit_log -S $RESULT_SERVER -T $TESTID -l $LOG
+ local log=$1
+ rhts_submit_log -S $RESULT_SERVER -T $TESTID -l $log
+}
+
+function EstatusReport ()
+{
+
+ if [ "$?" -ne "0" ]; then
+ local report=$1
+ local concern=$2
+
+ ReportStatus "$report" "$concern"
+ fi
+}
+
+function EstatusFail ()
+{
+
+ if [ "$?" -ne "0" ]; then
+ local problem=$1
+
+ DisplayFailandBail "$problem"
+ fi
+}
+
+function DisplayFailandBail ()
+{
+ # Display the fail in a informative format and feed RprtRslt
+
+ local issue=$1
+
+ DeBug "Failed: $issue"
+ echo "***** FAILED: $issue *****" | tee -a $OUTPUTFILE
+
+ RprtRslt
+}
+
+function ReportStatus ()
+{
+ # Report test status
+ # $3 is optional and enhances functionality
+
+ local status=$1
+ local message=$2
+
+ DeBug "$status: $message"
+ echo "***** $status: $message *****" | tee -a $OUTPUTFILE
+
+ # If $3 is provided, report_result and continue testing
+ if [ ! -z "$3" ]; then
+ local string=/$3
+
+ # Default to FAIL
+ if [ "$status" = "Passed" ]; then
+ local result="PASS"
+ else
+ local result="FAIL"
+ fi
+
+ # Then file the results in the database
+ report_result ${TEST}${string} $result
+ fi
+}
+
+######################################################
+# Below is a copy of the functions using new
+# naming scheme: K_FunctionName
+# If accepted tasks using kernel/include will
+# be updated and old function names removed.
+
+
+# REBOOTCOUNT is a Beaker env variable set equal to 0
+# Any test that reboots by design needs a workaround
+# Suggestion: define ExpectedRebootCount in test
+# then we can update this function to check variables
+function K_CheckRebootCount ()
+{
+ if [ -n "$REBOOTCOUNT" ]; then
+ if [ "$REBOOTCOUNT" -gt "0" ]; then
+ echo "" | tee -a $OUTPUTFILE
+ echo "***** System rebooted *****" | tee -a $OUTPUTFILE
+ echo "***** Check logs for oops or panic *****" | tee -a $OUTPUTFILE
+ echo "***** End of runtest.sh *****" | tee -a $OUTPUTFILE
+ report_result "system_rebooted" "WARN"
+ K_SubmitLog "$K_DEBUGLOG"
+ exit 0
+ fi
+ fi
+}
+
+# This is a temporary function.
+# ToDo: PBunyan needs modify a few tests to use new function name scheme
+function checkRebootCount ()
+{
+ K_CheckRebootCount
+}
+
+function K_DeBug ()
+{
+ local msg="$1"
+ local timestamp="$(date '+%F %T')"
+
+ if [ "$devnull" = "0" ]; then
+ (
+ flock -x 200 2>/dev/null
+ echo -n "${timestamp}: " >> $K_DEBUGLOG 2>&1
+ echo "${msg}" >> $K_DEBUGLOG 2>&1
+ ) 200>$K_LCK
+ else
+ echo "${msg}" > /dev/null 2>&1
+ fi
+}
+
+function K_SubmitLog ()
+{
+ local log="$1"
+
+ rhts_submit_log -S "$RESULT_SERVER" -T "$TESTID" -l "$log"
+}
+
+function K_ReportResult ()
+{
+ local task="$1"
+
+ # Default result to FAIL
+ local result="FAIL"
+
+ echo "" | tee -a $OUTPUTFILE
+ echo "***** End of runtest.sh *****" | tee -a $OUTPUTFILE
+
+ # score of 0 is PASS. score of 99 is PASS, as test is skipped
+ # If no score is given, default to fail and count the reported fails
+ # Then post-process the results to find the regressions
+ if [ -z "$2" ]; then
+ local score=`cat $OUTPUTFILE | grep "FAILED: " | wc -l`
+ else
+ local score="$2"
+ fi
+
+ if [ ! -s "$OUTPUTFILE" ]; then
+ local result="FAIL"
+ else
+ if [ "$score" -eq "0" ] || [ "$score" -eq "99" ]; then
+ local result="PASS"
+ else
+ local result="FAIL"
+ fi
+ fi
+
+ # File the results in the database
+ report_result "$task" "$result" "$score"
+ K_SubmitLog "$K_DEBUGLOG"
+ exit 0
+}
+
+function K_ReportStatus ()
+{
+ # Report test status
+ # $3 is optional, as its inclusion triggers report_result
+
+ local status="$1"
+ local message="$2"
+
+ K_DeBug " $status: $message"
+ echo "***** $status: $message *****" | tee -a $OUTPUTFILE
+
+ # If $3 is provided, report_result and continue testing
+ if [ ! -z "$3" ]; then
+ local task=/"$3"
+
+ # Default result to FAIL
+ case $status in
+ Passed)
+ local result="PASS"
+ ;;
+ Warn)
+ local result="WARN"
+ ;;
+ *)
+ local result="FAIL"
+ ;;
+ esac
+
+ # Then file the results in the database
+ report_result "${TEST}${task}" "$result"
+ fi
+}
+
+function K_EchoAll ()
+{
+ # echo an entry for debugging
+ # echo output
+
+ local text="$1"
+
+ K_DeBug " $text"
+ echo "***** $text *****" | tee -a $OUTPUTFILE
+}
+
+function K_ReportFailandBail ()
+{
+ # Display the fail in a informative format and feed K_ReportResult
+
+ local issue="$1"
+ local task="$2"
+
+ K_DeBug " FAILED: $issue"
+ echo "***** FAILED: $issue *****" | tee -a $OUTPUTFILE
+
+ K_ReportResult "$task"
+}
+
+function K_EstatusFail ()
+{
+ # Check the exit status
+ # If command fails, report the issue and exit the test
+
+ if [ "$?" -ne "0" ]; then
+ local issue="$1"
+ local task="$2"
+
+ K_ReportFailandBail "$issue" "$task"
+ fi
+}
+
+function K_EstatusWarn ()
+{
+ # Check the exit status
+ # If command fails, report Warn and continue testing
+
+ if [ "$?" -ne "0" ]; then
+ local concern="$1"
+ local task="$2"
+ local report="Warn"
+
+ K_ReportStatus "$report" "$concern" "$task"
+ fi
}
# EndFile