mirror of
https://github.com/espressif/openthread.git
synced 2026-08-19 08:59:52 +00:00
[scripts] apply shfmt changes (#4966)
This commit is contained in:
@@ -34,7 +34,8 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
main() {
|
||||
main()
|
||||
{
|
||||
gn gen gn-out
|
||||
ninja -C gn-out
|
||||
test -f gn-out/obj/lib-ot-core.a
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
at_exit() {
|
||||
at_exit()
|
||||
{
|
||||
EXIT_CODE=$?
|
||||
|
||||
killall expect || true
|
||||
@@ -41,12 +42,14 @@ at_exit() {
|
||||
exit $EXIT_CODE
|
||||
}
|
||||
|
||||
build() {
|
||||
build()
|
||||
{
|
||||
make -f examples/Makefile-simulation
|
||||
make -f src/posix/Makefile-posix
|
||||
}
|
||||
|
||||
check() {
|
||||
check()
|
||||
{
|
||||
trap at_exit INT TERM EXIT
|
||||
|
||||
rm -rf tmp/
|
||||
@@ -127,7 +130,8 @@ EOF
|
||||
test -n "{RADIO_VERSION}"
|
||||
}
|
||||
|
||||
main() {
|
||||
main()
|
||||
{
|
||||
case "$1" in
|
||||
build)
|
||||
build
|
||||
|
||||
@@ -41,7 +41,7 @@ build()
|
||||
reset_source
|
||||
make -f src/posix/Makefile-posix
|
||||
|
||||
if [[ $OSTYPE != "darwin"* ]] ; then
|
||||
if [[ $OSTYPE != "darwin"* ]]; then
|
||||
reset_source
|
||||
make -f src/posix/Makefile-posix RCP_BUS=spi
|
||||
fi
|
||||
|
||||
@@ -90,7 +90,7 @@ main()
|
||||
reset_source
|
||||
build
|
||||
|
||||
if [[ $OSTYPE != "darwin"* ]] ; then
|
||||
if [[ $OSTYPE != "darwin"* ]]; then
|
||||
reset_source
|
||||
build -DOT_POSIX_CONFIG_RCP_BUS=SPI
|
||||
fi
|
||||
|
||||
+21
-16
@@ -30,12 +30,14 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
die() {
|
||||
echo " *** ERROR: " $*
|
||||
exit 1
|
||||
die()
|
||||
{
|
||||
echo " *** ERROR: " $*
|
||||
exit 1
|
||||
}
|
||||
|
||||
at_exit() {
|
||||
at_exit()
|
||||
{
|
||||
EXIT_CODE=$?
|
||||
|
||||
sudo killall expect || true
|
||||
@@ -46,17 +48,19 @@ at_exit() {
|
||||
exit $EXIT_CODE
|
||||
}
|
||||
|
||||
build() {
|
||||
build()
|
||||
{
|
||||
make -f examples/Makefile-simulation
|
||||
make -f src/posix/Makefile-posix PLATFORM_NETIF=1 PLATFORM_UDP=1 UDP_FORWARD=0 MAX_POWER_TABLE=1
|
||||
}
|
||||
|
||||
check() {
|
||||
check()
|
||||
{
|
||||
trap at_exit INT TERM EXIT
|
||||
|
||||
SOCAT_OUTPUT=/tmp/ot-socat
|
||||
OT_OUTPUT=/tmp/ot-output
|
||||
socat -d -d pty,raw,echo=0 pty,raw,echo=0 > /dev/null 2> $SOCAT_OUTPUT &
|
||||
socat -d -d pty,raw,echo=0 pty,raw,echo=0 >/dev/null 2>$SOCAT_OUTPUT &
|
||||
while true; do
|
||||
if test $(head -n2 $SOCAT_OUTPUT | wc -l) = 2; then
|
||||
RADIO_PTY=$(head -n1 $SOCAT_OUTPUT | grep -o '/dev/.\+')
|
||||
@@ -70,7 +74,7 @@ check() {
|
||||
echo 'CORE_PTY' $CORE_PTY
|
||||
|
||||
RADIO_NCP_PATH="$(pwd)/$(ls output/*linux*/bin/ot-rcp)"
|
||||
$RADIO_NCP_PATH 1 > $RADIO_PTY < $RADIO_PTY &
|
||||
$RADIO_NCP_PATH 1 >$RADIO_PTY <$RADIO_PTY &
|
||||
|
||||
# Cover setting a valid network interface name.
|
||||
readonly VALID_NETIF_NAME="wan$(date +%H%M%S)"
|
||||
@@ -79,7 +83,7 @@ check() {
|
||||
'--max-power-table=11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26'
|
||||
)
|
||||
|
||||
if [[ "${DAEMON}" = 1 ]]; then
|
||||
if [[ ${DAEMON} == 1 ]]; then
|
||||
sudo "$(pwd)/$(ls output/posix/*linux*/bin/ot-daemon)" "${options[@]}" -I "${VALID_NETIF_NAME}" ${CORE_PTY} &
|
||||
sleep 1
|
||||
OT_CLI_CMD="$(pwd)/$(ls output/posix/*linux*/bin/ot-ctl)"
|
||||
@@ -94,11 +98,11 @@ check() {
|
||||
readonly INVALID_NETIF_NAME="wan0123456789123"
|
||||
sudo ${OT_CLI_CMD} -I "${INVALID_NETIF_NAME}" -n || test $? = 2
|
||||
|
||||
if [[ "${DAEMON}" = 1 ]]; then
|
||||
if [[ ${DAEMON} == 1 ]]; then
|
||||
sudo ${OT_CLI_CMD} panid 0xface | grep 'Done' || die 'failed to set panid with ot-ctl'
|
||||
fi
|
||||
|
||||
sudo expect <<EOF > "${OT_OUTPUT}" &
|
||||
sudo expect <<EOF >"${OT_OUTPUT}" &
|
||||
spawn ${OT_CLI_CMD}
|
||||
send "panid 0xface\r\n"
|
||||
expect "Done"
|
||||
@@ -134,13 +138,13 @@ EOF
|
||||
extaddr=$(awk '/extaddr/{getline; print}' $OT_OUTPUT | tr -d '\r\n')
|
||||
echo "Extended address is: ${extaddr}"
|
||||
|
||||
if [[ "${DAEMON}" = 1 ]]; then
|
||||
if [[ ${DAEMON} == 1 ]]; then
|
||||
sudo killall -9 expect || true
|
||||
sudo killall -9 ot-ctl || true
|
||||
NETIF_INDEX=$(ip link show "${VALID_NETIF_NAME}" | cut -f 1 -d ":" | head -n 1)
|
||||
sudo PATH="$(dirname ${OT_CLI_CMD}):${PATH}" \
|
||||
python3 "$PWD/tests/scripts/misc/test_multicast_join.py" "${NETIF_INDEX}" \
|
||||
|| die 'multicast group join failed'
|
||||
python3 "$PWD/tests/scripts/misc/test_multicast_join.py" "${NETIF_INDEX}" \
|
||||
|| die 'multicast group join failed'
|
||||
fi
|
||||
|
||||
LEADER_ALOC=fdde:ad00:beef::ff:fe00:fc00
|
||||
@@ -149,10 +153,11 @@ EOF
|
||||
echo "CoAP response is: ${coap_response}"
|
||||
|
||||
# Verify CoAP response contains the extended address
|
||||
[[ "${coap_response}" = *${extaddr}* ]] && echo 'Success' || die 'failed to get extended address'
|
||||
[[ ${coap_response} == *${extaddr}* ]] && echo 'Success' || die 'failed to get extended address'
|
||||
}
|
||||
|
||||
main() {
|
||||
main()
|
||||
{
|
||||
case $1 in
|
||||
build)
|
||||
build
|
||||
|
||||
@@ -81,7 +81,7 @@ do_scan_build()
|
||||
"-DMBEDTLS_DEBUG_C"
|
||||
"-I$(pwd)/third_party/mbedtls"
|
||||
"-I$(pwd)/third_party/mbedtls/repo/include"
|
||||
"-DMBEDTLS_CONFIG_FILE=\\\"mbedtls-config.h\\\""
|
||||
'-DMBEDTLS_CONFIG_FILE=\"mbedtls-config.h\"'
|
||||
)
|
||||
|
||||
configure_options=(
|
||||
|
||||
+14
-14
@@ -64,14 +64,14 @@ markdown_size()
|
||||
local name
|
||||
name=$(basename "$1")
|
||||
|
||||
read -r -a size_old <<< "$(size "$1" | awk '{text+=$1} {bss+=$2} {data+=$3} {total+=$4} END {printf "%d %d %d %d", text, bss, data, total}')"
|
||||
read -r -a size_new <<< "$(size "$2" | awk '{text+=$1} {bss+=$2} {data+=$3} {total+=$4} END {printf "%d %d %d %d", text, bss, data, total}')"
|
||||
read -r -a size_old <<<"$(size "$1" | awk '{text+=$1} {bss+=$2} {data+=$3} {total+=$4} END {printf "%d %d %d %d", text, bss, data, total}')"
|
||||
read -r -a size_new <<<"$(size "$2" | awk '{text+=$1} {bss+=$2} {data+=$3} {total+=$4} END {printf "%d %d %d %d", text, bss, data, total}')"
|
||||
|
||||
local -a size_diff
|
||||
|
||||
for i in 0 1 2 3; do
|
||||
size_diff[$i]="$((size_new["$i"] - size_old["$i"]))"
|
||||
if [[ "${size_diff["$i"]}" != 0 ]]; then
|
||||
if [[ ${size_diff["$i"]} != 0 ]]; then
|
||||
size_diff["$i"]=$(printf '%+d' "${size_diff["$i"]}")
|
||||
fi
|
||||
done
|
||||
@@ -86,11 +86,11 @@ markdown()
|
||||
case "$1" in
|
||||
init)
|
||||
shift
|
||||
markdown_init "$@" > "${OT_REPORT_FILE}"
|
||||
markdown_init "$@" >"${OT_REPORT_FILE}"
|
||||
;;
|
||||
size)
|
||||
shift
|
||||
markdown_size "$@" >> "${OT_REPORT_FILE}"
|
||||
markdown_size "$@" >>"${OT_REPORT_FILE}"
|
||||
;;
|
||||
post)
|
||||
mdv "${OT_REPORT_FILE}"
|
||||
@@ -152,11 +152,11 @@ size_nrf52840()
|
||||
local reporter
|
||||
|
||||
# not on GitHub Actions or not a pull request event
|
||||
if [[ ! "${GITHUB_ACTIONS+x}" || ! "${GITHUB_REF-}" =~ ^refs/pull/[0-9]+/merge ]]; then
|
||||
if [[ ! ${GITHUB_ACTIONS+x} || ! ${GITHUB_REF-} =~ ^refs/pull/[0-9]+/merge ]]; then
|
||||
reporter=markdown
|
||||
else
|
||||
reporter=./size-report
|
||||
curl -s "${SIZE_REPORT_URL}/bash" > size-report
|
||||
curl -s "${SIZE_REPORT_URL}/bash" >size-report
|
||||
chmod a+x size-report
|
||||
export OT_SHA_NEW OT_SHA_OLD
|
||||
fi
|
||||
@@ -167,16 +167,16 @@ size_nrf52840()
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-cli-mtd "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-cli-mtd
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-ncp-ftd "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-ncp-ftd
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-ncp-mtd "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-ncp-mtd
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-rcp "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-rcp
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-rcp "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-rcp
|
||||
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-cli-ftd.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-cli-ftd.a
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-cli-mtd.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-cli-mtd.a
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-ftd.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-ftd.a
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-mtd.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-mtd.a
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-ftd.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-ftd.a
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-mtd.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-mtd.a
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-ncp-ftd.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-ncp-ftd.a
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-ncp-mtd.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-ncp-mtd.a
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-rcp.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-rcp.a
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-radio.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-radio.a
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-rcp.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-rcp.a
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-radio.a "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-radio.a
|
||||
|
||||
"${reporter}" post
|
||||
}
|
||||
@@ -186,9 +186,9 @@ main()
|
||||
if [[ $# == 0 ]]; then
|
||||
setup
|
||||
size_nrf52840
|
||||
elif [[ "$1" == setup ]]; then
|
||||
elif [[ $1 == setup ]]; then
|
||||
setup
|
||||
elif [[ "$1" == nrf52840 ]]; then
|
||||
elif [[ $1 == nrf52840 ]]; then
|
||||
size_nrf52840
|
||||
else
|
||||
echo "USAGE: $0 [setup|nrf52840]"
|
||||
|
||||
+8
-8
@@ -29,7 +29,8 @@
|
||||
|
||||
CLANG_FORMAT_VERSION="clang-format version 6.0"
|
||||
|
||||
die() {
|
||||
die()
|
||||
{
|
||||
echo " *** ERROR: $*"
|
||||
exit 1
|
||||
}
|
||||
@@ -38,12 +39,12 @@ die() {
|
||||
# expand_aliases shell option is set using shopt.
|
||||
shopt -s expand_aliases
|
||||
|
||||
if command -v clang-format-6.0 > /dev/null; then
|
||||
if command -v clang-format-6.0 >/dev/null; then
|
||||
alias clang-format=clang-format-6.0
|
||||
elif command -v clang-format > /dev/null; then
|
||||
elif command -v clang-format >/dev/null; then
|
||||
case "$(clang-format --version)" in
|
||||
"$CLANG_FORMAT_VERSION"*)
|
||||
;;
|
||||
"$CLANG_FORMAT_VERSION"*) ;;
|
||||
|
||||
*)
|
||||
die "$(clang-format --version); clang-format 6.0 required"
|
||||
;;
|
||||
@@ -56,8 +57,7 @@ clang-format "$@" || die
|
||||
|
||||
# ensure EOF newline
|
||||
REPLACE=no
|
||||
for arg
|
||||
do
|
||||
for arg; do
|
||||
case $arg in
|
||||
-i)
|
||||
REPLACE=yes
|
||||
@@ -68,7 +68,7 @@ done
|
||||
file=$arg
|
||||
|
||||
[ $REPLACE != yes ] || {
|
||||
[ -n "$(tail -c1 "$file")" ] && echo >> "$file"
|
||||
[ -n "$(tail -c1 "$file")" ] && echo >>"$file"
|
||||
}
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
die() {
|
||||
die()
|
||||
{
|
||||
echo " *** ERROR: $*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
+38
-28
@@ -67,82 +67,91 @@ readonly OT_CLANG_SOURCES=('*.c' '*.cc' '*.cpp' '*.h' '*.hpp')
|
||||
readonly OT_MARKDOWN_SOURCES=('*.md')
|
||||
readonly OT_PYTHON_SOURCES=('*.py')
|
||||
|
||||
do_clang_format() {
|
||||
do_clang_format()
|
||||
{
|
||||
echo -e '====================='
|
||||
echo -e ' format c/c++'
|
||||
echo -e '====================='
|
||||
|
||||
git ls-files "${OT_CLANG_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" |
|
||||
xargs -n3 -P"$OT_BUILD_JOBS" script/clang-format -style=file -i -verbose
|
||||
git ls-files "${OT_CLANG_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" \
|
||||
| xargs -n3 -P"$OT_BUILD_JOBS" script/clang-format -style=file -i -verbose
|
||||
}
|
||||
|
||||
do_clang_check() {
|
||||
do_clang_check()
|
||||
{
|
||||
echo -e '====================='
|
||||
echo -e ' check c/c++'
|
||||
echo -e '====================='
|
||||
|
||||
git ls-files "${OT_CLANG_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" |
|
||||
xargs -n3 -P"$OT_BUILD_JOBS" script/clang-format-check
|
||||
git ls-files "${OT_CLANG_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" \
|
||||
| xargs -n3 -P"$OT_BUILD_JOBS" script/clang-format-check
|
||||
}
|
||||
|
||||
do_markdown_format() {
|
||||
do_markdown_format()
|
||||
{
|
||||
echo -e '======================'
|
||||
echo -e ' format markdown'
|
||||
echo -e '======================'
|
||||
|
||||
git ls-files "${OT_MARKDOWN_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" |
|
||||
xargs -n10 -P"$OT_BUILD_JOBS" npx [email protected] --write
|
||||
git ls-files "${OT_MARKDOWN_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" \
|
||||
| xargs -n10 -P"$OT_BUILD_JOBS" npx [email protected] --write
|
||||
}
|
||||
|
||||
do_markdown_check() {
|
||||
do_markdown_check()
|
||||
{
|
||||
echo -e '======================'
|
||||
echo -e ' check markdown'
|
||||
echo -e '======================'
|
||||
|
||||
git ls-files "${OT_MARKDOWN_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" |
|
||||
xargs -n10 -P"$OT_BUILD_JOBS" npx [email protected] --check
|
||||
git ls-files "${OT_MARKDOWN_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" \
|
||||
| xargs -n10 -P"$OT_BUILD_JOBS" npx [email protected] --check
|
||||
}
|
||||
|
||||
do_python_format() {
|
||||
do_python_format()
|
||||
{
|
||||
echo -e '======================'
|
||||
echo -e ' format python'
|
||||
echo -e '======================'
|
||||
|
||||
git ls-files "${OT_PYTHON_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" |
|
||||
xargs -n10 -P"$OT_BUILD_JOBS" python3 -m yapf --verbose --style google -ipr
|
||||
git ls-files "${OT_PYTHON_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" \
|
||||
| xargs -n10 -P"$OT_BUILD_JOBS" python3 -m yapf --verbose --style google -ipr
|
||||
}
|
||||
|
||||
do_python_check() {
|
||||
do_python_check()
|
||||
{
|
||||
echo -e '====================='
|
||||
echo -e ' check python'
|
||||
echo -e '====================='
|
||||
|
||||
git ls-files "${OT_PYTHON_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" |
|
||||
xargs -n10 -P"$OT_BUILD_JOBS" python3 -m yapf --verbose --style google -dpr
|
||||
git ls-files "${OT_PYTHON_SOURCES[@]}" | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" \
|
||||
| xargs -n10 -P"$OT_BUILD_JOBS" python3 -m yapf --verbose --style google -dpr
|
||||
}
|
||||
|
||||
do_shell_format() {
|
||||
do_shell_format()
|
||||
{
|
||||
echo -e '====================='
|
||||
echo -e ' format shell'
|
||||
echo -e '====================='
|
||||
|
||||
shfmt -f . | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" |
|
||||
xargs -n10 -P"$OT_BUILD_JOBS" shfmt -i 4 -bn -ci -fn -s -w
|
||||
shfmt -f . | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" \
|
||||
| xargs -n10 -P"$OT_BUILD_JOBS" shfmt -i 4 -bn -ci -fn -s -w
|
||||
}
|
||||
|
||||
do_shell_check() {
|
||||
do_shell_check()
|
||||
{
|
||||
echo -e '====================='
|
||||
echo -e ' check shell'
|
||||
echo -e '====================='
|
||||
|
||||
shfmt -f . | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" |
|
||||
xargs -n10 -P"$OT_BUILD_JOBS" shfmt -i 4 -bn -ci -fn -s -d
|
||||
shfmt -f . | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" \
|
||||
| xargs -n10 -P"$OT_BUILD_JOBS" shfmt -i 4 -bn -ci -fn -s -d
|
||||
|
||||
shfmt -f . | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" |
|
||||
xargs -n10 -P"$OT_BUILD_JOBS" shellcheck
|
||||
shfmt -f . | grep -v -E "^($(echo "${OT_EXCLUDE_DIRS[@]}" | tr ' ' '|'))" \
|
||||
| xargs -n10 -P"$OT_BUILD_JOBS" shellcheck
|
||||
}
|
||||
|
||||
do_check() {
|
||||
do_check()
|
||||
{
|
||||
if [ $# == 0 ]; then
|
||||
do_clang_check
|
||||
do_markdown_check
|
||||
@@ -163,7 +172,8 @@ do_check() {
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
main()
|
||||
{
|
||||
if [ $# == 0 ]; then
|
||||
do_clang_format
|
||||
do_markdown_format
|
||||
|
||||
+51
-44
@@ -77,22 +77,22 @@ build_simulation()
|
||||
"-DOT_THREAD_VERSION=${version}"
|
||||
)
|
||||
|
||||
if [[ "${version}" == "1.2" ]]; then
|
||||
if [[ ${version} == "1.2" ]]; then
|
||||
options+=(
|
||||
"-DOT_DUA=ON"
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ "${VIRTUAL_TIME}" == 1 ]]; then
|
||||
if [[ ${VIRTUAL_TIME} == 1 ]]; then
|
||||
options+=("-DOT_SIMULATION_VIRTUAL_TIME=ON")
|
||||
|
||||
if [[ "${NODE_MODE}" == "rcp" ]]; then
|
||||
if [[ ${NODE_MODE} == "rcp" ]]; then
|
||||
options+=("-DOT_SIMULATION_VIRTUAL_TIME_UART=ON")
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [[ "${version}" == "1.2" ]]; then
|
||||
if [[ ${version} == "1.2" ]]; then
|
||||
options+=(
|
||||
"-DOT_CSL_RECEIVER=ON"
|
||||
)
|
||||
@@ -104,12 +104,12 @@ build_simulation()
|
||||
&& cmake -GNinja "${options[@]}" "${ot_extra_options[@]}" "${OT_SRCDIR}" \
|
||||
&& ninja)
|
||||
|
||||
if [[ "${version}" == "1.2" ]]; then
|
||||
if [[ ${version} == "1.2" ]]; then
|
||||
|
||||
options+=(
|
||||
"-DOT_BACKBONE_ROUTER=ON"
|
||||
"-DOT_BORDER_ROUTER=ON"
|
||||
"-DOT_SERVICE=ON"
|
||||
"-DOT_BACKBONE_ROUTER=ON"
|
||||
"-DOT_BORDER_ROUTER=ON"
|
||||
"-DOT_SERVICE=ON"
|
||||
)
|
||||
|
||||
local builddir="${OT_BUILDDIR}/cmake/openthread-simulation-${version}-bbr"
|
||||
@@ -133,13 +133,13 @@ build_posix()
|
||||
"-DOT_THREAD_VERSION=${version}"
|
||||
)
|
||||
|
||||
if [[ "${version}" == "1.2" ]]; then
|
||||
if [[ ${version} == "1.2" ]]; then
|
||||
options+=(
|
||||
"-DOT_DUA=ON"
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ "${VIRTUAL_TIME}" == 1 ]]; then
|
||||
if [[ ${VIRTUAL_TIME} == 1 ]]; then
|
||||
options+=("-DOT_POSIX_VIRTUAL_TIME=ON")
|
||||
fi
|
||||
|
||||
@@ -149,12 +149,12 @@ build_posix()
|
||||
&& cmake -GNinja "${options[@]}" "${ot_extra_options[@]}" "${OT_SRCDIR}" \
|
||||
&& ninja)
|
||||
|
||||
if [[ "${version}" == "1.2" ]]; then
|
||||
if [[ ${version} == "1.2" ]]; then
|
||||
|
||||
options+=(
|
||||
"-DOT_BACKBONE_ROUTER=ON"
|
||||
"-DOT_BORDER_ROUTER=ON"
|
||||
"-DOT_SERVICE=ON"
|
||||
"-DOT_BACKBONE_ROUTER=ON"
|
||||
"-DOT_BORDER_ROUTER=ON"
|
||||
"-DOT_SERVICE=ON"
|
||||
)
|
||||
|
||||
local builddir="${OT_BUILDDIR}/cmake/openthread-posix-${version}-bbr"
|
||||
@@ -165,30 +165,33 @@ build_posix()
|
||||
fi
|
||||
}
|
||||
|
||||
do_build() {
|
||||
do_build()
|
||||
{
|
||||
build_simulation "${THREAD_VERSION}"
|
||||
|
||||
if [[ "${NODE_MODE}" == "rcp" ]]; then
|
||||
if [[ ${NODE_MODE} == "rcp" ]]; then
|
||||
build_posix "${THREAD_VERSION}"
|
||||
fi
|
||||
|
||||
# Extra 1.1 build for 1.2 tests
|
||||
if [[ "${THREAD_VERSION}" == "1.2" ]]; then
|
||||
if [[ ${THREAD_VERSION} == "1.2" ]]; then
|
||||
build_simulation 1.1
|
||||
|
||||
if [[ "${NODE_MODE}" == "rcp" ]]; then
|
||||
if [[ ${NODE_MODE} == "rcp" ]]; then
|
||||
build_posix 1.1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
do_clean() {
|
||||
do_clean()
|
||||
{
|
||||
rm -rfv "${OT_BUILDDIR}"
|
||||
}
|
||||
|
||||
do_unit() {
|
||||
do_unit()
|
||||
{
|
||||
local builddir="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}"
|
||||
if [[ ! -d "${builddir}" ]]; then
|
||||
if [[ ! -d ${builddir} ]]; then
|
||||
echo "Cannot find build directory!"
|
||||
exit -1
|
||||
fi
|
||||
@@ -197,10 +200,11 @@ do_unit() {
|
||||
ninja test
|
||||
}
|
||||
|
||||
do_cert() {
|
||||
do_cert()
|
||||
{
|
||||
export top_builddir="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}"
|
||||
|
||||
if [[ "${THREAD_VERSION}" == "1.2" ]]; then
|
||||
if [[ ${THREAD_VERSION} == "1.2" ]]; then
|
||||
export top_builddir_1_1="${OT_BUILDDIR}/cmake/openthread-simulation-1.1"
|
||||
export top_builddir_1_2_bbr="${OT_BUILDDIR}/cmake/openthread-simulation-1.2-bbr"
|
||||
fi
|
||||
@@ -209,10 +213,11 @@ do_cert() {
|
||||
PYTHONUNBUFFERED=1 "$1"
|
||||
}
|
||||
|
||||
do_cert_suite() {
|
||||
do_cert_suite()
|
||||
{
|
||||
export top_builddir="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}"
|
||||
|
||||
if [[ "${THREAD_VERSION}" == "1.2" ]]; then
|
||||
if [[ ${THREAD_VERSION} == "1.2" ]]; then
|
||||
export top_builddir_1_1="${OT_BUILDDIR}/cmake/openthread-simulation-1.1"
|
||||
export top_builddir_1_2_bbr="${OT_BUILDDIR}/cmake/openthread-simulation-1.2-bbr"
|
||||
fi
|
||||
@@ -224,18 +229,18 @@ do_cert_suite() {
|
||||
|
||||
for test_case in "$@"; do
|
||||
rm -rf tmp
|
||||
if "${test_case}" &> test.log; then
|
||||
if "${test_case}" &>test.log; then
|
||||
echo -e "${COLOR_PASS}PASS${COLOR_NONE} ${test_case}"
|
||||
pass_count=$(( pass_count + 1 ))
|
||||
pass_count=$((pass_count + 1))
|
||||
else
|
||||
echo -e "${COLOR_FAIL}FAIL${COLOR_NONE} ${test_case}"
|
||||
fail_count=$(( fail_count + 1 ))
|
||||
fail_count=$((fail_count + 1))
|
||||
{
|
||||
echo "=============================="
|
||||
echo "!!! FAIL:${test_case}"
|
||||
echo "=============================="
|
||||
cat test.log
|
||||
} >> fail.log
|
||||
} >>fail.log
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -246,8 +251,8 @@ do_cert_suite() {
|
||||
echo "# PASS: ${pass_count}"
|
||||
echo "# FAIL: ${fail_count}"
|
||||
|
||||
if [[ "${fail_count}" -gt 0 ]]; then
|
||||
tr -dc '[:print:]\r\n\t' < fail.log
|
||||
if [[ ${fail_count} -gt 0 ]]; then
|
||||
tr -dc '[:print:]\r\n\t' <fail.log
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
@@ -260,7 +265,7 @@ do_expect()
|
||||
local rcp_command=
|
||||
local test_pattern
|
||||
|
||||
if [[ "${NODE_MODE}" == rcp ]]; then
|
||||
if [[ ${NODE_MODE} == rcp ]]; then
|
||||
ot_command="${OT_CLI_PATH}"
|
||||
rcp_command="${RADIO_DEVICE}"
|
||||
test_pattern='posix-*.exp'
|
||||
@@ -288,7 +293,8 @@ do_expect()
|
||||
exit 0
|
||||
}
|
||||
|
||||
print_usage() {
|
||||
print_usage()
|
||||
{
|
||||
echo "USAGE: [ENVIRONMENTS] $0 COMMANDS
|
||||
|
||||
ENVIRONMENTS:
|
||||
@@ -338,7 +344,8 @@ EXAMPLES:
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
do_package() {
|
||||
do_package()
|
||||
{
|
||||
local builddir="${OT_BUILDDIR}/cmake/openthread-sim"
|
||||
local options=(
|
||||
"-DCMAKE_BUILD_TYPE=Release"
|
||||
@@ -373,19 +380,19 @@ do_package() {
|
||||
(mkdir -p "${builddir}" \
|
||||
&& cd "${builddir}" \
|
||||
&& cmake -GNinja -DOT_PLATFORM="posix" \
|
||||
-DOT_DAEMON=1 -DOT_PLATFORM_NETIF=1 -DOT_PLATFORM_UDP=1 "${options[@]}" "${ot_extra_options[@]}" "${OT_SRCDIR}" \
|
||||
-DOT_DAEMON=1 -DOT_PLATFORM_NETIF=1 -DOT_PLATFORM_UDP=1 "${options[@]}" "${ot_extra_options[@]}" "${OT_SRCDIR}" \
|
||||
&& ninja package \
|
||||
&& ls "${builddir}"/openthread-daemon-*.deb)
|
||||
}
|
||||
|
||||
envsetup()
|
||||
{
|
||||
if [[ "${NODE_MODE}" == 'rcp' ]] ; then
|
||||
if [[ ${NODE_MODE} == 'rcp' ]]; then
|
||||
export RADIO_DEVICE="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}/examples/apps/ncp/ot-rcp"
|
||||
export OT_CLI_PATH="${OT_BUILDDIR}/cmake/openthread-posix-${THREAD_VERSION}/src/posix/ot-cli"
|
||||
export OT_NCP_PATH="${OT_BUILDDIR}/cmake/openthread-posix-${THREAD_VERSION}/src/posix/ot-ncp"
|
||||
|
||||
if [[ "${THREAD_VERSION}" == "1.2" ]]; then
|
||||
if [[ ${THREAD_VERSION} == "1.2" ]]; then
|
||||
export RADIO_DEVICE_1_1="${OT_BUILDDIR}/cmake/openthread-simulation-1.1/examples/apps/ncp/ot-rcp"
|
||||
export OT_CLI_PATH_1_1="${OT_BUILDDIR}/cmake/openthread-posix-1.1/src/posix/ot-cli"
|
||||
export OT_NCP_PATH_1_1="${OT_BUILDDIR}/cmake/openthread-posix-1.1/src/posix/ot-ncp"
|
||||
@@ -397,13 +404,13 @@ envsetup()
|
||||
export NODE_TYPE VIRTUAL_TIME
|
||||
|
||||
# CMake always works in verbose mode if VERBOSE exists in environments.
|
||||
if [[ "${VERBOSE}" == 1 ]]; then
|
||||
if [[ ${VERBOSE} == 1 ]]; then
|
||||
export VERBOSE
|
||||
else
|
||||
export -n VERBOSE
|
||||
fi
|
||||
|
||||
read -r -a ot_extra_options <<< "${OT_OPTIONS-}"
|
||||
read -r -a ot_extra_options <<<"${OT_OPTIONS-}"
|
||||
ot_extra_options=${ot_extra_options:-()}
|
||||
}
|
||||
|
||||
@@ -411,14 +418,14 @@ main()
|
||||
{
|
||||
envsetup
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
if [[ -z $1 ]]; then
|
||||
print_usage 1
|
||||
fi
|
||||
|
||||
[[ "${NODE_MODE}" == "rcp" ]] && echo "Using rcp mode" || echo "Using standalone mode"
|
||||
[[ "${NODE_TYPE}" == "ncp-sim" ]] && echo "Using NCP node" || echo "Using CLI node"
|
||||
[[ "${VIRTUAL_TIME}" == 1 ]] && echo "Using virtual time" || echo "Using real time"
|
||||
[[ "${THREAD_VERSION}" == "1.2" ]] && echo "Using Thread 1.2 stack" || echo "Using Thread 1.1 stack"
|
||||
[[ ${NODE_MODE} == "rcp" ]] && echo "Using rcp mode" || echo "Using standalone mode"
|
||||
[[ ${NODE_TYPE} == "ncp-sim" ]] && echo "Using NCP node" || echo "Using CLI node"
|
||||
[[ ${VIRTUAL_TIME} == 1 ]] && echo "Using virtual time" || echo "Using real time"
|
||||
[[ ${THREAD_VERSION} == "1.2" ]] && echo "Using Thread 1.2 stack" || echo "Using Thread 1.1 stack"
|
||||
|
||||
while [[ $# != 0 ]]; do
|
||||
case "$1" in
|
||||
|
||||
Reference in New Issue
Block a user