add common test framework
Add new file with common functions for tests to use. - loads config file - checks for mcexec etc - checks for LTP and OSTEST if required - handle mcstop / mcreboot if required, and provide function for it At the same time, make a few changes to mck_test_config: - move to ~/.mck_test_config - add boot params to the config, tests the require specific params can overwite it - make the config "set-if-variable-is-empty", so someone can overwrite any param by setting the environment value e.g. LTP=.... ./test.sh will use the value given Change-Id: Ib04112043e3eb89615dc7afaa8842a98571fab93
This commit is contained in:
committed by
Dominique Martinet
parent
7e342751a2
commit
60011718d2
117
test/common.sh
Normal file
117
test/common.sh
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
# Common test framework, source this file to get config and basic variables:
|
||||||
|
# BIN/SBIN are the mckernel install paths
|
||||||
|
# if USELTP is set,
|
||||||
|
# LTP is the root of the ltp install directory
|
||||||
|
# LTPBIN is the testcases bin dir
|
||||||
|
# if USEOSTEST is set,
|
||||||
|
# OSTEST is the root of the ostest repo after install
|
||||||
|
# TESTMCK is the test_mck binary
|
||||||
|
# MCEXEC, IHKCONFIG, IHKOSCTL are the corresponding binaries
|
||||||
|
# mcreboot and mcstop are functions that perform the action with prints/checks
|
||||||
|
#
|
||||||
|
# Additionally, the following parameters can be provided through environment:
|
||||||
|
# BOOTPARAM to override mcreboot options
|
||||||
|
# MCREBOOT and MCSTOP can be set to 0/empty to not run the action at start
|
||||||
|
|
||||||
|
|
||||||
|
# Unfortunately, there is no standard way to get sourced file's path
|
||||||
|
# use bash-specific feature.
|
||||||
|
TEST_BASE=$(dirname "${BASH_SOURCE[0]}")
|
||||||
|
|
||||||
|
if [ -f "$HOME/.mck_test_config" ]; then
|
||||||
|
. "$HOME/.mck_test_config"
|
||||||
|
elif [ -f "$TEST_BASE/../mck_test_config.sample" ]; then
|
||||||
|
. "$TEST_BASE/../mck_test_config.sample"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [[ -z "$BIN" ]]; then
|
||||||
|
if [ -f ../../../config.h ]; then
|
||||||
|
BIN=$(awk -F\" '/^#define BINDIR/ { print $2; exit }' \
|
||||||
|
"$TEST_BASE/../config.h")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$SBIN" ]]; then
|
||||||
|
if [ -f ../../../Makefile ]; then
|
||||||
|
SBIN=$(awk -F\" '/^#define SBINDIR/ { print $2; exit }' \
|
||||||
|
"$TEST_BASE/../config.h")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x "$BIN/mcexec" ]]; then
|
||||||
|
echo no mckernel found $BIN >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
MCEXEC="$BIN/mcexec"
|
||||||
|
IHKOSCTL="$SBIN/ihkosctl"
|
||||||
|
IHKCONFIG="$SBIN/ihkconfig"
|
||||||
|
|
||||||
|
if ((USELTP)); then
|
||||||
|
if [[ -z "$LTP" ]]; then
|
||||||
|
if [[ -f "$HOME/ltp/testcases/bin/fork01" ]]; then
|
||||||
|
LTP="$HOME/ltp"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x "$LTP/testcases/bin/fork01" ]]; then
|
||||||
|
echo no LTP found $LTP >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
LTPBIN="$LTP/testcases/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((USEOSTEST)); then
|
||||||
|
if [[ -z "$OSTEST" ]]; then
|
||||||
|
if [[ -f "$HOME/ostest/bin/test_mck" ]]; then
|
||||||
|
OSTEST="$HOME/ostest"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x "$OSTEST"/bin/test_mck ]]; then
|
||||||
|
echo no ostest found $OSTEST >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
TESTMCK="$OSTEST/bin/test_mck"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# compat variables
|
||||||
|
BINDIR="$BIN"
|
||||||
|
SBINDIR="$SBIN"
|
||||||
|
LTPDIR="$LTP"
|
||||||
|
OSTESTDIR="$OSTEST"
|
||||||
|
|
||||||
|
if [[ ! -x "$SBIN/mcstop+release.sh" ]]; then
|
||||||
|
echo mcstop+release: not found >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x "$SBIN/mcreboot.sh" ]]; then
|
||||||
|
echo mcreboot: not found >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mcstop() {
|
||||||
|
echo -n "mcstop+release.sh ... "
|
||||||
|
sudo "$SBIN/mcstop+release.sh"
|
||||||
|
echo "done"
|
||||||
|
|
||||||
|
if lsmod | grep mcctrl > /dev/null 2>&1; then
|
||||||
|
echo mckernel shutdown failed >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
mcreboot() {
|
||||||
|
echo -n "mcreboot.sh $BOOTPARAM ... "
|
||||||
|
sudo "$SBIN/mcreboot.sh" $BOOTPARAM
|
||||||
|
echo "done"
|
||||||
|
|
||||||
|
if ! lsmod | grep mcctrl > /dev/null 2>&1; then
|
||||||
|
echo mckernel boot failed >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
((${MCSTOP-1})) && mcstop
|
||||||
|
((${MCREBOOT-1})) && mcreboot
|
||||||
@ -1,116 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
BOOTPARAM="-c 1-7,9-15,17-23,25-31 -m 10G@0,10G@1 -r 1-7:0+9-15:8+17-23:16+25-31:24"
|
|
||||||
USELTP=1
|
USELTP=1
|
||||||
USEOSTEST=1
|
USEOSTEST=1
|
||||||
|
|
||||||
################################################################################
|
. ../../common.sh
|
||||||
BINDIR=
|
|
||||||
SBINDIR=
|
|
||||||
OSTESTDIR=
|
|
||||||
LTPDIR=
|
|
||||||
LTPBIN=
|
|
||||||
MCEXEC=
|
|
||||||
TESTMCK=
|
|
||||||
|
|
||||||
if [ -f $HOME/mck_test_config ]; then
|
|
||||||
. $HOME/mck_test_config
|
|
||||||
elif [ -f ../../../mck_test_config.sample ]; then
|
|
||||||
. ../../../mck_test_config.sample
|
|
||||||
else
|
|
||||||
BIN=
|
|
||||||
SBIN=
|
|
||||||
OSTEST=
|
|
||||||
LTP=
|
|
||||||
fi
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
if [ "x$BIN" = x ]; then
|
|
||||||
if [ -f ../../../config.h ]; then
|
|
||||||
str=`grep "^#define BINDIR " ../../../config.h | head -1 | sed 's/^#define BINDIR /BINDIR=/'`
|
|
||||||
eval $str
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
BINDIR="$BIN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "x$SBIN" = x ]; then
|
|
||||||
if [ -f ../../../Makefile ]; then
|
|
||||||
str=`grep ^SBINDIR ../../../Makefile | head -1 | sed 's/ //g'`
|
|
||||||
eval $str
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
SBINDIR="$SBIN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -x "$BINDIR/mcexec" ]; then
|
|
||||||
echo no mckernel found $BINDIR >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
MCEXEC="$BINDIR/mcexec"
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
if [ "x$USELTP" != x ]; then
|
|
||||||
if [ "x$LTP" = x ]; then
|
|
||||||
if [ -f "$HOME/ltp/testcases/bin/fork01" ]; then
|
|
||||||
LTPDIR="$HOME/ltp"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
LTPDIR="$LTP"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -x "$LTPDIR/testcases/bin/fork01" ]; then
|
|
||||||
echo no LTP found $LTPDIR >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
LTPBIN="$LTPDIR/testcases/bin"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
if [ "x$USEOSTEST" != x ]; then
|
|
||||||
if [ "x$OSTEST" = x ]; then
|
|
||||||
if [ -f "$HOME/ostest/bin/test_mck" ]; then
|
|
||||||
OSTESTDIR="$HOME/ostest"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
OSTESTDIR="$OSTEST"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -x "$OSTESTDIR"/bin/test_mck ]; then
|
|
||||||
echo no ostest found $OSTESTDIR >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
TESTMCK="$OSTESTDIR/bin/test_mck"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
if [ ! -x "$SBINDIR/mcstop+release.sh" ]; then
|
|
||||||
echo mcstop+release: not found >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo -n "mcstop+release.sh ... "
|
|
||||||
sudo "$SBINDIR/mcstop+release.sh"
|
|
||||||
echo "done"
|
|
||||||
|
|
||||||
if lsmod | grep mcctrl > /dev/null 2>&1; then
|
|
||||||
echo mckernel shutdown failed >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -x "$SBINDIR/mcreboot.sh" ]; then
|
|
||||||
echo mcreboot: not found >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo -n "mcreboot.sh $BOOTPARAM ... "
|
|
||||||
sudo "$SBINDIR/mcreboot.sh" $BOOTPARAM
|
|
||||||
echo "done"
|
|
||||||
|
|
||||||
if ! lsmod | grep mcctrl > /dev/null 2>&1; then
|
|
||||||
echo mckernel boot failed >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
"$MCEXEC" "$TESTMCK" -s getrusage -n 2 2>&1 | tee C1176T01.txt
|
"$MCEXEC" "$TESTMCK" -s getrusage -n 2 2>&1 | tee C1176T01.txt
|
||||||
if grep "RESULT: you need check rusage value" C1176T01.txt > /dev/null 2>&1;then
|
if grep "RESULT: you need check rusage value" C1176T01.txt > /dev/null 2>&1;then
|
||||||
echo "*** C1176T01: OK"
|
echo "*** C1176T01: OK"
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
# Config file for McKernel tests
|
# Config file for McKernel tests
|
||||||
BIN=@prefix@/bin
|
: ${BIN:=@prefix@/bin}
|
||||||
SBIN=@prefix@/sbin
|
: ${SBIN:=@prefix@/sbin}
|
||||||
OSTEST=
|
: ${OSTEST:=}
|
||||||
LTP=
|
: ${LTP:=}
|
||||||
|
: ${BOOTPARAM:=-c 1-7,9-15,17-23,25-31 -m 10G@0,10G@1 -r 1-7:0+9-15:8+17-23:16+25-31:24}
|
||||||
|
|||||||
Reference in New Issue
Block a user