From 6a596d2b46fd375b7984d9db315b6ccf7059f9f5 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 8 Jul 2025 22:33:28 -0700 Subject: [PATCH] tests: run all py tests with cgroupfs and systemd Many python tests do not run with systemd, and it makes sense to do so. Signed-off-by: Kir Kolyshkin --- tests/run_all_tests.sh | 16 +++++++++++++--- tests/tests_utils.py | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/run_all_tests.sh b/tests/run_all_tests.sh index e869470653..7864d6d1db 100755 --- a/tests/run_all_tests.sh +++ b/tests/run_all_tests.sh @@ -13,9 +13,19 @@ if [ -t 1 ]; then COLOR="yes" fi -for i in test_*.py -do - ./tap-driver.sh --test-name "$i" --log-file "$i.log" --trs-file "$i.trs" --color-tests "${COLOR}" --enable-hard-errors yes --expect-failure no -- /usr/bin/python "$i" +managers="cgroupfs" +if grep -q systemd /proc/1/comm && $OCI_RUNTIME --version | grep -qF +SYSTEMD; then + managers="$managers systemd" +fi + +for cm in cgroupfs systemd; do + export CGROUP_MANAGER=$cm + echo "#" + echo "# CGROUP_MANAGER=$cm" + echo "#" + for i in test_*.py; do + ./tap-driver.sh --test-name "$i" --log-file "${i}_${cm}.log" --trs-file "${i}_${cm}.trs" --color-tests "${COLOR}" --enable-hard-errors yes --expect-failure no -- /usr/bin/python "$i" + done done if grep FAIL -- *.trs; then diff --git a/tests/tests_utils.py b/tests/tests_utils.py index 6aec2aaccf..b6df247e2e 100755 --- a/tests/tests_utils.py +++ b/tests/tests_utils.py @@ -223,7 +223,7 @@ def get_crun_path(): def run_and_get_output(config, detach=False, preserve_fds=None, pid_file=None, keep=False, - command='run', env=None, use_popen=False, hide_stderr=False, cgroup_manager='cgroupfs', + command='run', env=None, use_popen=False, hide_stderr=False, cgroup_manager=None, all_dev_null=False, id_container=None, relative_config_path="config.json", chown_rootfs_to=None, callback_prepare_rootfs=None, debug_on_error=None): @@ -287,6 +287,8 @@ def run_and_get_output(config, detach=False, preserve_fds=None, pid_file=None, relative_config_path = ['--config', relative_config_path] if relative_config_path else [] root = get_tests_root_status() + if cgroup_manager is None: + cgroup_manager = os.environ.get('CGROUP_MANAGER', 'cgroupfs') args = [crun, "--cgroup-manager", cgroup_manager, "--root", root, command] + relative_config_path + preserve_fds_arg + detach_arg + keep_arg + pid_file_arg + [id_container] stderr = subprocess.STDOUT