From ef75fd0f01520869fadd99e1d40508189acea5e9 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 4 Jan 2024 23:12:50 -0500 Subject: [PATCH] tests/bcachefs: make check_counters more robust Signed-off-by: Kent Overstreet --- tests/bcachefs/bcachefs-test-libs.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/bcachefs/bcachefs-test-libs.sh b/tests/bcachefs/bcachefs-test-libs.sh index 7c7e130..d4cc4b4 100644 --- a/tests/bcachefs/bcachefs-test-libs.sh +++ b/tests/bcachefs/bcachefs-test-libs.sh @@ -156,6 +156,16 @@ bcachefs_antagonist() #antagonist_switch_str_hash & } +get_slowpath_counters() +{ + local dev=$1 + + bcachefs show-super --field-only counters "$dev"| + grep -E '(fail|restart|blocked|full)'| + grep -vE '(path_relock_fail|mem_realloced)'| + grep -v ' 0$' || true +} + check_counters() { local dev=$1 @@ -163,11 +173,15 @@ check_counters() local ratio=10 local ret=0 + [[ -z $nr_commits ]] && return 0 + [[ $# -ge 2 ]] && ratio=$2 local max_fail=$((nr_commits / ratio)) - local counters=$(bcachefs show-super -f counters "$dev"|grep -E '(fail|restart|blocked)'|grep -v path_relock_fail|grep -v mem_realloced) + local counters=$(set +e; set +o pipefail; get_slowpath_counters $dev) + + [[ -z $counters ]] && return 0 while IFS= read -r line; do linea=($line)