Skip to content

Commit

Permalink
sharness: update flux-sharness.sh
Browse files Browse the repository at this point in the history
Problem: test_under_flux() conditionally
starts the broker with the -q option,
but that option is no longer valid.

N.B. flux-broker -q,--quiet was dropped in
PR flux-framework/flux-core#1464.

flux-sharness.sh has lagged behind the
one in flux-core.  Copy over the
flux-core version.
  • Loading branch information
garlick committed Apr 18, 2018
1 parent 79dcae4 commit a5f5aea
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions t/sharness.d/flux-sharness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,37 @@ test_size_large() {
echo ${size}
}


#
# Tests using test_under_flux() and which load their own modules should
# ensure those modules are unloaded at the end of the test for proper
# cleanup and test coverage (also as a general principle, module unload
# should be something explicitly tested).
#
# The functions below ensure that every module loaded at "test_done" time
# when test_under_flux() was used was also loaded before test_under_flux
# was called.
#
flux_module_list() {
flux module list | awk '!/^Module/{print $1}' | sort
}

check_module_list() {
flux_module_list > module-list.final
while read module; do
grep "^$module$" module-list.initial >/dev/null 2>&1 \
|| bad="${bad}${bad:+ }$module"
done < module-list.final
if test -n "$bad"; then
test -n "$logfile" \
&& say_color error >&3 \
"Error: manually loaded module(s) not unloaded: $bad"
# This function is run under test_eval_ so redirect
# error message to &5 (saved stdout) so text doesn't disappear:
error >&5 2>&1 "manually loaded module(s) not unloaded: $bad"
fi
}

#
# Reinvoke a test file under a flux comms instance
#
Expand All @@ -34,39 +65,49 @@ test_under_flux() {
personality=${2:-full}
log_file="$TEST_NAME.broker.log"
if test -n "$TEST_UNDER_FLUX_ACTIVE" ; then
cleanup rm "${SHARNESS_TEST_DIRECTORY:-..}/$log_file"
test "$debug" = "t" || cleanup rm "${SHARNESS_TEST_DIRECTORY:-..}/$log_file"
flux_module_list > module-list.initial
cleanup check_module_list
return
fi
quiet="-o -q,-Slog-filename=${log_file},-Slog-forward-level=7"
if test "$verbose" = "t" -o -n "$FLUX_TESTS_DEBUG" ; then
flags="${flags} --verbose"
quiet=""
fi
if test "$debug" = "t" -o -n "$FLUX_TESTS_DEBUG" ; then
flags="${flags} --debug"
fi
if test "$chain_lint" = "t"; then
flags="${flags} --chain-lint"
fi
if test -n "$logfile" -o -n "$FLUX_TESTS_LOGFILE" ; then
flags="${flags} --logfile"
fi
if test -n "$SHARNESS_TEST_DIRECTORY"; then
cd $SHARNESS_TEST_DIRECTORY
fi
timeout="-o -Sinit.rc2_timeout=300"
if test -n "$FLUX_TEST_DISABLE_TIMEOUT"; then
timeout=""
fi

if test "$personality" = "minimal"; then
export FLUX_RC1_PATH=""
export FLUX_RC3_PATH=""
elif test "$personality" != "full"; then
export FLUX_RC1_PATH=$FLUX_SOURCE_DIR/t/rc/rc1-$personality
export FLUX_RC3_PATH=""
test -x $FLUX_RC1_PATH || error "$FLUX_RC1_PATH"
export FLUX_RC3_PATH=$FLUX_SOURCE_DIR/t/rc/rc3-$personality
test -x $FLUX_RC1_PATH || error "cannot execute $FLUX_RC1_PATH"
test -x $FLUX_RC3_PATH || error "cannot execute $FLUX_RC3_PATH"
else
unset FLUX_RC1_PATH
unset FLUX_RC3_PATH
fi

logopts="-o -Slog-filename=${log_file},-Slog-forward-level=7"
TEST_UNDER_FLUX_ACTIVE=t \
TERM=${ORIGINAL_TERM} \
exec flux start --size=${size} ${quiet} "sh $0 ${flags}"
exec flux start --bootstrap=selfpmi --size=${size} ${logopts} ${timeout} \
"sh $0 ${flags}"
}

mock_bootstrap_instance() {
Expand Down Expand Up @@ -98,4 +139,7 @@ if ! lua -e 'require "posix"'; then
error "failed to find lua posix module in path"
fi

# Some tests in flux don't work with --chain-lint, add a prereq for
# --no-chain-lint:
test "$chain_lint" = "t" || test_set_prereq NO_CHAIN_LINT
# vi: ts=4 sw=4 expandtab

0 comments on commit a5f5aea

Please sign in to comment.