From 755b1016eeabe9977547d08946a612dde6c47bac Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Sat, 30 May 2020 14:44:16 -0700 Subject: [PATCH] test/int/update: simplify mem+swap presence check For v2, mem+swap is always present. For v1, check it once and set a variable which is used below. This also removes CGROUP_MEMORY for v2 case since it's no longer used. Signed-off-by: Kir Kolyshkin --- tests/integration/update.bats | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/integration/update.bats b/tests/integration/update.bats index 4dd8d17e..08736e42 100644 --- a/tests/integration/update.bats +++ b/tests/integration/update.bats @@ -69,6 +69,10 @@ EOF MEM_SWAP="memory.memsw.limit_in_bytes" SD_MEM_SWAP="unsupported" SYSTEM_MEM=$(cat "${CGROUP_MEMORY_BASE_PATH}/${MEM_LIMIT}") + HAVE_SWAP="no" + if [ -f "${CGROUP_MEMORY_BASE_PATH}/${MEM_SWAP}" ]; then + HAVE_SWAP="yes" + fi ;; yes) MEM_LIMIT="memory.max" @@ -78,7 +82,7 @@ EOF MEM_SWAP="memory.swap.max" SD_MEM_SWAP="MemorySwapMax" SYSTEM_MEM="max" - CGROUP_MEMORY=$CGROUP_PATH + HAVE_SWAP="yes" ;; esac SD_UNLIMITED="infinity" @@ -124,7 +128,7 @@ EOF check_systemd_value "$SD_MEM_RESERVE" 33554432 # Run swap memory tests if swap is available - if [ -f "$CGROUP_MEMORY/$MEM_SWAP" ]; then + if [ "$HAVE_SWAP" = "yes" ]; then # try to remove memory swap limit runc update test_update --memory-swap -1 [ "$status" -eq 0 ] @@ -156,7 +160,7 @@ EOF check_systemd_value $SD_MEM_LIMIT $SD_UNLIMITED # check swap memory limited is gone - if [ -f "$CGROUP_MEMORY/$MEM_SWAP" ]; then + if [ "$HAVE_SWAP" = "yes" ]; then check_cgroup_value $MEM_SWAP $SYSTEM_MEM check_systemd_value "$SD_MEM_SWAP" $SD_UNLIMITED fi