scan and run test_ methods

Bug: N/A
Test: run bootstrap_test.sh
Change-Id: I3f810277763144d4a6a2f9c1d08bed3a29b7598e
This commit is contained in:
Usta Shrestha
2022-12-08 01:29:21 -05:00
parent 4e17a2e503
commit 572ecec696
3 changed files with 24 additions and 49 deletions

View File

@@ -150,3 +150,16 @@ info "Mock top: $MOCK_TOP"
export ALLOW_MISSING_DEPENDENCIES=true
export ALLOW_BP_UNDER_SYMLINKS=true
warmup_mock_top
function scan_and_run_tests {
# find all test_ functions
# NB "declare -F" output is sorted, hence test order is deterministic
readarray -t test_fns < <(declare -F | sed -n -e 's/^declare -f \(test_.*\)$/\1/p')
info "Found ${#test_fns[*]} tests"
if [[ ${#test_fns[*]} -eq 0 ]]; then
fail "No tests found"
fi
for f in ${test_fns[*]}; do
$f
done
}