📄 functions.sh
字号:
then exit 0; fi if [ -z "${KERNEL_NAME}" ] then echo Kernel name not defined. exit 99 fi kernelver=`echo ${KERNEL_VERSION} | tr '.' '_'` kernelname=`echo ${KERNEL_NAME} | tr 'a-z' 'A-Z'` kernel_var_name=KERNEL_${kernelname}${kernelver}_SRC echo Looking for kernel source ${kernel_var_name} KERNEL_SRC=${!kernel_var_name} echo at location ${KERNEL_SRC}. if [ -z "${KERNEL_SRC}" ] || [ ! -d "${KERNEL_SRC}" ] then echo Kernel source not found. exit 99 fi # okay, we got some source code to play with! mkdir OUTPUT${KLIPS_MODULE}/$kernel_var_name # get ourselves a kernel source tree. if (cd OUTPUT${KLIPS_MODULE}/$kernel_var_name && lndir -silent $KERNEL_SRC . ) then : else echo Unable to link in kernel source. exit 99 fi env >OUTPUT${KLIPS_MODULE}/env.txt # now patch it. (set +x turns off any debugging there might have been) set -x set -v # the environment variable OPENSWANSRCDIR should be correct # but the make macro OPENSWANSRCDIR may be relative, and hence wrong (cd ${OPENSWANSRCDIR} && make OPENSWANSRCDIR=`pwd` kernelpatch${KERNEL_VERSION} ) | tee OUTPUT${KLIPS_MODULE}/patchfile.patch | (cd OUTPUT${KLIPS_MODULE}/$kernel_var_name && patch -p1 2>&1 ) >OUTPUT${KLIPS_MODULE}/patch-output.txt # compare the patch. if [ -n "${REF_PATCH_OUTPUT}" ] then consolediff "" OUTPUT${KLIPS_MODULE}/patch-output.txt $REF_PATCH_OUTPUT fi # normally, clean up the kernel output, as it is volumnous if [ -z "${KERNEL_PATCH_LEAVE_SOURCE}" ] then rm -rf OUTPUT${KLIPS_MODULE}/$kernel_var_name fi case "$success" in true) exit 0 ;; *) exit 1 ;; esac}# test entry point:kernel_patch_test() { testdir=$1 testexpect=$2 echo '***** KERNEL PATCH RUNNING' $testdir '*******' export UML_BRAND="$$" ( preptest $testdir kernel_patch_test && do_kernel_patch_test ) stat=$? if [ $stat = 99 ] then echo Test missing parts. stat='missing parts' fi recordresults $testdir "$testexpect" "$stat" $testdir}##################################### test type: module_compile####################################do_module_compile_test() { rm -rf OUTPUT${KLIPS_MODULE}/module mkdir -p OUTPUT${KLIPS_MODULE}/module set -e success=false moddir=`cd OUTPUT${KLIPS_MODULE}/module && pwd` prerunsetup if [ -z "${KERNEL_VERSION}" ] then exit 0; fi if [ -z "${KERNEL_NAME}" ] then echo Kernel name not defined. exit 99 fi kernelver=`echo ${KERNEL_VERSION} | tr '.' '_'` kernelname=`echo ${KERNEL_NAME} | tr 'a-z' 'A-Z'` kernel_var_name=KERNEL_${kernelname}${kernelver}_SRC echo Looking for kernel source ${kernel_var_name} KERNEL_SRC=${!kernel_var_name}${KERNVER} if [ -z "${KERNEL_SRC}" ] then echo Kernel source missing. exit 99 fi if [ ! -r ${MODULE_DEF_INCLUDE} ] then echo the file ${MODULE_DEF_INCLUDE} is needed to build this test. exit 99 fi if [ ! -r ${MODULE_DEFCONFIG} ] then echo the file ${MODULE_DEFCONFIG} is needed to build this test. exit 99 fi if [ -z "${ARCH}" ] then ARCH=`uname -m` fi case $ARCH in i?86) ARCH=i386;; esac if [ -z "${SUBARCH}" ] then SUBARCH=${ARCH} fi case $SUBARCH in i?86) SUBARCH=i386;; esac if [ -n "${KERNEL_CONFIG_FILE}" ] then echo "Making local copy of kernel source, for ${KERNEL_CONFIG_FILE}." # if there is a KERNEL_CONFIG_FILE, then we have to # lndir, and "make oldconfig" the kernel to get something working. LOCAL_KERNEL_SRC=`pwd`/OUTPUT${KLIPS_MODULE}/$kernel_var_name rm -rf ${LOCAL_KERNEL_SRC} mkdir -p ${LOCAL_KERNEL_SRC} # get ourselves a kernel source tree, which is configured (cd ${LOCAL_KERNEL_SRC} && lndir -silent $KERNEL_SRC . ) # this directory needs to really be a symlink. rm -r ${LOCAL_KERNEL_SRC}/include/asm cp ${KERNEL_CONFIG_FILE} ${LOCAL_KERNEL_SRC}/.config (cd ${LOCAL_KERNEL_SRC} && make ARCH=${ARCH} SUBARCH=${SUBARCH} oldconfig ) >OUTPUT${KLIPS_MODULE}/oldconfig.txt # repoint ourselves here, so we use the just configured sources. KERNEL_SRC=${LOCAL_KERNEL_SRC} fi # make this name absolute. MODULE_DEF_INCLUDE=`pwd`/$MODULE_DEF_INCLUDE if [ -z "${MODULE_DEFCONFIG}" ] then MODULE_DEFCONFIG=/dev/null else MODULE_DEFCONFIG=`pwd`/$MODULE_DEFCONFIG fi rm -f OUTPUT${KLIPS_MODULE}/module/ipsec.o cmd="(cd $OPENSWANSRCDIR && make KERNELSRC=$KERNEL_SRC MOD${KERNVER}BUILDDIR=$moddir OPENSWANSRCDIR=$OPENSWANSRCDIR MODULE_DEFCONFIG=${MODULE_DEFCONFIG} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} ARCH=${ARCH} SUBARCH=${SUBARCH} module${KERNVER} )" echo "# run as" >OUTPUT${KLIPS_MODULE}/doit.sh echo "$cmd" >>OUTPUT${KLIPS_MODULE}/doit.sh . OUTPUT${KLIPS_MODULE}/doit.sh if [ -n "${KERNEL_PROCESS_FILE}" ] then source ${KERNEL_PROCESS_FILE} elif [ -r OUTPUT${KLIPS_MODULE}/module/ipsec.o ] then success=true fi if [ -n "${KERNEL_CONFIG_FILE}" ] then if [ -z "${KERNEL_PATCH_LEAVE_SOURCE}" ] then rm -r ${KERNEL_CONFIG_FILE} fi fi case "$success" in true) exit 0 ;; *) exit 1 ;; esac}# test entry point:module_compile() { testdir=$1 testexpect=$2 echo '****MODULE COMPILE RUNNING' $testdir '*******' export UML_BRAND="$$" ( preptest $testdir module_compile && do_module_compile_test ) stat=$? if [ $stat = 99 ] then echo Test missing parts. stat='missing parts' fi recordresults $testdir "$testexpect" "$stat" $testdir}##################################### test type: umlXhost - a test with many hosts under control####################################do_umlX_test() { prerunsetup success=true failnum=1 # these are network names EASTOUTPUT='' WESTOUTPUT='' PUBOUTPUT='' EXP2_ARGS='' if [ -n "$EAST_INPUT" ] then EAST_PLAY=$EAST_INPUT export EAST_PLAY fi if [ -n "$WEST_INPUT" ] then WEST_PLAY=$WEST_INPUT export WEST_PLAY fi export NORTH_PLAY export SOUTH_PLAY if [ -n "$PUB_INPUT" ] then EXP2_ARGS="$EXP2_ARGS -p $PUB_INPUT" fi if [ -z "$XHOST_LIST" ] then XHOST_LIST="EAST WEST JAPAN" fi export XHOST_LIST # Xhost script takes things from the environment. for host in $XHOST_LIST do verboseecho "Processing exports for $host" verboseecho lhost=`echo $host | tr 'A-Z' 'a-z'` local startvar startvar=${host}_START if [ -z "${!startvar}" ] then local startdir local starthost starthost=${host}HOST startdir=$POOLSPACE/${!starthost} if [ -n "$KLIPS_MODULE" ] then eval ${host}_START=$startdir/startmodule.sh else eval ${host}_START=$startdir/start.sh fi fi export ${host}_START eval "REF${KERNVER}_${host}_CONSOLE_RAW=OUTPUT${KLIPS_MODULE}/${KERNVER}${lhost}console.txt" export REF${KERNVER}_${host}_CONSOLE_RAW export ${host}_INIT_SCRIPT export ${host}_RUN_SCRIPT export ${host}_RUN2_SCRIPT export ${host}_RUN3_SCRIPT export ${host}_RUN4_SCRIPT export ${host}_RUN5_SCRIPT export ${host}_FINAL_SCRIPT done for net in NORTH SOUTH NORTHPUBLIC SOUTHPUBLIC EAST WEST PUBLIC ADMIN do export ${net}_PLAY export ${net}_REC export ${net}_ARPREPLY done if [ -n "$REF_EAST_OUTPUT" ] then EASTOUTPUT=`basename $REF_EAST_OUTPUT .txt ` EXP2_ARGS="$EXP2_ARGS -E OUTPUT${KLIPS_MODULE}/$EASTOUTPUT.pcap" fi if [ -n "$REF_WEST_OUTPUT" ] then WESTOUTPUT=`basename $REF_WEST_OUTPUT .txt ` EXP2_ARGS="$EXP2_ARGS -W OUTPUT${KLIPS_MODULE}/$WESTOUTPUT.pcap" fi if [ -n "$REF_NORTH_OUTPUT" ] then NORTHOUTPUT=`basename $REF_NORTH_OUTPUT .txt ` NORTH_REC=OUTPUT${KLIPS_MODULE}/$EASTOUTPUT.pcap export NORTH_REC fi if [ -n "$REF_SOUTH_OUTPUT" ] then SOUTHOUTPUT=`basename $REF_SOUTH_OUTPUT .txt ` SOUTH_REC=OUTPUT${KLIPS_MODULE}/$WESTOUTPUT.pcap export SOUTH_REC fi if [ -n "$REF_PUB_OUTPUT" ] then PUBOUTPUT=`basename $REF_PUB_OUTPUT .txt` EXP2_ARGS="$EXP2_ARGS -P OUTPUT${KLIPS_MODULE}/$PUBOUTPUT.pcap" fi if [ "X$ARPREPLY" = "X--arpreply" ] then EXP2_ARGS="$EXP2_ARGS -a" fi if [ -n "$NETJIG_EXTRA" ] then EXP2_ARGS="$EXP2_ARGS -N $NETJIG_EXTRA" fi EXP2_ARGS="$EXP2_ARGS "`setup_additional_hosts` rm -f OUTPUT${KLIPS_MODULE}/eastconsole.txt rm -f OUTPUT${KLIPS_MODULE}/westconsole.txt rm -f OUTPUT${KLIPS_MODULE}/japanconsole.txt cmd="expect -f $UTILS/Xhost-test.tcl -- -n $NJ $EXP2_ARGS " $NETJIGDEBUG && echo $cmd eval $cmd pcap_filter west "$REF_WEST_OUTPUT" "$WESTOUTPUT" "$REF_WEST_FILTER" pcap_filter east "$REF_EAST_OUTPUT" "$EASTOUTPUT" "$REF_EAST_FILTER" pcap_filter public "$REF_PUB_OUTPUT" "$PUBOUTPUT" "$REF_PUB_FILTER" for host in $XHOST_LIST do local consoleref consoleref=REF${KERNVER}_${host}_CONSOLE_OUTPUT lhost=`echo $host | tr 'A-Z' 'a-z'` if [ -n "${!consoleref}" ] then consolediff ${KERNVER}$lhost OUTPUT${KLIPS_MODULE}/${KERNVER}${lhost}console.txt ${!consoleref} fi done case "$success" in true) exit 0 ;; *) exit 1 ;; esac}# test entry point:umlXhost() { testdir=$1 testexpect=$2 echo '***** UML 3HOST RUNNING' $testdir '*******' export UML_BRAND="$$" ( preptest $testdir umlXhost && do_umlX_test ) stat=$? recordresults $testdir "$testexpect" "$stat" $testdir}## $Id: functions.sh,v 1.117 2004/11/09 18:36:35 ken Exp $## $Log: functions.sh,v $# Revision 1.117 2004/11/09 18:36:35 ken# rpm -> ipkg## Revision 1.116 2004/11/09 18:30:24 ken# Add functions for ipkg_build_install_test## Revision 1.115 2004/10/20 01:43:58 mcr# redirected stderr to capture file as well.## Revision 1.114 2004/10/19 22:10:54 mcr# capture and compare the output as well.## Revision 1.113 2004/10/17 17:37:45 mcr# run library tests in the subdir (so core will go there),# and make sure that core dumps are enabled.## Revision 1.112 2004/10/16 22:53:22 mcr# added EXTRAFLAGS and EXTRALIBS variable to library test# process, and provide FLAGS.testobj file to configure# test case.## Revision 1.111 2004/09/21 01:20:09 mcr# support per-kernel console output## Revision 1.110 2004/09/13 02:26:48 mcr# use appropriate console comparison file.## Revision 1.109 2004/08/22 04:59:59 mcr# fix up module compile test to work with 2.6.# added post-build complicated check.## Revision 1.108 2004/05/19 14:53:31 mcr# call summarize results just before each test case.## Revision 1.107 2004/04/16 19:57:29 mcr# if THREEEIGHT is set to true, then do not run the# three-eight filter.## Revision 1.106 2004/04/09 18:30:05 mcr# look in all sorts of places for the library code.## Revision 1.105 2004/04/04 03:57:58 ken# Change order of options to ps, as newer versions are more strict about order## Revision 1.104 2004/04/03 19:44:52 ken# FREESWANSRCDIR -> OPENSWANSRCDIR (patch by folken)## Revision 1.103 2004/02/16 04:13:37 mcr# use new NETWORK_ARPREPLY= to decide how/when to answer arp# requests.## Revision 1.102 2004/02/03 20:14:39 mcr# networks are now managed as a list rather than explicitely.## Revision 1.101 2003/11/25 00:22:53 mcr# have skiptest make up a fake TEST_PURPOSE, so there are# no complaints from regressrecord.## Revision 1.100 2003/11/05 07:38:30 dhr## make functions.sh more robust## Revision 1.99 2003/11/05 04:35:56 dhr## clarify shell variable export command## Revision 1.98 2003/10/31 02:43:33 mcr# pull up of port-selector tests## Revision 1.97 2003/10/29 20:52:37 dhr## functions.sh: silence grep; add "rogue" to status if rogue was found## Revision 1.96 2003/10/28 03:03:33 dhr## Refine testing scripts:# - put timeout and eof handlers in each expect script# - kill more rogue processes: even those with unreadable(!) /proc entries# - improve reporting of skipped tests# - make "recordresults" do more, simplifying every caller# - speed up UML shutdown by using "halt -p -r" (requires many reference log updates)## Revision 1.95 2003/10/21 15:08:03 dhr## - show more raw detail within braces of testing report# - make functions.sh clearer# - silence the "kill" commands in function.sh that probe for successful killing## Revision 1.94 2003/10/16 03:14:56 dhr## Many minor improvements to functions.sh:# - add quotes for good shell hygiene# - try harder to kill rogue UML processes# - use "case" to analyze $success (``if $success'' fails whe $success is "missing")# The use of $success is still disorganized and confusing. With some work# it could be used to produce better diagnostics.## Revision 1.93 2003/10/16 02:56:47 dhr## clean up whitespace## Revision 1.92 2003/10/15 15:31:57 dhr## functions.sh: let recordresults survive a testparams.sh that exits## Revision 1.91 2003/10/14 22:07:09 dhr## functions.sh: let recordresults survive a missing testparams.sh## Revision 1.90 2003/10/14 14:23:29 dhr## Fix some problems with "make check" (testing/utils/functions.sh):# - Make sure that each "source" or "." command uses a pathname with a slash.# Otherwise the $PATH will be used.# - Fix the TEST_PURPOSE analysis: source testparams.sh in recordresults.# Note when TEST_PURPOSE isn't understood.# - remove redundant "rm -rf" commands## Revision 1.89 2003/10/01 16:13:56 dhr## Make the -modules hack in testing/klips/dotests.sh actually work:# add ${KLIPS_MODULE} to almost every path with OUTPUT that didn't already have it.## Revision 1.88.2.1 2003/10/29 02:09:56 mcr# set test purpose to REGRESS for library tests.## Revision 1.88 2003/08/21 22:38:06 mcr# sense of test was wrong for MODULE_DEFCONFIG## Revision 1.87 2003/08/21 22:35:11 mcr# if we didn't specify a MODULE_DEFCONFIG, then use /dev/null## Revision 1.86 2003/08/18 16:32:48 mcr# export 3,4,5 RUN script variables.## Revision 1.85 2003/05/21 14:10:31 mcr# look for core files produced by pluto, and save them to the# OUTPUT directory, changing failure state to "core".## Revision 1.84 2003/05/03 23:26:02 mcr# added RCS Ids.##
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -