mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[shell] resolve shellcheck warnings (#4966)
This commit is contained in:
@@ -36,10 +36,6 @@
|
||||
|
||||
nlbuild_autotools_stem="third_party/nlbuild-autotools/repo"
|
||||
|
||||
# Establish some key directories
|
||||
abs_srcdir=$(cd "$(dirname "${0}")" && pwd)
|
||||
|
||||
srcdir=$(dirname ${0})
|
||||
abs_srcdir=$(pwd)
|
||||
abs_top_srcdir="${abs_srcdir}"
|
||||
|
||||
exec ${srcdir}/${nlbuild_autotools_stem}/scripts/bootstrap -I "${abs_top_srcdir}/${nlbuild_autotools_stem}" $*
|
||||
(cd "$abs_srcdir" && exec "$abs_srcdir/$nlbuild_autotools_stem/scripts/bootstrap" -I "$abs_srcdir/$nlbuild_autotools_stem" "${@}")
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
docker exec -it otsim node $1
|
||||
docker exec -it otsim node "$1"
|
||||
|
||||
@@ -93,7 +93,7 @@ EOF
|
||||
|
||||
echo "Step 2. Start retrieving dataset from Radio..."
|
||||
RADIO_NCP_PATH="$(pwd)/$(ls output/*linux*/bin/ot-ncp-ftd)"
|
||||
"$(pwd)/$(ls output/posix/*linux*/bin/ot-ncp)" -n --radio-version --ncp-dataset -- ${RADIO_NCP_PATH} 1
|
||||
"$(pwd)/$(ls output/posix/*linux*/bin/ot-ncp)" -n --radio-version --ncp-dataset -- "${RADIO_NCP_PATH}" 1
|
||||
|
||||
echo "Step 3. Start posix app and check whether PAN dataset is the same..."
|
||||
RADIO_RCP_PATH="$(pwd)/$(ls output/*linux*/bin/ot-rcp)"
|
||||
@@ -126,8 +126,8 @@ expect eof
|
||||
EOF
|
||||
|
||||
echo "Step 4. Start posix app and check whether it can get radio firmware version..."
|
||||
RADIO_VERSION="$("$(pwd)/$(ls output/posix/*linux*/bin/ot-cli)" -n --radio-version --ncp-dataset -- ${RADIO_RCP_PATH} 1)" || true
|
||||
test -n "{RADIO_VERSION}"
|
||||
RADIO_VERSION="$("$(pwd)/$(ls output/posix/*linux*/bin/ot-cli)" -n --radio-version --ncp-dataset -- "${RADIO_RCP_PATH}" 1)" || true
|
||||
test -n "${RADIO_VERSION}"
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
readonly OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
reset_source()
|
||||
{
|
||||
rm -rf build output tmp
|
||||
|
||||
@@ -77,12 +77,12 @@ build()
|
||||
"-DOT_FULL_LOGS=on"
|
||||
)
|
||||
|
||||
mkdir -p $OT_BUILDDIR
|
||||
cd $OT_BUILDDIR
|
||||
cmake -GNinja "${options[@]}" $OT_SRCDIR
|
||||
mkdir -p "$OT_BUILDDIR"
|
||||
cd "$OT_BUILDDIR"
|
||||
cmake -GNinja "${options[@]}" "$OT_SRCDIR"
|
||||
ninja
|
||||
|
||||
cd $OT_SRCDIR
|
||||
cd "$OT_SRCDIR"
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
+22
-14
@@ -32,7 +32,7 @@ set -x
|
||||
|
||||
die()
|
||||
{
|
||||
echo " *** ERROR: " $*
|
||||
echo " *** ERROR: " "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ check()
|
||||
OT_OUTPUT=/tmp/ot-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
|
||||
if test "$(head -n2 $SOCAT_OUTPUT | wc -l)" = 2; then
|
||||
RADIO_PTY=$(head -n1 $SOCAT_OUTPUT | grep -o '/dev/.\+')
|
||||
CORE_PTY=$(head -n2 $SOCAT_OUTPUT | tail -n1 | grep -o '/dev/.\+')
|
||||
break
|
||||
@@ -70,11 +70,13 @@ check()
|
||||
echo 'Waiting for socat ready...'
|
||||
sleep 1
|
||||
done
|
||||
echo 'RADIO_PTY' $DEVICE_PTY
|
||||
echo 'CORE_PTY' $CORE_PTY
|
||||
echo 'RADIO_PTY' "$DEVICE_PTY"
|
||||
echo 'CORE_PTY' "$CORE_PTY"
|
||||
|
||||
RADIO_NCP_PATH="$(pwd)/$(ls output/*linux*/bin/ot-rcp)"
|
||||
$RADIO_NCP_PATH 1 >$RADIO_PTY <$RADIO_PTY &
|
||||
|
||||
# shellcheck disable=SC2094
|
||||
$RADIO_NCP_PATH 1 >"$RADIO_PTY" <"$RADIO_PTY" &
|
||||
|
||||
# Cover setting a valid network interface name.
|
||||
readonly VALID_NETIF_NAME="wan$(date +%H%M%S)"
|
||||
@@ -84,26 +86,28 @@ check()
|
||||
)
|
||||
|
||||
if [[ ${DAEMON} == 1 ]]; then
|
||||
sudo "$(pwd)/$(ls output/posix/*linux*/bin/ot-daemon)" "${options[@]}" -I "${VALID_NETIF_NAME}" ${CORE_PTY} &
|
||||
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)"
|
||||
OT_CLI_ARG=
|
||||
else
|
||||
OT_CLI_CMD="$(pwd)/$(ls output/posix/*linux*/bin/ot-cli) "${options[@]}" ${CORE_PTY}"
|
||||
OT_CLI_CMD="$(pwd)/$(ls output/posix/*linux*/bin/ot-cli)"
|
||||
OT_CLI_ARG="${CORE_PTY}"
|
||||
fi
|
||||
|
||||
sudo ${OT_CLI_CMD} -I "${VALID_NETIF_NAME}" -n
|
||||
sudo "${OT_CLI_CMD}" "${OT_CLI_ARG}" -I "${VALID_NETIF_NAME}" -n
|
||||
|
||||
# Cover setting a too long(max is 15 characters) network interface name.
|
||||
# Expect exit code to be 2(OT_EXIT_INVALID_ARGUMENTS).
|
||||
readonly INVALID_NETIF_NAME="wan0123456789123"
|
||||
sudo ${OT_CLI_CMD} -I "${INVALID_NETIF_NAME}" -n || test $? = 2
|
||||
sudo "${OT_CLI_CMD}" "${OT_CLI_ARG}" -I "${INVALID_NETIF_NAME}" -n || test $? = 2
|
||||
|
||||
if [[ ${DAEMON} == 1 ]]; then
|
||||
sudo ${OT_CLI_CMD} panid 0xface | grep 'Done' || die 'failed to set panid with ot-ctl'
|
||||
sudo "${OT_CLI_CMD}" "${OT_CLI_ARG}" panid 0xface | grep 'Done' || die 'failed to set panid with ot-ctl'
|
||||
fi
|
||||
|
||||
sudo expect <<EOF >"${OT_OUTPUT}" &
|
||||
spawn ${OT_CLI_CMD}
|
||||
sudo expect <<EOF | tee "${OT_OUTPUT}" &
|
||||
spawn ${OT_CLI_CMD} ${OT_CLI_ARG}
|
||||
send "panid 0xface\r\n"
|
||||
expect "Done"
|
||||
send "ifconfig up\r\n"
|
||||
@@ -142,7 +146,7 @@ EOF
|
||||
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}" \
|
||||
sudo PATH="$(dirname "${OT_CLI_CMD}"):${PATH}" \
|
||||
python3 "$PWD/tests/scripts/misc/test_multicast_join.py" "${NETIF_INDEX}" \
|
||||
|| die 'multicast group join failed'
|
||||
fi
|
||||
@@ -153,7 +157,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'
|
||||
if [[ ${coap_response} == *${extaddr}* ]]; then
|
||||
echo 'Success'
|
||||
else
|
||||
die 'failed to get extended address'
|
||||
fi
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
+3
-3
@@ -193,7 +193,7 @@ do_unit()
|
||||
local builddir="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}"
|
||||
if [[ ! -d ${builddir} ]]; then
|
||||
echo "Cannot find build directory!"
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "${builddir}"
|
||||
@@ -410,8 +410,8 @@ envsetup()
|
||||
export -n VERBOSE
|
||||
fi
|
||||
|
||||
read -r -a ot_extra_options <<<"${OT_OPTIONS-}"
|
||||
ot_extra_options=${ot_extra_options:-()}
|
||||
read -r -a ot_extra_options_in <<<"${OT_OPTIONS-}"
|
||||
ot_extra_options=${ot_extra_options_in:-()}
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
+21
-21
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2018, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
@@ -27,15 +27,12 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
cd $(dirname $0)
|
||||
cd ../..
|
||||
|
||||
display_usage()
|
||||
{
|
||||
echo ""
|
||||
echo "Toranj Build script "
|
||||
echo ""
|
||||
echo "Usage: $(basename $0) [options] <config>"
|
||||
echo "Usage: $(basename "$0") [options] <config>"
|
||||
echo " <config> can be:"
|
||||
echo " ncp : Build OpenThread NCP FTD mode with simulation platform"
|
||||
echo " rcp : Build OpenThread RCP (NCP in radio mode) with simulation platform"
|
||||
@@ -51,10 +48,13 @@ display_usage()
|
||||
|
||||
die()
|
||||
{
|
||||
echo " *** ERROR: " $*
|
||||
echo " *** ERROR: " "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
cd "$(dirname "$0")" || die "cd failed"
|
||||
cd ../.. || die "cd failed"
|
||||
|
||||
coverage=no
|
||||
tests=no
|
||||
|
||||
@@ -83,13 +83,13 @@ fi
|
||||
|
||||
build_config=$1
|
||||
|
||||
configure_options=" \
|
||||
--disable-docs \
|
||||
--enable-tests=$tests \
|
||||
--enable-coverage=$coverage \
|
||||
--enable-ftd \
|
||||
--enable-ncp \
|
||||
"
|
||||
configure_options=(
|
||||
"--disable-docs"
|
||||
"--enable-tests=$tests"
|
||||
"--enable-coverage=$coverage"
|
||||
"--enable-ftd"
|
||||
"--enable-ncp"
|
||||
)
|
||||
|
||||
if [ -n "${top_builddir}" ]; then
|
||||
top_srcdir=$(pwd)
|
||||
@@ -104,13 +104,13 @@ case ${build_config} in
|
||||
echo "==================================================================================================="
|
||||
echo "Building OpenThread NCP FTD mode with POSIX platform"
|
||||
echo "==================================================================================================="
|
||||
./bootstrap || die
|
||||
cd "${top_builddir}"
|
||||
./bootstrap || die "bootstrap failed"
|
||||
cd "${top_builddir}" || die "cd failed"
|
||||
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"'
|
||||
${top_srcdir}/configure \
|
||||
CPPFLAGS="$cppflags_config" \
|
||||
--with-examples=simulation \
|
||||
$configure_options || die
|
||||
"${configure_options[@]}" || die
|
||||
make -j 8 || die
|
||||
;;
|
||||
|
||||
@@ -118,8 +118,8 @@ case ${build_config} in
|
||||
echo "===================================================================================================="
|
||||
echo "Building OpenThread RCP (NCP in radio mode) with POSIX platform"
|
||||
echo "===================================================================================================="
|
||||
./bootstrap || die
|
||||
cd "${top_builddir}"
|
||||
./bootstrap || die "bootstrap failed"
|
||||
cd "${top_builddir}" || die "cd failed"
|
||||
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"'
|
||||
${top_srcdir}/configure \
|
||||
CPPFLAGS="$cppflags_config " \
|
||||
@@ -136,13 +136,13 @@ case ${build_config} in
|
||||
echo "===================================================================================================="
|
||||
echo "Building OpenThread POSIX App NCP"
|
||||
echo "===================================================================================================="
|
||||
./bootstrap || die
|
||||
cd "${top_builddir}"
|
||||
./bootstrap || die "bootstrap failed"
|
||||
cd "${top_builddir}" || die "cd failed"
|
||||
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-posix.h\"'
|
||||
${top_srcdir}/configure \
|
||||
CPPFLAGS="$cppflags_config" \
|
||||
--with-platform=posix \
|
||||
$configure_options || die
|
||||
"${configure_options[@]}" || die
|
||||
make -j 8 || die
|
||||
;;
|
||||
|
||||
|
||||
+11
-13
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2018, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
die()
|
||||
{
|
||||
echo " *** ERROR: " $*
|
||||
echo " *** ERROR: " "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -37,16 +37,14 @@ cleanup()
|
||||
{
|
||||
# Clear logs and flash files
|
||||
sudo rm tmp/*.flash tmp/*.data tmp/*.swap >/dev/null 2>&1
|
||||
sudo rm *.log >/dev/null 2>&1
|
||||
sudo rm ./*.log >/dev/null 2>&1
|
||||
|
||||
# Clear any wpantund instances
|
||||
sudo killall wpantund >/dev/null 2>&1
|
||||
|
||||
wpan_interfaces=$(ifconfig 2>/dev/null | grep -o wpan[0-9]*)
|
||||
|
||||
for interface in $wpan_interfaces; do
|
||||
sudo ip link delete $interface >/dev/null 2>&1
|
||||
done
|
||||
while read -r interface; do
|
||||
sudo ip link delete "$interface" >/dev/null 2>&1
|
||||
done < <(ifconfig 2>/dev/null | grep -o "wpan[0-9]*")
|
||||
|
||||
sleep 0.3
|
||||
}
|
||||
@@ -56,7 +54,7 @@ run()
|
||||
counter=0
|
||||
while true; do
|
||||
|
||||
if sudo -E python $1; then
|
||||
if sudo -E python "$1"; then
|
||||
cleanup
|
||||
return
|
||||
fi
|
||||
@@ -76,7 +74,7 @@ run()
|
||||
done
|
||||
}
|
||||
|
||||
cd $(dirname $0)
|
||||
cd "$(dirname "$0")" || die "cd failed"
|
||||
|
||||
if [ "$COVERAGE" = 1 ]; then
|
||||
coverage_option="--enable-coverage"
|
||||
@@ -94,11 +92,11 @@ case $TORANJ_POSIX_RCP_MODEL in
|
||||
esac
|
||||
|
||||
if [ "$use_posix_with_rcp" = "no" ]; then
|
||||
./build.sh ${coverage_option} ncp || die
|
||||
./build.sh ${coverage_option} ncp || die "ncp build failed"
|
||||
|
||||
else
|
||||
./build.sh ${coverage_option} rcp || die
|
||||
./build.sh ${coverage_option} posix || die
|
||||
./build.sh ${coverage_option} rcp || die "rcp build failed"
|
||||
./build.sh ${coverage_option} posix || die "posix build failed"
|
||||
fi
|
||||
|
||||
cleanup
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2018, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
die()
|
||||
{
|
||||
echo " *** ERROR: " $*
|
||||
echo " *** ERROR: " "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ display_usage()
|
||||
echo "By default, the changes are committed with a commit message which includes the list of all squashed commits"
|
||||
echo "(use --no-commit and --no-list options to change default behavior)."
|
||||
echo ""
|
||||
echo "Usage: $(basename $0) [--no-list] [--no-commit] <branch> [<commit msg>]"
|
||||
echo "Usage: $(basename "$0") [--no-list] [--no-commit] <branch> [<commit msg>]"
|
||||
echo ""
|
||||
echo " <branch> Specifies the name of branch to merge into current branch"
|
||||
echo " <commit msg> An optional parameter specifying text to add to the commit message"
|
||||
@@ -69,10 +69,6 @@ while test $# != 0; do
|
||||
;;
|
||||
--debug) set -x ;;
|
||||
--*) die "Unknown argument $1" ;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-*) die "Unknown argument $1" ;;
|
||||
*)
|
||||
break
|
||||
@@ -100,7 +96,7 @@ cur_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
# Note that the list starts with older commits
|
||||
|
||||
if ${SHOULD_ADD_LIST}; then
|
||||
commit_list=$(git log HEAD..$branch --oneline --decorate=no --reverse)
|
||||
commit_list=$(git log HEAD.."$branch" --oneline --decorate=no --reverse)
|
||||
else
|
||||
commit_list=""
|
||||
fi
|
||||
@@ -113,18 +109,17 @@ else
|
||||
commit_msg="${commit_msg_header}${NEWLINE}${NEWLINE}$2${NEWLINE}${NEWLINE}${commit_list}"
|
||||
fi
|
||||
|
||||
git merge --squash $branch 1>/dev/null 2>/dev/null || die "Failed to perform 'git merge -squash $branch'"
|
||||
git merge --squash "$branch" 1>/dev/null 2>/dev/null || die "Failed to perform 'git merge -squash $branch'"
|
||||
|
||||
# Check if there is anything staged
|
||||
git diff --cached --quiet
|
||||
if [ $? -eq 0 ]; then
|
||||
if ! git diff --cached --quiet; then
|
||||
echo "No changes to commit when squash merging branch '$branch' into '$cur_branch'"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ${SHOULD_COMMIT}; then
|
||||
# Commit the staged changes
|
||||
git commit -m "$commit_msg" 1>/dev/null 2>/dev/null || die "git commit failed${NEWLINE}${NEWLINE}$(cat $TMP)"
|
||||
git commit -m "$commit_msg" 1>/dev/null 2>/dev/null || die "git commit failed${NEWLINE}${NEWLINE}$(cat "$TMP")"
|
||||
|
||||
git log -1
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/sh
|
||||
cd $(dirname $0)
|
||||
python -u -m autothreadharness.runner $@
|
||||
cd "$(dirname "$0")" || exit 1
|
||||
python -u -m autothreadharness.runner "$@"
|
||||
|
||||
Reference in New Issue
Block a user