12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #!/bin/bash
-
- . "$TF_DIR/include/common.sh"
-
- tf_enum_subtests() {
- #
- # Stub: enumerate subtests
- #
- tf_warn "implement tf_enum_subtests()!"
- return $TF_ES_ERROR
- }
-
- tf_name2cmd() {
- #
- # Stub: expand test name to test command
- #
- tf_warn "implement tf_name2cmd()!"
- return $TF_ES_ERROR
- }
-
- tf_do_subtest() {
- #
- # Run single subtest inc. setup/cleanup if present
- #
- local subtname="$1" # this subtest name
- local ses=0 # subtest exit status
- local tcmd="" # test command
- local setup=true # setup command
- local cleanup=true # cleanup command
- test -f TF_SETUP && setup=". TF_SETUP"
- test -f TF_CLEANUP && cleanup=". TF_CLEANUP"
- if $setup;
- then
- tcmd="$(tf_name2cmd "$subtname")"
- tf_debug "tcmd='$tcmd'"
- $tcmd; ses=$?
- else
- tf_warn "setup phase failed, skipping: $subtname"
- ses=$TF_ES_ERROR
- fi
- if ! $cleanup;
- then
- tf_warn "cleanup phase failed: $subtname"
- ses=$TF_ES_PANIC
- fi
- return $ses
- }
-
- tf_do_subtests() {
- #
- # Run all subtests and return highest status
- #
- local es=0 # final exit status ("worst" of subtests)
- local subtname="" # one subtest name
- local tes="" # one subtest exit status
- local enumd=TF_ENUMERATED_SUBTESTS
- local fltrd=TF_FILTERED_SUBTESTS
- tf_enum_subtests >$enumd || { tf_warn "error enumerating subtests"; return $TF_ES_BAILOUT; }
- test -s $enumd || { tf_warn "no subtests enumerated"; return $TF_ES_BAILOUT; }
- grep -e "$TF_FILTER_SUBTEST" $enumd > $fltrd
- test -s $fltrd || tf_debug "TF_FILTER_SUBTEST ate everything: $TF_FILTER_SUBTEST"
- for subtname in $(<$fltrd);
- do
- export TF_SUBTNAME=$subtname
- tf_think "::: $TF_TNAME::$TF_SUBTNAME"
- tf_do_subtest "$TF_SUBTNAME";
- tes=$?
- test $tes -gt $es && es=$tes
- test $tes -gt $TF_ES_OK && tf_warn "!!! $TF_TNAME::$TF_SUBTNAME ($tes)"
- test $tes -gt $TF_ES_BAILOUT && break
- done
- return $es
- }
|