Use finally() function in test suites

Mainly to call stop_all_servald_servers(), which asserts that the server is
still running and responding to orderly shutdown.
This commit is contained in:
Andrew Bettison 2012-10-18 11:46:32 +10:30
parent ed44dfe720
commit 381fc7cad8
3 changed files with 15 additions and 12 deletions

View File

@ -337,6 +337,7 @@ stop_servald_server() {
tfw_log "# ended servald process: pid=$bpid" tfw_log "# ended servald process: pid=$bpid"
fi fi
done done
pop_instance
} }
# Utility function: # Utility function:
@ -349,7 +350,6 @@ report_servald_server() {
tfw_core_backtrace "$servald" "$instance_dir/core" tfw_core_backtrace "$servald" "$instance_dir/core"
rm -f "$instance_dir/core" rm -f "$instance_dir/core"
fi fi
pop_instance
} }
# Utility function: # Utility function:
@ -423,7 +423,7 @@ stop_all_servald_servers() {
# Utility function for tearing down servald fixtures: # Utility function for tearing down servald fixtures:
# - log a report of the execution of all servald server process instances # - log a report of the execution of all servald server process instances
report_all_servald_servers() { report_all_servald_servers() {
foreach_instance_with_pidfile report_servald_server foreach_instance +{A..Z} report_servald_server
} }
# Utility function for tearing down servald fixtures: # Utility function for tearing down servald fixtures:
@ -498,7 +498,7 @@ get_servald_pids() {
assert_no_servald_processes() { assert_no_servald_processes() {
local pids local pids
get_servald_pids pids get_servald_pids pids
assert --message="$servald_basename process(es) running: $pids" [ -z "$pids" ] assert --message="no $servald_basename process(es) running" [ -z "$pids" ]
return 0 return 0
} }

View File

@ -47,10 +47,14 @@ setup() {
executeOk_servald config set debug.all Yes executeOk_servald config set debug.all Yes
} }
teardown() { finally() {
stop_all_servald_servers stop_all_servald_servers
}
teardown() {
kill_all_servald_processes kill_all_servald_processes
assert_no_servald_processes assert_no_servald_processes
report_all_servald_servers
} }
set_server_vars() { set_server_vars() {

View File

@ -24,15 +24,14 @@ source "${0%/*}/../testdefs_rhizome.sh"
shopt -s extglob shopt -s extglob
finally() {
stop_all_servald_servers
}
teardown() { teardown() {
kill_all_servald_processes kill_all_servald_processes
assert_no_servald_processes assert_no_servald_processes
report_all_servald_processes report_all_servald_servers
}
setup_rhizome() {
foreach_instance +A +B create_single_identity
set_instance +B
} }
# Called by start_servald_instances for each instance. # Called by start_servald_instances for each instance.
@ -109,8 +108,9 @@ setup_curl_7() {
setup_common() { setup_common() {
setup_servald setup_servald
setup_rhizome
assert_no_servald_processes assert_no_servald_processes
foreach_instance +A +B create_single_identity
set_instance +B
} }
extract_manifest_vars() { extract_manifest_vars() {
@ -431,7 +431,6 @@ test_FileTransferStress() {
assert_rhizome_list --fromhere=1 file-$i-* --fromhere=0 file-!($i)-* assert_rhizome_list --fromhere=1 file-$i-* --fromhere=0 file-!($i)-*
assert_received file-!($i)-* assert_received file-!($i)-*
done done
assert_status_all_servald_servers running
} }
runTests "$@" runTests "$@"