add 'info' mode for integration tests (#318)
Motivation: Sometimes it's useful if the integration tests can output something that isn't always useful. `-v` for verbose is way too verbose so this adds a `-i` flag to the integration tests that lets 'info' messages through. Modifications: - add `-i` flags to integration tests - make use of it in the integration counter tests Result: if we enable `-i` in CI, then we can constantly monitor the number of allocations we do even if we don't fail the tests.
This commit is contained in:
parent
acfb5f7136
commit
4e4890d990
|
@ -22,6 +22,7 @@ set -o pipefail
|
|||
test="$1"
|
||||
tmp="$2"
|
||||
root="$3"
|
||||
g_show_info="$4"
|
||||
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$here/test_functions.sh"
|
||||
|
|
|
@ -61,7 +61,8 @@ shift $plugin_opts_ind
|
|||
|
||||
filter="."
|
||||
verbose=false
|
||||
while getopts "f:v" opt; do
|
||||
show_info=false
|
||||
while getopts "f:vi" opt; do
|
||||
case $opt in
|
||||
f)
|
||||
filter="$OPTARG"
|
||||
|
@ -69,6 +70,9 @@ while getopts "f:v" opt; do
|
|||
v)
|
||||
verbose=true
|
||||
;;
|
||||
i)
|
||||
show_info=true
|
||||
;;
|
||||
\?)
|
||||
usage
|
||||
exit 1
|
||||
|
@ -104,7 +108,7 @@ for f in tests_*; do
|
|||
test_tmp=$(mktemp -d "$tmp/test.tmp_XXXXXX")
|
||||
plugins_do test_begin "$t" "$f"
|
||||
start=$(date +%s)
|
||||
if run_test "$here/run-single-test.sh" "$here/$f/$t" "$test_tmp" "$here/.."; then
|
||||
if run_test "$here/run-single-test.sh" "$here/$f/$t" "$test_tmp" "$here/.." "$show_info"; then
|
||||
plugins_do test_ok "$(time_diff_to_now $start)"
|
||||
suite_ok=$((suite_ok+1))
|
||||
if $verbose; then
|
||||
|
|
|
@ -61,6 +61,18 @@ function assert_greater_than_or_equal() {
|
|||
fi
|
||||
}
|
||||
|
||||
g_has_previously_infoed=false
|
||||
|
||||
function info() {
|
||||
if $g_show_info; then
|
||||
if ! $g_has_previously_infoed; then
|
||||
echo >&3 || true # echo an extra newline so it looks better
|
||||
g_has_previously_infoed=true
|
||||
fi
|
||||
echo >&3 "info: $*" || true
|
||||
fi
|
||||
}
|
||||
|
||||
function warn() {
|
||||
echo >&4 "warning: $*"
|
||||
}
|
||||
|
|
|
@ -64,6 +64,9 @@ for test in 1000_reqs_1_conn 1_reqs_1000_conn; do
|
|||
not_freed_allocations=$(grep "^$test.remaining_allocations:" "$tmp/output" | cut -d: -f2 | sed 's/ //g')
|
||||
max_allowed_env_name="MAX_ALLOCS_ALLOWED_$test"
|
||||
|
||||
info "$test: allocations not freed: $not_freed_allocations"
|
||||
info "$test: total number of mallocs: $total_allocations"
|
||||
|
||||
assert_less_than "$not_freed_allocations" 5 # allow some slack
|
||||
assert_greater_than "$not_freed_allocations" -5 # allow some slack
|
||||
assert_greater_than "$total_allocations" 1000
|
||||
|
|
Loading…
Reference in New Issue