From 0de3e3b521ce127d30cd1e00723e08e76ec7ff61 Mon Sep 17 00:00:00 2001 From: Esko Dijk Date: Fri, 13 Sep 2024 12:29:03 +0200 Subject: [PATCH] [script] Bugfix: enable 'test' script to properly build and test for a custom OT node pointed to from OT_DIR. This is required for OpenThread CI. --- .github/workflows/develop.yml | 13 ++++++++----- ot-rfsim/script/build | 4 ++++ ot-rfsim/script/build_br | 2 +- ot-rfsim/script/build_latest | 2 +- script/common.sh | 7 ++++++- script/test | 4 ++-- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index afd4f1ec..51b9454b 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -60,8 +60,11 @@ jobs: run: | docker build -t otns-env -f etc/docker/environment/Dockerfile . docker run -t -v$PWD:/otns otns-env -c "./script/pack-web" - if ! git diff --quiet; then - echo "script/pack-web was not properly executed:" - git diff - exit 1 - fi + git diff --quiet + - name: Build custom OT node + # Note: OT_CMAKE_NINJA_TARGET excludes tests because test_platform.cpp is missing otPlatAssertFail() + run: | + ./script/install-deps + ./script/setup-dev + cd ot-rfsim + OT_CMAKE_NINJA_TARGET="ot-cli-ftd ot-cli-mtd" ./script/build diff --git a/ot-rfsim/script/build b/ot-rfsim/script/build index c5f30be5..dfaaf119 100755 --- a/ot-rfsim/script/build +++ b/ot-rfsim/script/build @@ -29,8 +29,12 @@ set -euxo pipefail +# shellcheck source=../script/utils.sh +. "$(dirname "$0")"/../../script/utils.sh + OTRFSIM_SRCDIR="$(pwd)" OT_DIR=${OT_DIR:-../openthread} +OT_DIR=$(realpathf "${OT_DIR}") OT_CMAKE_NINJA_TARGET=${OT_CMAKE_NINJA_TARGET-} readonly OTRFSIM_SRCDIR readonly OT_DIR diff --git a/ot-rfsim/script/build_br b/ot-rfsim/script/build_br index edae9453..3d978da1 100755 --- a/ot-rfsim/script/build_br +++ b/ot-rfsim/script/build_br @@ -61,7 +61,7 @@ main() local options=() options+=("${OTBR_OPTIONS[@]}" "$@") - OT_DIR="../openthread" OTNS_NODE_TYPE="br" OT_CMAKE_NINJA_TARGET="ot-cli-ftd" ./script/build "${options[@]}" + OTNS_NODE_TYPE="br" OT_CMAKE_NINJA_TARGET="ot-cli-ftd" ./script/build "${options[@]}" cp ./build/br/bin/ot-cli-ftd ./ot-versions/ot-cli-ftd_br } diff --git a/ot-rfsim/script/build_latest b/ot-rfsim/script/build_latest index 1592bf91..0e15040c 100755 --- a/ot-rfsim/script/build_latest +++ b/ot-rfsim/script/build_latest @@ -57,7 +57,7 @@ main() local options=() options+=("${OT_OPTIONS[@]}" "$@") - OT_DIR="../openthread" OTNS_NODE_TYPE="latest" OT_CMAKE_NINJA_TARGET="ot-cli-ftd ot-cli-mtd" ./script/build "${options[@]}" + OTNS_NODE_TYPE="latest" OT_CMAKE_NINJA_TARGET="ot-cli-ftd ot-cli-mtd" ./script/build "${options[@]}" cp ./build/latest/bin/ot-cli-ftd ./ot-versions/ cp ./build/latest/bin/ot-cli-mtd ./ot-versions/ diff --git a/script/common.sh b/script/common.sh index 34c92b70..8de8362e 100644 --- a/script/common.sh +++ b/script/common.sh @@ -43,9 +43,13 @@ fi SCRIPTDIR=$(realpathf "$(dirname "$0")") export readonly SCRIPTDIR -OTNSDIR=$(realpathf "$SCRIPTDIR"/..) +OTNSDIR=$(realpathf "${SCRIPTDIR}"/..) export readonly OTNSDIR +OT_DIR=${OT_DIR:-./openthread} +OT_DIR=$(realpathf "${OT_DIR}") +export readonly OT_DIR + GOPATH=$(go env GOPATH) export readonly GOPATH export PATH=$PATH:"$GOPATH"/bin @@ -117,6 +121,7 @@ build_openthread_br() ) } +# Note: any environment var OT_DIR is not used for legacy node version (1.1, 1.2, 1.3) builds. build_openthread_versions() { get_openthread_versions diff --git a/script/test b/script/test index bd436855..6707ca4d 100755 --- a/script/test +++ b/script/test @@ -131,8 +131,8 @@ py_examples() install_deps activate_python_venv install_otns - build_openthread_br build_openthread + build_openthread_br check_py_example "$OTNSDIR"/pylibs/examples/simple.py check_py_example "$OTNSDIR"/pylibs/examples/form_partition.py @@ -151,8 +151,8 @@ stress_tests() install_deps activate_python_venv install_otns - build_openthread_br build_openthread + build_openthread_br python3 "$OTNSDIR"/pylibs/stress_tests/run_stress_suite.py "$@" }