From b437ed3063150c721eb1d3c5e4d8d46b083c7ed7 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 13 Aug 2024 17:33:14 -0700 Subject: [PATCH] tests/int: check_{systemd,cgroup}_value: better log 1. Rename current -> got, expected -> want. 2. check_cgroup_value: add file name to output. 3. Improve functions description. This is mostly to simplify debugging test failures. Example output before: current 500000 !? 500 After: cpu.max.burst: got 500000, want 500 Signed-off-by: Kir Kolyshkin --- tests/integration/helpers.bash | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index 40637bca6..b32652dc2 100755 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -260,29 +260,29 @@ function get_cgroup_value() { cat "$cgroup/$1" } -# Helper to check a if value in a cgroup file matches the expected one. +# Check if a value in a cgroup file $1 matches $2. function check_cgroup_value() { - local current - current="$(get_cgroup_value "$1")" - local expected=$2 + local got + got="$(get_cgroup_value "$1")" + local want=$2 - echo "current $current !? $expected" - [ "$current" = "$expected" ] + echo "$1: got $got, want $want" + [ "$got" = "$want" ] } -# Helper to check a value in systemd. +# Check if a value of systemd unit property $1 matches $2 or $3 (if specified). function check_systemd_value() { [ ! -v RUNC_USE_SYSTEMD ] && return local source="$1" [ "$source" = "unsupported" ] && return - local expected="$2" - local expected2="${3:-}" + local want="$2" + local want2="${3:-}" local user="" [ $EUID -ne 0 ] && user="--user" - current=$(systemctl show $user --property "$source" "$SD_UNIT_NAME" | awk -F= '{print $2}') - echo "systemd $source: current $current !? $expected $expected2" - [ "$current" = "$expected" ] || [[ -n "$expected2" && "$current" = "$expected2" ]] + got=$(systemctl show $user --property "$source" "$SD_UNIT_NAME" | awk -F= '{print $2}') + echo "systemd $source: got $got, want $want $want2" + [ "$got" = "$want" ] || [[ -n "$want2" && "$got" = "$want2" ]] } function check_cpu_quota() {