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 <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2024-08-13 17:33:14 -07:00
parent 6602681d52
commit b437ed3063
+12 -12
View File
@@ -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() {