[toranj] enable new mode "posix app and RCP" (#3091)

This commit updates `toranj` framework to allow a different mode of
operation where tests are run using posix-app along with an RCP (NCP
in radio only mode) build. This commit also adds a new job for the
new model in travis CI build matrix.
This commit is contained in:
Abtin Keshavarzian
2018-09-24 09:43:19 -10:00
committed by Jonathan Hui
parent 55bf9fc2fe
commit 5fe9038e33
5 changed files with 129 additions and 30 deletions
+3
View File
@@ -157,3 +157,6 @@ matrix:
- env: BUILD_TARGET="toranj-test-framework" VERBOSE=1
os: linux
compiler: gcc
- env: BUILD_TARGET="toranj-test-framework" VERBOSE=1 TORANJ_POSIX_APP_RCP_MODEL=1
os: linux
compiler: gcc
@@ -275,5 +275,31 @@
#define OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL 1
#if OPENTHREAD_RADIO
/**
* @def OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT
*
* Define to 1 if you want to enable software ACK timeout logic.
*
*/
#define OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT 1
/**
* @def OPENTHREAD_CONFIG_ENABLE_SOFTWARE_RETRANSMIT
*
* Define to 1 if you want to enable software retransmission logic.
*
*/
#define OPENTHREAD_CONFIG_ENABLE_SOFTWARE_RETRANSMIT 1
/**
* @def OPENTHREAD_CONFIG_ENABLE_SOFTWARE_CSMA_BACKOFF
*
* Define to 1 if you want to enable software CSMA-CA backoff logic.
*
*/
#define OPENTHREAD_CONFIG_ENABLE_SOFTWARE_CSMA_BACKOFF 1
#endif // OPENTHREAD_RADIO
#endif /* OPENTHREAD_CORE_TORANJ_CONFIG_H_ */
+76 -26
View File
@@ -53,7 +53,7 @@ run() {
counter=0
while true; do
if sudo python $1; then
if sudo -E python $1; then
cleanup
return
fi
@@ -78,41 +78,91 @@ run() {
cd $(dirname $0)
cd ../..
# Build OpenThread posix mode with required configuration
# On Travis CI, the $BUILD_TARGET is defined as "toranj-test-framework".
if [ "$BUILD_TARGET" = "toranj-test-framework" ]; then
coverage=yes
else
coverage=no
fi
./bootstrap || die
./configure \
CPPFLAGS='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config.h\"' \
--enable-coverage=${coverage} \
--enable-ncp \
--with-ncp-bus=uart \
--enable-border-router \
--enable-child-supervision \
--enable-diag \
--enable-ftd \
--enable-jam-detection \
--enable-legacy \
--enable-mac-filter \
--enable-service \
--enable-channel-monitor \
--enable-channel-manager \
--enable-commissioner \
--with-examples=posix \
--disable-docs \
--disable-tests || die
case $TORANJ_POSIX_APP_RCP_MODEL in
1|yes)
use_posix_app_with_rcp=yes
;;
*)
use_posix_app_with_rcp=no
;;
esac
make -j 8 || die
configure_options=" \
--disable-docs \
--disable-tests \
--enable-border-router \
--enable-channel-manager \
--enable-channel-monitor \
--enable-child-supervision \
--enable-commissioner \
--enable-coverage=$coverage \
--enable-diag \
--enable-ftd \
--enable-jam-detection \
--enable-legacy \
--enable-mac-filter \
--enable-ncp \
--enable-service \
--with-ncp-bus=uart \
"
# Run all the tests
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config.h\"'
if [ "$use_posix_app_with_rcp" = "no" ]; then
echo "==================================================================================================="
echo "Building OpenThread NCP FTD mode with POSIX platform"
echo "==================================================================================================="
./bootstrap || die
./configure \
CPPFLAGS="$cppflags_config" \
--with-examples=posix \
$configure_options || die \
make -j 8 || die
else
echo "===================================================================================================="
echo "Building OpenThread RCP (NCP in radio mode) with POSIX platform"
echo "===================================================================================================="
./bootstrap || die
./configure \
CPPFLAGS="$cppflags_config" \
--enable-coverage=${coverage} \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--with-examples=posix \
--disable-docs \
--disable-tests || die
make -j 8 || die
echo "===================================================================================================="
echo "Building OpenThread POSIX App NCP"
echo "===================================================================================================="
./bootstrap || die
./configure \
CPPFLAGS="$cppflags_config -DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=1" \
--enable-posix-app \
$configure_options || die \
make -j 8 || die
fi
cd tests/toranj
cleanup
run test-001-get-set.py
@@ -80,8 +80,8 @@ chan_15_to_17_mask = int('0x0038000', 0)
node.set(wpan.WPAN_CHANNEL_MANAGER_SUPPORTED_CHANNEL_MASK, str(all_channls_mask))
verify(int(node.get(wpan.WPAN_CHANNEL_MANAGER_SUPPORTED_CHANNEL_MASK), 0) == all_channls_mask)
# Sleep for 4 second with speedup factor of 10,000 this is more than 11 hours.
time.sleep(4)
# Sleep for 4.5 second with speedup factor of 10,000 this is more than 12 hours.
time.sleep(4.5)
verify(int(node.get(wpan.WPAN_CHANNEL_MONITOR_SAMPLE_COUNT), 0) > 970)
+22 -2
View File
@@ -28,6 +28,7 @@
#
import sys
import os
import time
import re
import random
@@ -207,11 +208,19 @@ class Node(object):
_VERBOSE = False # defines the default verbosity setting (can be changed per `Node`)
_SPEED_UP_FACTOR = 1 # defines the default time speed up factor
# path to `wpantund`, `wpanctl` and `ot-ncp-ftd` code
# path to `wpantund`, `wpanctl`, `ot-ncp-ftd`,`ot-ncp` and `ot-ncp-radio`
_WPANTUND = '/usr/local/sbin/wpantund'
_WPANCTL = '/usr/local/bin/wpanctl'
_OT_NCP_FTD = '../../examples/apps/ncp/ot-ncp-ftd'
_OT_NCP_FTD_POSIX_APP = '../../src/posix/ot-ncp'
_OT_NCP_RADIO = '../../examples/apps/ncp/ot-ncp-radio'
# Environment variable used to determine how to run OpenThread
# If set to 1, then posix-app (`ot-ncp`) is used along with a posix RCP `ot-ncp-radio`.
# Otherwise, the posix NCP `ot-ncp-ftd` is used
_POSIX_APP_ENV_VAR = 'TORANJ_POSIX_APP_RCP_MODEL'
_TUND_LOG_TO_FILE = True # determines if the wpantund logs are saved in file or sent to stdout
_TUND_LOG_FNAME = 'wpantund-logs' # name of wpantund log file (if # name of wpantund _TUND_LOG_TO_FILE is True)
@@ -232,7 +241,18 @@ class Node(object):
self._interface_name = self._INTFC_NAME_PREFIX + str(index)
self._verbose = verbose
ncp_socket_path = 'system:{} {} {}'.format(self._OT_NCP_FTD, index, self._SPEED_UP_FACTOR)
# Check if env variable `TORANJ_POSIX_APP_RCP_MODEL` is defined
# and use it to determine if to use operate in "posix-ncp-app".
if self._POSIX_APP_ENV_VAR in os.environ:
use_posix_app_with_rcp = (os.environ[self._POSIX_APP_ENV_VAR] in ['1', 'yes'])
else:
use_posix_app_with_rcp = False
if use_posix_app_with_rcp:
ncp_socket_path = 'system:{} -s {} {} {}'.format(self._OT_NCP_FTD_POSIX_APP, self._SPEED_UP_FACTOR,
self._OT_NCP_RADIO, index)
else:
ncp_socket_path = 'system:{} {} {}'.format(self._OT_NCP_FTD, index, self._SPEED_UP_FACTOR)
cmd = self._WPANTUND + \
' -o Config:NCP:SocketPath \"{}\"'.format(ncp_socket_path) + \