cri-o: Add CONTAINER_DEFAULT_RUNTIME to run-ptest

CRI-O version 1.31 and later defaults to crun instead of runc.
This change cause ptests to fail if crun is not installed on the
target system, as the test runner verifies the runtime's availability
using 'command -v "$CONTAINER_DEFAULT_RUNTIME"'.

Additionally, CRI-O specifies the runtime via the
VIRTUAL-RUNTIME_container_runtime variable as a dependency.

This commit explicitly sets the CONTAINER_DEFAULT_RUNTIME environment
variable within the run-ptest script, based on the value of
VIRTUAL-RUNTIME_container_runtime. This ensures ptests execute with
the expected container runtime.

Signed-off-by: Zhang Peng <peng.zhang1.cn@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Zhang Peng 2025-03-11 14:56:59 +08:00 committed by Bruce Ashfield
parent 18630a89a2
commit c949c06f0b

View File

@ -117,6 +117,16 @@ do_install_ptest() {
install -d ${D}${PTEST_PATH}/bin
cp -rf ${S}/src/import/test ${D}${PTEST_PATH}
cp -rf ${S}/src/import/bin ${D}${PTEST_PATH}
# CRI-O testing changed the default container runtime from runc to crun in version 1.31+.
# To maintain compatibility with older tests expecting runc, and to allow for other custom runtimes,
# this section explicitly sets CONTAINER_DEFAULT_RUNTIME in the run-ptest script.
# The value is determined by the VIRTUAL-RUNTIME_container_runtime variable.
if [ "${VIRTUAL-RUNTIME_container_runtime}" = "virtual-runc" ]; then
sed -i '/^.\/test\/test_runner/iexport CONTAINER_DEFAULT_RUNTIME=runc' ${D}${PTEST_PATH}/run-ptest
else
sed -i '/^.\/test\/test_runner/iexport CONTAINER_DEFAULT_RUNTIME=${VIRTUAL-RUNTIME_container_runtime}' ${D}${PTEST_PATH}/run-ptest
fi
}
FILES:${PN}-config = "${sysconfdir}/crio/config/*"