mirror of
https://github.com/ovh/the-bastion.git
synced 2024-09-20 15:05:58 +08:00
enh: tests: --module can be specified multiple times
This commit is contained in:
parent
4e9dffda44
commit
0f1596b51c
|
@ -23,7 +23,7 @@ Test Options:
|
||||||
--skip-consistency-check Speed up tests by skipping the consistency check between every test
|
--skip-consistency-check Speed up tests by skipping the consistency check between every test
|
||||||
--no-pause-on-fail Don't pause when a test fails
|
--no-pause-on-fail Don't pause when a test fails
|
||||||
--log-prefix=X Prefix all logs by this name
|
--log-prefix=X Prefix all logs by this name
|
||||||
--module=X Only test this module (specify a filename found in \`functional/tests.d/\`)
|
--module=X Only test this module (specify a filename found in \`functional/tests.d/\`), can be specified multiple times
|
||||||
|
|
||||||
Remote OS directory locations:
|
Remote OS directory locations:
|
||||||
--remote-etc-bastion=X Override the default remote bastion configuration directory (default: $opt_remote_etc_bastion)
|
--remote-etc-bastion=X Override the default remote bastion configuration directory (default: $opt_remote_etc_bastion)
|
||||||
|
@ -72,13 +72,13 @@ do
|
||||||
opt_log_prefix="$optval"
|
opt_log_prefix="$optval"
|
||||||
;;
|
;;
|
||||||
--module=*)
|
--module=*)
|
||||||
opt_module="$optval"
|
|
||||||
if [ ! -e "$basedir/tests/functional/tests.d/$optval" ]; then
|
if [ ! -e "$basedir/tests/functional/tests.d/$optval" ]; then
|
||||||
echo "Unknown module specified '$opt_module', supported modules are:"
|
echo "Unknown module specified '$optval', supported modules are:"
|
||||||
cd "$basedir/tests/functional/tests.d"
|
cd "$basedir/tests/functional/tests.d"
|
||||||
ls -- ???-*.sh
|
ls -- ???-*.sh
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
opt_module="$opt_module $optval"
|
||||||
;;
|
;;
|
||||||
--has-*=*)
|
--has-*=*)
|
||||||
optname=${1/--has-/}
|
optname=${1/--has-/}
|
||||||
|
@ -528,11 +528,12 @@ sshclientconfigchg()
|
||||||
|
|
||||||
runtests()
|
runtests()
|
||||||
{
|
{
|
||||||
|
modulename=main
|
||||||
|
|
||||||
# ensure syslog is clean
|
# ensure syslog is clean
|
||||||
ignorecodewarn 'Configuration error' # previous unit tests can provoke this
|
ignorecodewarn 'Configuration error' # previous unit tests can provoke this
|
||||||
success syslog_cleanup $r0 "\": > /var/log/bastion/bastion.log\""
|
success syslog_cleanup $r0 "\": > /var/log/bastion/bastion.log\""
|
||||||
|
|
||||||
modulename=main
|
|
||||||
# backup the original default configuration on target side
|
# backup the original default configuration on target side
|
||||||
now=$(date +%s)
|
now=$(date +%s)
|
||||||
success backupconfig $r0 "dd if=$opt_remote_etc_bastion/bastion.conf of=$opt_remote_etc_bastion/bastion.conf.bak.$now"
|
success backupconfig $r0 "dd if=$opt_remote_etc_bastion/bastion.conf of=$opt_remote_etc_bastion/bastion.conf.bak.$now"
|
||||||
|
@ -543,9 +544,18 @@ runtests()
|
||||||
do
|
do
|
||||||
module="$(readlink -f "$module")"
|
module="$(readlink -f "$module")"
|
||||||
modulename="$(basename "$module" .sh)"
|
modulename="$(basename "$module" .sh)"
|
||||||
if [ -n "$opt_module" ] && [ "$opt_module" != "$(basename "$module")" ]; then
|
if [ -n "$opt_module" ]; then
|
||||||
echo "### SKIPPING MODULE $modulename"
|
skip=1
|
||||||
continue
|
for wantedmod in $opt_module
|
||||||
|
do
|
||||||
|
if [ "$wantedmod" = "$(basename "$module")" ]; then
|
||||||
|
skip=0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$skip" = 1 ]; then
|
||||||
|
echo "### SKIPPING MODULE $modulename"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo "### RUNNING MODULE $modulename"
|
echo "### RUNNING MODULE $modulename"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue