From de8ef8217740c8c2a08db4e9ad3873c2622eb659 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 24 Jul 2026 15:29:56 +0200 Subject: [PATCH 1/2] test/system: Use long options, instead of their shorter aliases The long options are easier to grep(1) for in the sources than their shorter aliases. Fallout from ecd1ced719742a6faea4d0cf41d68391f5644b4e and 54a2ca1ead343c3db2c7443cc58b9d9e896d3c46 https://github.com/containers/toolbox/pull/1825 --- test/system/libs/helpers.bash | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index a7fc145cf..369ac241d 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -106,7 +106,7 @@ function _pull_and_cache_distro_image() { fi if [ ! -d "${IMAGE_CACHE_DIR}" ]; then - run mkdir -p "${IMAGE_CACHE_DIR}" + run mkdir --parents "${IMAGE_CACHE_DIR}" assert_success fi @@ -153,7 +153,7 @@ function _setup_docker_registry() { # Create certificates for HTTPS # This is needed so that Podman does not have to be configured to work with # HTTP-only registries - run mkdir -p "${DOCKER_REG_CERTS_DIR}" + run mkdir --parents "${DOCKER_REG_CERTS_DIR}" assert_success run openssl req \ -newkey rsa:4096 \ @@ -167,20 +167,20 @@ function _setup_docker_registry() { assert_success # Add certificate to Podman's trusted certificates (rootless) - run mkdir -p "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}" + run mkdir --parents "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}" assert_success run cp "${DOCKER_REG_CERTS_DIR}"/domain.crt "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}"/domain.crt assert_success # Create a registry user # username: user; password: user - run mkdir -p "${DOCKER_REG_AUTH_DIR}" + run mkdir --parents "${DOCKER_REG_AUTH_DIR}" assert_success run htpasswd -Bbc "${DOCKER_REG_AUTH_DIR}"/htpasswd user user assert_success # Create separate Podman root - run mkdir -p "${DOCKER_REG_ROOT}" + run mkdir --parents "${DOCKER_REG_ROOT}" assert_success # Pull Docker registry image From 842227756c554e4d6281a77bd404c5b86475af20 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 24 Jul 2026 16:17:00 +0200 Subject: [PATCH 2/2] test/system: Don't use Bats' 'run' to only check if a command succeeded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bats' 'run' helper is not necessary to merely check if a command succeeded or not [1]. Bats sets Bash's 'set -e' [1,2] to fail and exit immediately if a pipeline, list of commands or compound command returns with a non-zero exit code. Therefore, directly invoking the command without 'run' is enough to stop execution in case of an error. Perhaps more importantly, until Bats 1.14.0 that came out four days ago, 'run --separate-stderr' didn't work inside setup_suite() because BATS_TEST_TMPDIR wasn't defined [3]. Hence, using 'run' in these functions used in setup_suite() exposed them to the possibility that it would be used in ways that don't work. So far, a failure led to: not ok 1 setup_suite # (from function `assert_success' in file test/system/libs/bats-assert/src/assert.bash, line 114, # from function `_pull_and_cache_distro_image' in file test/system/libs/helpers.bash, line 110, # from function `setup_suite' in test file test/system/setup_suite.bash, line 52) # `_pull_and_cache_distro_image fedora 34' failed # # -- command failed -- # status : 1 # output : mkdir: cannot create directory ‘/var/tmp/bats-run-KCijAa/suite/image-cache’: Permission denied # -- # Instead, from now on, it will be: not ok 1 setup_suite # (from function `_pull_and_cache_distro_image' in file test/system/libs/helpers.bash, line 109, # from function `setup_suite' in test file test/system/setup_suite.bash, line 52) # `_pull_and_cache_distro_image fedora 34' failed # mkdir: cannot create directory ‘/var/tmp/bats-run-KCijAa/suite/image-cache’: Permission denied Fallout from 8f6deadaefefa96f60d180a1713fc6afbeced441 and ecd1ced719742a6faea4d0cf41d68391f5644b4e [1] https://bats-core.readthedocs.io/en/stable/writing-tests.html [2] https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html [3] Bats commit 33ffbedd2760e51c https://github.com/bats-core/bats-core/commit/33ffbedd2760e51c https://github.com/bats-core/bats-core/pull/1118 https://github.com/containers/toolbox/pull/1825 --- test/system/libs/helpers.bash | 49 ++++++++++++----------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index 369ac241d..84aab2ad5 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -106,8 +106,7 @@ function _pull_and_cache_distro_image() { fi if [ ! -d "${IMAGE_CACHE_DIR}" ]; then - run mkdir --parents "${IMAGE_CACHE_DIR}" - assert_success + mkdir --parents "${IMAGE_CACHE_DIR}" fi local error_message @@ -153,9 +152,8 @@ function _setup_docker_registry() { # Create certificates for HTTPS # This is needed so that Podman does not have to be configured to work with # HTTP-only registries - run mkdir --parents "${DOCKER_REG_CERTS_DIR}" - assert_success - run openssl req \ + mkdir --parents "${DOCKER_REG_CERTS_DIR}" + openssl req \ -newkey rsa:4096 \ -nodes -sha256 \ -keyout "${DOCKER_REG_CERTS_DIR}"/domain.key \ @@ -164,31 +162,24 @@ function _setup_docker_registry() { -days 365 \ -subj '/' \ -out "${DOCKER_REG_CERTS_DIR}"/domain.crt - assert_success # Add certificate to Podman's trusted certificates (rootless) - run mkdir --parents "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}" - assert_success - run cp "${DOCKER_REG_CERTS_DIR}"/domain.crt "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}"/domain.crt - assert_success + mkdir --parents "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}" + cp "${DOCKER_REG_CERTS_DIR}"/domain.crt "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}"/domain.crt # Create a registry user # username: user; password: user - run mkdir --parents "${DOCKER_REG_AUTH_DIR}" - assert_success - run htpasswd -Bbc "${DOCKER_REG_AUTH_DIR}"/htpasswd user user - assert_success + mkdir --parents "${DOCKER_REG_AUTH_DIR}" + htpasswd -Bbc "${DOCKER_REG_AUTH_DIR}"/htpasswd user user # Create separate Podman root - run mkdir --parents "${DOCKER_REG_ROOT}" - assert_success + mkdir --parents "${DOCKER_REG_ROOT}" # Pull Docker registry image - run podman --root "${DOCKER_REG_ROOT}" pull "${IMAGES[docker-reg]}" - assert_success + podman --root "${DOCKER_REG_ROOT}" pull "${IMAGES[docker-reg]}" # Create a Docker registry - run podman --root "${DOCKER_REG_ROOT}" run \ + podman --root "${DOCKER_REG_ROOT}" run \ --detach \ --env REGISTRY_AUTH=htpasswd \ --env REGISTRY_AUTH_HTPASSWD_PATH="/auth/htpasswd" \ @@ -202,26 +193,18 @@ function _setup_docker_registry() { --volume "${DOCKER_REG_AUTH_DIR}":/auth \ --volume "${DOCKER_REG_CERTS_DIR}":/certs \ "${IMAGES[docker-reg]}" - assert_success _wait_for_docker_registry - run podman login \ - --authfile "${BATS_SUITE_TMPDIR}/authfile.json" \ - --username user \ - --password user \ - "${DOCKER_REG_URI}" - assert_success + podman login --authfile "${BATS_SUITE_TMPDIR}/authfile.json" --username user --password user "${DOCKER_REG_URI}" # Add fedora-toolbox:34 image to the registry - run skopeo --command-timeout 60s copy \ - --dest-authfile "${BATS_SUITE_TMPDIR}/authfile.json" \ - dir:"${IMAGE_CACHE_DIR}"/fedora-toolbox-34 \ - docker://"${DOCKER_REG_URI}"/fedora-toolbox:34 - assert_success + skopeo --command-timeout 60s copy \ + --dest-authfile "${BATS_SUITE_TMPDIR}/authfile.json" \ + dir:"${IMAGE_CACHE_DIR}"/fedora-toolbox-34 \ + docker://"${DOCKER_REG_URI}"/fedora-toolbox:34 - run rm "${BATS_SUITE_TMPDIR}/authfile.json" - assert_success + rm "${BATS_SUITE_TMPDIR}/authfile.json" }