From 8f6e47a19158f6ba835fb0a20ba69321ac1ff811 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Thu, 21 Sep 2023 19:00:16 +0200 Subject: [PATCH] test/system: Avoid future problems caused by Bat's 'run' overwriting 'i' Until Bats 1.10.0, 'run' with options had a bug where it would overwrite the value of the 'i' variable even outside 'run' [1]. In these particular instances, no options are being passed to 'run', and, hence, currently there's no problem. However, in case a future commit adds an option, then it could lead to hard-to-debug problems. eg., --separate-stderr sets 'i' to 1, --show-output-of-passing-tests sets it to 2, etc.. Therefore, depending on the flag and the loop, the loop might get terminated prematurely or run infinitely or something else. Moreover, Bats 1.10.0 is only available in Fedora >= 39 and is absent from Fedoras 37 and 38. Therefore, it's not possible to consider this bug fixed. Hence, it's better to preemptively work around it to avoid any future issues. [1] Bats commit 502dc47dd063c187 https://github.com/bats-core/bats-core/commit/502dc47dd063c187 https://github.com/bats-core/bats-core/issues/726 https://github.com/containers/toolbox/pull/1373 --- test/system/libs/helpers.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index 84e39c7..3d77385 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -107,7 +107,7 @@ function _pull_and_cache_distro_image() { assert_success fi - for ((i = 0; i < num_of_retries; i++)); do + for ((j = 0; j < num_of_retries; j++)); do run "$SKOPEO" copy --dest-compress "docker://${image}" "dir:${IMAGE_CACHE_DIR}/${image_archive}" if [ "$status" -eq 0 ]; then @@ -441,7 +441,7 @@ function container_started() { local num_of_retries=5 - for ((i = 0; i < num_of_retries; i++)); do + for ((j = 0; j < num_of_retries; j++)); do run "$PODMAN" logs "$container_name" # Look for last line of the container startup log