simplify supervised vs. standalone mode detection; also fix the docs

This commit is contained in:
George Danchev 2012-04-21 15:41:45 +00:00
parent 89fdb9b3b6
commit 04fe7a2d2a
3 changed files with 18 additions and 29 deletions

View File

@ -229,10 +229,15 @@ When exiting prematurely, make sure to call function cleanup.
Variables, general options, helper functions
The master script run_all_auto sets this variable:
RELENG_SCRIPT_RUN_BY_RUN_ALL_AUTO
1=supervised, the script is run by run_all_auto script
else=standalone, the script is run in standalone mode
The code piece inc/releng_getopts.inc should get executed inline at the
start of a test script.
It initializes the following variables and sets some of them according
to the general options of the test suite:
start of a test script. It initializes the following variables and sets
some of them according to the general options of the test suite:
SELF basename $0
@ -250,17 +255,12 @@ to the general options of the test suite:
SPECIFIC_HELP 0=normal operation, 1=print help text of script and exit 0
Default 0. Setable to 1 by option -h.
RELENG_STANDALONE 0=standalone, 1=supervised by run_all_auto script,
-1=undefined.
RELENG_PARENT Name of the parent process. Default: unknown_parent
The code piece inc/releng_getopts.inc defines the following functions
for use by the single tests:
standalone_or_supervised This is internally called routine to find
out the running mode of the scripts - standalone,
supervised by run_all_auto, or unknown.
supervised by run_all_auto.
No need to call it from the scripts themselves.
print_help Prints the help text for general options.

View File

@ -9,34 +9,20 @@ CLEANUP=1
SPECIFIC_HELP=0
START_DIR_DONT_CHANGE=`pwd`
GEN_DATA_DIR=releng_generated_data/${SELF}
RELENG_STANDALONE=-1
RELENG_PARENT=unknown_parent
#############################################
standalone_or_supervised() {
which ps >/dev/null 2>&1
ret="$?"
case "$ret" in
0)
RELENG_PARENT=`ps -p $PPID -o comm=`
if test x"$RELENG_PARENT" = x"run_all_auto"
then
echo "${SELF}: Running in Supervised mode by ${RELENG_PARENT}"
RELENG_STANDALONE=0
else
echo "${SELF}: Running in Standalone mode"
RELENG_STANDALONE=1
fi
case "${RELENG_SCRIPT_RUN_BY_RUN_ALL_AUTO}" in
1)
echo "${SELF}: Running in Supervised mode"
;;
*)
echo "${SELF}: Running in Unknown mode by ${RELENG_PARENT}"
echo "${SELF}: Running in Standalone mode"
;;
esac
esac
}
# Unconditionally initialize the invocation mode - standalone or supervised
# Unconditionally shout out the invocation mode - standalone or supervised
standalone_or_supervised
#############################################

View File

@ -6,6 +6,9 @@
set -e
export RELENG_SCRIPT_RUN_BY_RUN_ALL_AUTO
RELENG_SCRIPT_RUN_BY_RUN_ALL_AUTO=1
SELF=$(basename "$0")
GEN_DATA_DIR=releng_generated_data
CLOG=${GEN_DATA_DIR}/log.${SELF}