summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorBill Peck <bpeck@redhat.com>2013-04-23 13:17:17 -0400
committerBill Peck <bpeck@redhat.com>2013-04-23 13:17:17 -0400
commitbcfbeb2fc2df8b10b747fa3c165752aa31221858 (patch)
treea0bc7d7ff55208ab11690e1e4dc5d2201253bf8b /kernel
parent44188568f1cd5d8f36fe3361acb9a6f3f7060b48 (diff)
downloadtests-bcfbeb2fc2df8b10b747fa3c165752aa31221858.tar.gz
tests-bcfbeb2fc2df8b10b747fa3c165752aa31221858.tar.xz
tests-bcfbeb2fc2df8b10b747fa3c165752aa31221858.zip
copy and update of /kernel/include
Diffstat (limited to 'kernel')
-rw-r--r--kernel/include/Makefile48
-rw-r--r--kernel/include/PURPOSE27
-rwxr-xr-xkernel/include/runtest.sh110
3 files changed, 185 insertions, 0 deletions
diff --git a/kernel/include/Makefile b/kernel/include/Makefile
new file mode 100644
index 0000000..6b73226
--- /dev/null
+++ b/kernel/include/Makefile
@@ -0,0 +1,48 @@
+# 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
+
+# The toplevel namespace within which the test lives.
+TOPLEVEL_NAMESPACE=/$(PACKAGE_NAME)
+
+# The toplevel namespace within which the test lives.
+PACKAGE_NAME=kernel
+
+# The name of the package under test.
+RELATIVE_PATH=include
+
+# The relative path name to the test
+export TEST=$(TOPLEVEL_NAMESPACE)/$(RELATIVE_PATH)
+
+# All files you want bundled into your rpm:
+# data files, scripts, and anything needed to either
+# compile the test and/or run it.
+FILES= $(METADATA) \
+ runtest.sh
+
+build:
+ chmod a+x runtest.sh
+
+run: $(FILES) build
+ ./runtest.sh
+
+clean:
+ $(RM) $(METADATA)
+ $(RM) *~ kernel-kernel-include*
+
+# Generate the testinfo.desc here:
+$(METADATA):
+ touch $(METADATA)
+ @echo "Name: $(TEST)" >$(METADATA)
+ @echo "Description: Common functions and/or variables for Kernel Testing Tasks." >>$(METADATA)
+ @echo "Path: $(TEST_DIR)" >>$(METADATA)
+ @echo "TestTime: 5m" >>$(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >>$(METADATA)
+ @echo "License: GPLv3" >>$(METADATA)
+ @echo "Owner: Paul Bunyan<pbunyan@redhat.com>" >>$(METADATA)
+ @echo "Provides: test(/kernel/include)" >>$(METADATA)
+ @cat $(METADATA)
+
+# EndFile
diff --git a/kernel/include/PURPOSE b/kernel/include/PURPOSE
new file mode 100644
index 0000000..f995ace
--- /dev/null
+++ b/kernel/include/PURPOSE
@@ -0,0 +1,27 @@
+# ===========================================================
+#
+# PURPOSE file for:
+# Kernel Testing Include File
+# /kernel/include/runtest.sh
+# test(/kernel/include)
+#
+# Description:
+# This is the Shell library for including common functions
+# and/or variables for Kernel Testing Tasks.
+#
+# Author(s):
+# Paul Bunyan <pbunyan@redhat.com>
+# Jeff Burke <jburke@redhat.com>
+#
+# ===========================================================
+#
+# Two lines will need be added to each task that will source
+# this "include" file:
+# [1] For each task add the following to the runtest.sh script:
+# . /mnt/tests/kernel/include/runtest.sh
+#
+# [2] For each task add the following to the Makefile:
+# @echo "RhtsRequires: test(/kernel/include)" >>$(METADATA)
+#
+# ===========================================================
+# EndFile
diff --git a/kernel/include/runtest.sh b/kernel/include/runtest.sh
new file mode 100755
index 0000000..94a2ff1
--- /dev/null
+++ b/kernel/include/runtest.sh
@@ -0,0 +1,110 @@
+#!/bin/sh
+#
+### Kernel Testing Include File
+
+### Include these variables
+#
+# control where to log debug messages to:
+# devnull = 1 : log to /dev/null
+# devnull = 0 : log to file specified in ${DEBUGLOG}
+devnull=0
+
+# Create debug log
+DEBUGLOG=`mktemp -p /mnt/testarea -t DeBug.XXXXXX`
+
+# locking to avoid races
+lck=$OUTPUTDIR/$(basename $0).lck
+
+# Kernel Variables
+K_NAME=`rpm -q --queryformat '%{name}\n' -qf /boot/config-$(uname -r)`
+# example output: kernel
+K_VER=`rpm -q --queryformat '%{version}\n' -qf /boot/config-$(uname -r)`
+# example output: 2.6.32
+K_REL=`rpm -q --queryformat '%{release}\n' -qf /boot/config-$(uname -r)`
+# 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
+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
+K_ARCH=$(rpm -q --queryformat '%{arch}' -f /boot/config-$(uname -r))
+# 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
+#
+RH_REL=`cat /etc/redhat-release | cut -d" " -f7`
+# example output: 6.2
+TESTAREA="/mnt/testarea"
+
+### Include these functions
+#
+# Print out a header
+function DefaultHeader ()
+{
+ echo "*********************************************"
+ echo "** Sourcing: /kernel/include **"
+ echo "*********************************************"
+
+}
+
+# Log a message to the ${DEBUGLOG} or to /dev/null
+function DeBug ()
+{
+ 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
+ else
+ echo "${msg}" >/dev/null 2>&1
+ fi
+}
+
+function RprtRslt ()
+{
+ echo "" | tee -a $OUTPUTFILE
+ echo "***** End of runtest.sh *****" | tee -a $OUTPUTFILE
+
+ TEST=$1
+
+ # Default result to FAIL
+ export 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
+ # Then post-process the results to find the regressions
+ if test -z "$2" ; then
+ export SCORE=`cat $OUTPUTFILE | grep "FAILED: " | wc -l`
+ else
+ export SCORE=$2
+ fi
+
+ if test ! -s "$OUTPUTFILE" ; then
+ export RESULT="FAIL"
+ else
+ if [ "$SCORE" -eq "0" ] || [ "$SCORE" -eq "99" ]; then
+ export RESULT="PASS"
+ else
+ export RESULT="FAIL"
+ fi
+ fi
+
+ # File the results in the database
+ report_result $TEST $RESULT $SCORE
+ SubmitLog $DEBUGLOG
+ exit 0
+}
+
+function SubmitLog ()
+{
+ LOG=$1
+ rhts_submit_log -S $RESULT_SERVER -T $TESTID -l $LOG
+}
+
+# EndFile