mirror of https://github.com/schoebel/mars
test_suite: use a marker file as only criterion to identify a test directory
This commit is contained in:
parent
506397397e
commit
a6665922b2
|
@ -7,7 +7,7 @@ The test suite is work in progress.
|
|||
|
||||
At the moment it is not in the state to be usable outside of the development
|
||||
team.
|
||||
Event this file is not complete!
|
||||
Even this file is not complete!
|
||||
|
||||
|
||||
=============================================================================
|
||||
|
@ -38,55 +38,71 @@ of one of the both directories build_test_environment and test_cases.
|
|||
The scope and configuration of a test is completely described by this
|
||||
subdirectory (we call it start directory) as follows:
|
||||
|
||||
- All leaf subdirectories of the start directory define one test case.
|
||||
If the test specified by one leaf subdirectory fails the tests belonging to
|
||||
other leaf subdirectories of the start directory will not be executed.
|
||||
- All subdirectories of the start directory containing a (usually empty)
|
||||
file named i_am_a_testdirectory define one test case. In the following
|
||||
we call such a subdirectory a test directory.
|
||||
If a test for one test directory below the start directory fails, the tests
|
||||
belonging to the other test directories of the start directory will not be
|
||||
executed.
|
||||
Though only tests which are likely not to fail should be executed by only
|
||||
one call to start_test.sh. The simple and recommended way is to call
|
||||
start_test.sh for each leaf directory once.
|
||||
- For each leaf subdirectory xyz there exists a configuration file named
|
||||
xyz.conf which contains (among others) in the variables prepare_list,
|
||||
setup_list, run_list, cleanup_list and finish_list names of shell
|
||||
functions defined in scripts/modules/*.sh.
|
||||
These functions are called in the order they appear in the mentioned
|
||||
*list variables.
|
||||
The file xyz.conf may reside in the leaf directory or any of it's parent
|
||||
directories (up to 20 levels higher in the directory tree).
|
||||
- The configuration of the test case belonging to a leaf directory is defined
|
||||
by a set of *.conf files which are included by start_test.sh in the
|
||||
following order:
|
||||
start_test.sh for each test directory once (which means that the
|
||||
start directory consists of only one test directory and coincides with it.
|
||||
|
||||
- The configuration of the test case is defined by a set of *.conf files which
|
||||
are included by start_test.sh in the following order:
|
||||
|
||||
-- default-*.conf: These are the configuration files belonging to the
|
||||
scripts scripts/modules/*.sh which are also included
|
||||
bei start_test.sh and which define all functions executed
|
||||
by the various tests.
|
||||
-- user_modules.conf
|
||||
-- <subdirname>.conf where subdirname runs top down through the parent
|
||||
directories starting with the immediate subdirectory of the start directory
|
||||
(or the immediate subdirectory directory given by option --config_root_dir)
|
||||
to the leaf directory.
|
||||
bei start_test.sh and which define all functions which may
|
||||
be used by the various tests.
|
||||
|
||||
If the start directory is a leaf directory the <leaf directory name>.conf
|
||||
is included.
|
||||
For example:
|
||||
-- user_modules.conf
|
||||
|
||||
-- <subdirname>.conf where subdirname runs top down through the parent
|
||||
directories starting with the first subdirectory of a directory called
|
||||
root config directory to the test directory.
|
||||
This config root directory is set to the start directory (on the directory
|
||||
branch start directory -> test directory) by default. It may be changed by
|
||||
the option --config_root_dir=<my dir>.
|
||||
If the start directory coincides with the test directory the file
|
||||
<test directory name>.conf is included for conveniance (in the strict
|
||||
sense there are no true subdirectories of the start directory residing
|
||||
above the test directory).
|
||||
The <subdirnam>.conf files may reside in the test directory or any of
|
||||
it's parent directories (up to 20 levels).
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
1. start directory = test_cases/perf
|
||||
leaf directory = test_cases/perf/apply/no_parallel_writer
|
||||
test directory = test_cases/perf/apply/no_parallel_writer
|
||||
Option --config_root_dir not given
|
||||
|
||||
leads to including of apply.conf and no_parallel_writer.conf (in
|
||||
this order!) which must reside as mentioned above in the leaf
|
||||
directory or any of it's parent directories (up to 20 levels).
|
||||
|
||||
2. start directory = test_cases/perf/apply/no_parallel_writer
|
||||
--config_root_dir=.../test_cases/perf
|
||||
leaf directory = test_cases/perf/apply/no_parallel_writer
|
||||
Option --config_root_dir=test_cases/perf
|
||||
|
||||
leads to including the same *.conf files as above.
|
||||
|
||||
3. start directory = test_cases/perf/apply/no_parallel_writer
|
||||
leaf directory = test_cases/perf/apply/no_parallel_writer
|
||||
Option --config_root_dir given or not
|
||||
|
||||
leads to including of no_parallel_writer.conf
|
||||
|
||||
- In one of the included <subdirnam>.conf files of a test one of the variables
|
||||
prepare_list, setup_list, run_list, cleanup_list or finish_list must be set.
|
||||
Each of these variables may be empty or contain a list of shell function
|
||||
names of functions defined in scripts/modules/*.sh.
|
||||
These functions are called by start_test.sh in the order they appear in the
|
||||
mentioned *list variables. The *list variables are evaluated in the order
|
||||
prepare_list, setup_list, run_list, cleanup_list, finish_list.
|
||||
|
||||
1.1. Test output
|
||||
----------------
|
||||
|
||||
|
|
|
@ -19,49 +19,7 @@
|
|||
|
||||
#####################################################################
|
||||
|
||||
# wrapper for the exit builtin to be able to remove temporary files
|
||||
function start_test_exit
|
||||
{
|
||||
rm -f $environ_save
|
||||
exit $1
|
||||
}
|
||||
|
||||
shopt -s extdebug
|
||||
|
||||
# Use directory names as basis for configuration variants
|
||||
|
||||
script_dir="$(cd "$(dirname "$(which "$0")")"; pwd)"
|
||||
lib_dir=$script_dir/modules
|
||||
echo "================= Sourcing libraries in $lib_dir ==============================="
|
||||
for lib in $lib_dir/lib*.sh; do
|
||||
echo "Sourcing $lib"
|
||||
source "$lib" || start_test_exit $?
|
||||
done
|
||||
echo "================= End sourcing libraries ======================================="
|
||||
|
||||
to_produce="${to_produce:-replay.gz}"
|
||||
to_check="${to_check:-}"
|
||||
to_start="${to_start:-main}"
|
||||
|
||||
dry_run_script=0
|
||||
start_dir=$(pwd)
|
||||
# all directories between config_root_dir and the actual test directory will be
|
||||
# considered as "configuration options". That means that a <dirname>.conf file must
|
||||
# be provided for all these directories
|
||||
config_root_dir=$start_dir
|
||||
verbose_script=1
|
||||
|
||||
# check some preconditions
|
||||
|
||||
check_list="grep sed gawk head tail cut nice date gzip gunzip zcat buffer"
|
||||
check_installed "$check_list"
|
||||
|
||||
# include modules
|
||||
prepare_list=""
|
||||
setup_list=""
|
||||
run_list=""
|
||||
cleanup_list=""
|
||||
finish_list=""
|
||||
## For a general documentation please refer to README, section "Running a test"
|
||||
|
||||
function set_host_locks
|
||||
{
|
||||
|
@ -143,37 +101,42 @@ function print_config_environment
|
|||
|
||||
}
|
||||
|
||||
function usage
|
||||
{
|
||||
echo "usage: $(basename $0) [--dry-run] [--config_root_dir=<my_dir>]" >&2
|
||||
echo " Option --dry-run:" >&2
|
||||
echo " Print all configuration variables and the name " >&2
|
||||
echo " of the test. Don't execute it." >&2
|
||||
echo " Option --config_root_dir:" >&2
|
||||
echo " Include all *.conf files belonging to subdirectories " >&2
|
||||
echo " between my_dir and test directory." >&2
|
||||
echo " Default: my_dir = working directory" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
save_environment # for later use in print_config_environment
|
||||
|
||||
shopt -s nullglob
|
||||
echo "================= Sourcing modules and default configuration ==================="
|
||||
for module in $module_dir/[0-9]*.sh; do
|
||||
source_module "$module"
|
||||
done
|
||||
echo "================= End sourcing modules and default configuration ==============="
|
||||
dry_run_script=0
|
||||
start_dir=$(pwd)
|
||||
# all directories between config_root_dir and the actual test directory will be
|
||||
# considered as "configuration options". That means that a <dirname>.conf file
|
||||
# must be provided for all these directories
|
||||
config_root_dir=$start_dir
|
||||
verbose_script=1
|
||||
|
||||
# parse options.
|
||||
while [ $# -ge 1 ]; do
|
||||
key="$(echo "$1" | cut -d= -f1)"
|
||||
val="$(echo "$1" | cut -d= -f2-)"
|
||||
case "$key" in
|
||||
--test | --dry-run)
|
||||
dry_run_script="$val"
|
||||
shift
|
||||
;;
|
||||
--override)
|
||||
shift
|
||||
echo "=> Overriding $1"
|
||||
eval $1
|
||||
shift
|
||||
;;
|
||||
--dry-run)
|
||||
dry_run_script="$val"
|
||||
shift
|
||||
;;
|
||||
--config_root_dir)
|
||||
config_root_dir="$val"
|
||||
shift
|
||||
;;
|
||||
config_root_dir="$val"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
@ -185,36 +148,56 @@ else
|
|||
config_root_dir=$(pwd) # we need the absolute path
|
||||
cd $start_dir
|
||||
fi
|
||||
ignore_cmd="grep -v '[/.]old' | grep -v 'ignore'"
|
||||
sort_cmd="while read i; do if [ -e \"\$i\"/prio-[0-9]* ]; then echo \"\$(cd \$i; ls prio-[0-9]*):\$i\"; else echo \"z:\$i\"; fi; done | sort | sed 's/^[^:]*://'"
|
||||
|
||||
# wrapper for the exit builtin to be able to remove temporary files
|
||||
function start_test_exit
|
||||
{
|
||||
rm -f $environ_save
|
||||
exit $1
|
||||
}
|
||||
|
||||
shopt -s extdebug
|
||||
|
||||
# Use directory names as basis for configuration variants
|
||||
|
||||
script_dir="$(cd "$(dirname "$(which "$0")")"; pwd)"
|
||||
lib_dir=$script_dir/modules
|
||||
echo "================= Sourcing libraries in $lib_dir ==============================="
|
||||
for lib in $lib_dir/lib*.sh; do
|
||||
echo "Sourcing $lib"
|
||||
source "$lib" || start_test_exit $?
|
||||
done
|
||||
echo "================= End sourcing libraries ======================================="
|
||||
|
||||
to_start="${to_start:-main}"
|
||||
marker_file="i_am_a_testdirectory"
|
||||
|
||||
# check some preconditions
|
||||
|
||||
check_list="grep sed gawk head tail cut nice date gzip gunzip zcat buffer"
|
||||
check_installed "$check_list"
|
||||
|
||||
# include modules
|
||||
prepare_list=""
|
||||
setup_list=""
|
||||
run_list=""
|
||||
cleanup_list=""
|
||||
finish_list=""
|
||||
|
||||
save_environment # for later use in print_config_environment
|
||||
|
||||
shopt -s nullglob
|
||||
echo "================= Sourcing modules and default configuration ==================="
|
||||
for module in $module_dir/[0-9]*.sh; do
|
||||
source_module "$module"
|
||||
done
|
||||
echo "================= End sourcing modules and default configuration ==============="
|
||||
|
||||
# find directories
|
||||
echo "================= Scanning subdirectories of $start_dir ========================"
|
||||
for test_dir in $(find . -type d | eval "$ignore_cmd" | eval "$sort_cmd"); do
|
||||
(( dry_run_script )) || rm -f $test_dir/dry-run.$to_produce
|
||||
if [ -e "$test_dir/skip" ]; then
|
||||
echo "Skipping directory $test_dir"
|
||||
continue
|
||||
fi
|
||||
if [ $(find $test_dir -type d | eval "$ignore_cmd" | wc -l) -gt 1 ]; then
|
||||
echo "Ignoring inner directory $test_dir"
|
||||
continue
|
||||
fi
|
||||
for marker in $(find . -type f -name "$marker_file"); do
|
||||
test_dir=$(dirname $marker)
|
||||
shopt -u nullglob
|
||||
if ls $test_dir/*.$to_produce > /dev/null 2>&1; then
|
||||
echo "Already finished $test_dir"
|
||||
continue
|
||||
fi
|
||||
if [ -n "$to_check" ] && ! ls $test_dir/*.$to_check > /dev/null 2>&1; then
|
||||
echo "No *.$to_check files exist in $test_dir"
|
||||
continue
|
||||
fi
|
||||
echo ""
|
||||
if [ -e "$test_dir/stop" ] || [ -e "./stop" ]; then
|
||||
echo "would start $test_dir"
|
||||
echo "echo stopping due to stop file."
|
||||
break
|
||||
fi
|
||||
(
|
||||
cd $test_dir
|
||||
echo "================= Test directory $(pwd) $date =================================="
|
||||
|
@ -251,8 +234,8 @@ for test_dir in $(find . -type d | eval "$ignore_cmd" | eval "$sort_cmd"); do
|
|||
shopt -u nullglob
|
||||
|
||||
if (( dry_run_script )); then
|
||||
echo "==> Dry Run ..."
|
||||
touch dry-run.$to_produce
|
||||
echo "would start $(pwd)"
|
||||
exit 0
|
||||
else
|
||||
set_host_locks
|
||||
echo "================= Starting $(pwd) $(date) ======================================"
|
||||
|
@ -271,10 +254,5 @@ for test_dir in $(find . -type d | eval "$ignore_cmd" | eval "$sort_cmd"); do
|
|||
[ $rc -ne 0 ] && start_test_exit $rc
|
||||
done
|
||||
|
||||
if (( dry_run_script )); then
|
||||
echo "removing dry-run.$to_produce everywhere..."
|
||||
rm -f $(find . -name "dry-run.$to_produce")
|
||||
fi
|
||||
|
||||
echo "========================== Finished start directory $start_dir ================="
|
||||
start_test_exit 0
|
||||
|
|
Loading…
Reference in New Issue