[toranj] add --log-level option to build.sh (#11840)

This change introduces a `--log-level` option to the `build.sh`
script, allowing the `OPENTHREAD_CONFIG_LOG_LEVEL` to be specified at
build time.

The supported log levels are `NONE`, `CRIT`, `WARN`, `NOTE`, `INFO`,
and `DEBG`. The default level is set to `INFO`.

The CI workflow is updated to test builds with all the supported log
levels.
This commit is contained in:
Abtin Keshavarzian
2025-08-22 14:30:39 -07:00
committed by GitHub
parent b6f1252bd8
commit 46e3c15cd7
3 changed files with 48 additions and 2 deletions
+16
View File
@@ -152,6 +152,7 @@ jobs:
run: |
./tests/toranj/build.sh all
ninja test
#- - - - - - - - - - - - - - - - - - - - - - - - - - -
# Validate posix builds with different radio configs
git clean -dfx
./tests/toranj/build.sh ncp-15.4
@@ -165,6 +166,21 @@ jobs:
./tests/toranj/build.sh posix-15.4+trel
git clean -dfx
./tests/toranj/build.sh posix-trel
#- - - - - - - - - - - - - - - - - - - - - - - - - - -
# Log levels
git clean -dfx
./tests/toranj/build.sh --log-level DEBG all
git clean -dfx
./tests/toranj/build.sh --log-level INFO all
git clean -dfx
./tests/toranj/build.sh --log-level NOTE all
git clean -dfx
./tests/toranj/build.sh --log-level WARN all
git clean -dfx
./tests/toranj/build.sh --log-level CRIT all
git clean -dfx
./tests/toranj/build.sh --log-level NONE all
#- - - - - - - - - - - - - - - - - - - - - - - - - - -
git clean -dfx
./tests/toranj/build.sh --enable-plat-key-ref all
+32
View File
@@ -52,6 +52,7 @@ display_usage()
echo "Options:"
echo " -c/--enable-coverage Enable code coverage"
echo " -k/--enable-plat-key-ref Enable OT_PLATFORM_KEY_REF"
echo " -l/--log-level Set specific log level (NONE, CRIT, WARN, NOTE, INFO, DEBG)"
echo ""
}
@@ -66,6 +67,7 @@ cd ../.. || die "cd failed"
ot_coverage=OFF
ot_plat_key_ref=OFF
ot_log_level=INFO
while [ $# -ge 2 ]; do
case $1 in
@@ -80,6 +82,22 @@ while [ $# -ge 2 ]; do
ot_plat_key_ref=ON
shift
;;
-l | --log-level)
# Check if the provided log level is valid
case "$2" in
NONE | CRIT | WARN | NOTE | INFO | DEBG)
ot_log_level="$2"
;;
*)
echo "Invalid log level \"$2\". Choose from NONE, CRIT, WARN, NOTE, INFO, DEBG."
exit 1
;;
esac
shift 2
;;
"")
shift
;;
@@ -116,6 +134,7 @@ case ${build_config} in
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_OPERATIONAL_DATASET_AUTO_INIT=ON -DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_BORDER_ROUTING=OFF \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
ninja || die
@@ -130,6 +149,7 @@ case ${build_config} in
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=OFF -DOT_OPERATIONAL_DATASET_AUTO_INIT=ON \
-DOT_BORDER_ROUTING=OFF \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
@@ -146,6 +166,7 @@ case ${build_config} in
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=OFF -DOT_TREL=ON -DOT_OPERATIONAL_DATASET_AUTO_INIT=ON \
-DOT_BORDER_ROUTING=OFF \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
@@ -162,6 +183,7 @@ case ${build_config} in
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=ON -DOT_OPERATIONAL_DATASET_AUTO_INIT=ON \
-DOT_BORDER_ROUTING=OFF \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
@@ -176,6 +198,7 @@ case ${build_config} in
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
@@ -190,6 +213,7 @@ case ${build_config} in
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=OFF \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
@@ -205,6 +229,7 @@ case ${build_config} in
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \
-DOT_15_4=OFF -DOT_TREL=ON \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
@@ -220,6 +245,7 @@ case ${build_config} in
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=ON \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
@@ -234,6 +260,7 @@ case ${build_config} in
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=OFF -DOT_APP_NCP=OFF -DOT_APP_RCP=ON \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
@@ -247,6 +274,7 @@ case ${build_config} in
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \
"${top_srcdir}" || die
@@ -261,6 +289,7 @@ case ${build_config} in
cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=OFF \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \
"${top_srcdir}" || die
@@ -275,6 +304,7 @@ case ${build_config} in
cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=OFF -DOT_TREL=ON \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \
"${top_srcdir}" || die
@@ -289,6 +319,7 @@ case ${build_config} in
cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=ON \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \
"${top_srcdir}" || die
@@ -302,6 +333,7 @@ case ${build_config} in
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.4 -DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=ON \
-DOT_LOG_LEVEL="${ot_log_level}" \
-DOT_PLATFORM_KEY_REF=${ot_plat_key_ref} \
-DOT_PROJECT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
@@ -136,8 +136,6 @@
#define OPENTHREAD_CONFIG_MAC_FILTER_SIZE 80
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_INFO
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 1
#define OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME 1