diff --git a/.gitignore b/.gitignore index 2e88651..406a33b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ ttcn3/out/ ttcn3/make/ ttcn3/.run.sh ttcn3/usr_local +ttcn3/var_local current_log lastlog autolog diff --git a/gen_makefile.py b/gen_makefile.py index d306364..3f6a994 100755 --- a/gen_makefile.py +++ b/gen_makefile.py @@ -364,7 +364,7 @@ def gen_make(proj, deps, configure_opts, jobs, make_dir, src_dir, build_dir, url deps_installed = ' '.join(['.make.%s.install' % d for d in deps]) deps_reinstall = ' '.join(['%s-reinstall' %d for d in deps]) cflags = 'CFLAGS=-g ' if args.build_debug else '' - docker_cmd = f'{args.docker_cmd} ' if args.docker_cmd else '' + docker_cmd = f'OSMODEV_PROJECT={proj} {args.docker_cmd} ' if args.docker_cmd else '' check = 'check' if make_check else '' no_ldconfig = '#' if no_ldconfig else '' sudo_ldconfig = '' if ldconfig_without_sudo else 'sudo ' diff --git a/ttcn3/scripts/docker_configure_make.sh b/ttcn3/scripts/docker_configure_make.sh index 7a79ff1..e6857fd 100755 --- a/ttcn3/scripts/docker_configure_make.sh +++ b/ttcn3/scripts/docker_configure_make.sh @@ -4,16 +4,60 @@ # location inside the docker container. A usr_local dir is mounted to # /usr/local, so 'make install' can put all files there and following builds # have the files available. +# env vars: OSMODEV_PROJECT DIR_OSMODEV="$(readlink -f "$(dirname $0)/../..")" DIR_MAKE="$DIR_OSMODEV/ttcn3/make" DIR_USR_LOCAL="$DIR_OSMODEV/ttcn3/usr_local" +DIR_VAR_LOCAL="$DIR_OSMODEV/ttcn3/var_local" DIR_CCACHE="$DIR_OSMODEV/ttcn3/ccache/osmocom-programs" RUN_SCRIPT="$DIR_OSMODEV/ttcn3/.run.sh" -DOCKER_IMG="$1" UID="$(id -u)" -shift -mkdir -p "$DIR_MAKE" "$DIR_CCACHE" +# Osmocom libraries and programs relevant for the current testsuite will be +# built in this container. It must have all build dependencies available and +# be based on the same distribution that master-* containers are based on, so +# there are no incompatibilities with shared libraries. +DOCKER_IMG_BUILD="debian-bookworm-build" +DOCKER_IMG_BUILD_OGS="open5gs-master" + +docker_image_exists() { + test -n "$(docker images -q "$1")" +} + +build_docker_img() { + local img="$1" + local dp="${DIR_OSMODEV}/src/docker-playground" + + if ! docker_image_exists "$USER/$img"; then + echo "Building docker image: $USER/$img" + make -C "$dp/$img" + fi +} + +build_docker_imgs() { + build_docker_img "$DOCKER_IMG_BUILD" + + if [ "$OSMODEV_PROJECT" = "open5gs" ]; then + build_docker_img "$DOCKER_IMG_BUILD_OGS" + fi +} + +set_docker_img_var() { + case "$OSMODEV_PROJECT" in + open5gs) + DOCKER_IMG="$USER/$DOCKER_IMG_BUILD_OGS" + ;; + *) + DOCKER_IMG="$USER/$DOCKER_IMG_BUILD" + ;; + esac +} + +mkdir -p \ + "$DIR_MAKE" \ + "$DIR_CCACHE" \ + "$DIR_USR_LOCAL" \ + "$DIR_VAR_LOCAL" # Script running as user inside docker echo "#!/bin/sh -ex" > "$RUN_SCRIPT" @@ -24,12 +68,16 @@ done echo >> "$RUN_SCRIPT" chmod +x "$RUN_SCRIPT" +build_docker_imgs +set_docker_img_var + docker run \ --rm \ -t \ -e "LD_LIBRARY_PATH=/usr/local/lib" \ -v "$DIR_OSMODEV:$DIR_OSMODEV" \ -v "$DIR_USR_LOCAL:/usr/local" \ + -v "$DIR_VAR_LOCAL:/var/local" \ -v "$RUN_SCRIPT:/tmp/run.sh:ro" \ -v "$DIR_CCACHE:/home/build/.ccache" \ "$DOCKER_IMG" \ diff --git a/ttcn3/ttcn3.sh b/ttcn3/ttcn3.sh index 3426e7b..5c3fae6 100755 --- a/ttcn3/ttcn3.sh +++ b/ttcn3/ttcn3.sh @@ -5,16 +5,11 @@ DIR_OSMODEV="$(readlink -f "$(dirname $0)/..")" DIR_MAKE="${DIR_MAKE:-${DIR_OSMODEV}/ttcn3/make}" DIR_OUTPUT="${DIR_OUTPUT:-${DIR_OSMODEV}/ttcn3/out}" DIR_USR_LOCAL="$DIR_OSMODEV/ttcn3/usr_local" +DIR_VAR_LOCAL="$DIR_OSMODEV/ttcn3/var_local" JOBS="$(nproc)" KERNEL_DIR="" KERNEL_SKIP_MARKER="$DIR_MAKE/.kernel_built_from_source" ARG_TEST_NAME="" - -# Osmocom libraries and programs relevant for the current testsuite will be -# built in this container. It must have all build dependencies available and -# be based on the same distribution that master-* containers are based on, so -# there are no incompatibilities with shared libraries. -DOCKER_IMG_BUILD="debian-bookworm-build" DOCKER_IMG_TITAN="debian-bookworm-titan" clean() { @@ -29,7 +24,8 @@ clean() { rm -rf \ "$DIR_MAKE" \ "$DIR_OUTPUT" \ - "$DIR_USR_LOCAL" + "$DIR_USR_LOCAL" \ + "$DIR_VAR_LOCAL" if [ -d "$DIR_OSMODEV/src/osmo-ttcn3-hacks" ]; then make -C "$DIR_OSMODEV/src/osmo-ttcn3-hacks" clean @@ -98,6 +94,7 @@ parse_args() { echo " $name -d ggsn" echo " $name -k ggsn" echo " $name -k -f ggsn" + echo " $name ggsn-ogs" exit 1 ;; esac @@ -134,7 +131,7 @@ get_testsuite_dir() { case "$PROJECT" in bsc-*) echo "$hacks/bsc" ;; bts-*) echo "$hacks/bts" ;; - ggsn) echo "$hacks/ggsn_tests" ;; + ggsn|ggsn-ogs) echo "$hacks/ggsn_tests" ;; pcu-sns) echo "$hacks/pcu" ;; *) echo "$hacks/$PROJECT" ;; esac @@ -145,6 +142,7 @@ get_testsuite_config() { bts-gprs) echo "BTS_Tests_GPRS.cfg" ;; bts-oml) echo "BTS_Tests_OML.cfg" ;; pcu-sns) echo "PCU_Tests_SNS.cfg" ;; + ggsn-ogs) echo "GGSN_Tests.cfg" ;; *) echo "$(get_testsuite_name).cfg" ;; esac } @@ -156,6 +154,9 @@ get_testsuite_dir_docker() { bsc-*) echo "$dp/ttcn3-bsc-test-$(echo "$PROJECT" | cut -d - -f 2-)" ;; + ggsn-ogs) + echo "$dp/ttcn3-ggsn-test-ogs" + ;; *) echo "$dp/ttcn3-$PROJECT-test" ;; @@ -167,6 +168,9 @@ get_testsuite_image() { bsc-*) echo "$USER/ttcn3-bsc-test" ;; + ggsn-ogs) + echo "$USER/ttcn3-ggsn-test" + ;; *) echo "$USER/ttcn3-$PROJECT-test" ;; @@ -185,6 +189,7 @@ get_programs() { case "$PROJECT" in bsc|bsc-*) echo "osmo-stp osmo-bsc osmo-bts-omldummy" ;; bts) echo "osmo-bsc osmo-bts-trx" ;; + ggsn-ogs) echo "open5gs" ;; msc) echo "osmo-stp osmo-msc" ;; pcu-sns) echo "osmo-pcu" ;; pcu) echo "osmo-pcu osmo-bsc osmo-bts-virtual" ;; @@ -218,7 +223,6 @@ setup_dir_make() { cd "$DIR_OSMODEV" local docker_cmd="$DIR_OSMODEV/ttcn3/scripts/docker_configure_make.sh" - docker_cmd="$docker_cmd $USER/$DOCKER_IMG_BUILD" ./gen_makefile.py \ default.opts \ @@ -294,17 +298,6 @@ prepare_local_bin() { done } -prepare_docker_build_container() { - local dp="${DIR_OSMODEV}/src/docker-playground" - - if docker_image_exists "$USER/$DOCKER_IMG_BUILD"; then - return - fi - - echo "Building docker image: $USER/$DOCKER_IMG_BUILD" - make -C "$dp/$DOCKER_IMG_BUILD" -} - prepare_docker_testsuite_container() { local testsuite_image="$(get_testsuite_image)" @@ -352,6 +345,12 @@ build_osmo_programs() { set +x for program in $programs; do + if [ "$program" = "open5gs" ]; then + # open5gs binaries have different names (open5gs-mmed, + # etc.) + continue + fi + local repo="$(get_program_repo "$program")" local usr_local_bin="$DIR_USR_LOCAL/bin" @@ -472,6 +471,7 @@ run_docker() { DOCKER_ARGS="\ -e LD_LIBRARY_PATH=/usr/local/lib \ -v "$DIR_USR_LOCAL":/usr/local:ro \ + -v "$DIR_VAR_LOCAL":/var/local:ro \ -v $hacks:/osmo-ttcn3-hacks:ro \ " if [ -n "$ARG_TEST_NAME" ]; then @@ -513,7 +513,6 @@ clone_repo "osmo-ttcn3-hacks" clone_repo "docker-playground" check_dir_testsuite prepare_local_bin -prepare_docker_build_container build_extra_libraries build_osmo_programs build_kernel