From ecee66d03fb3b9126767e83d098057f445dd0fa3 Mon Sep 17 00:00:00 2001 From: Ryo Nakamura Date: Tue, 12 Aug 2025 14:45:10 +0900 Subject: [PATCH] cmake: add custom targets docker-run-${DOCKER_INDEX} --- CMakeLists.txt | 10 ++++++++++ scripts/test-in-container.sh | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fc294e..27fcee2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,16 @@ foreach(x RANGE ${DIST_LISTLEN}) --add-host=ip6-localhost:::1 ${DOCKER_IMAGE} /mscp/scripts/test-in-container.sh) + add_custom_target(docker-run-${DOCKER_INDEX} + COMMENT "Start ${DOCKER_IMAGE} container" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMAND + ${CE} run --init --rm --privileged + --sysctl net.ipv6.conf.all.disable_ipv6=0 + --add-host=ip6-localhost:::1 + -it + ${DOCKER_IMAGE} /mscp/scripts/test-in-container.sh bash) + list(APPEND DOCKER_BUILDS docker-build-${DOCKER_INDEX}) list(APPEND DOCKER_BUILDS_NO_CACHE docker-build-${DOCKER_INDEX}-no-cache) list(APPEND DOCKER_TESTS docker-test-${DOCKER_INDEX}) diff --git a/scripts/test-in-container.sh b/scripts/test-in-container.sh index 67f151e..aaa85f7 100755 --- a/scripts/test-in-container.sh +++ b/scripts/test-in-container.sh @@ -28,5 +28,11 @@ for port in 22 8022; do ssh-keyscan -p $port ::1 >> ${HOME}/.ssh/known_hosts done -# Run test -python3 -m pytest -v ../test + +if [ $# -gt 0 ]; then + # command arguments are passed, exec them + "$@" +else + # no arguments passed, run the test + python3 -m pytest -v ../test +fi