From f227bbe7f24897611e6c33c62575a02722a6c60a Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Thu, 6 Sep 2018 17:16:33 +0800 Subject: [PATCH] [posix-app] fix alarm issue (#3035) --- .travis.yml | 3 +++ .travis/before_install.sh | 4 ++++ .travis/script.sh | 46 ++++++++++++++++++++++++++++++++++++++ src/posix/platform/alarm.c | 11 ++++----- 4 files changed, 59 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 46e557efa..ac815a939 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,6 +53,9 @@ matrix: - env: BUILD_TARGET="posix-app-ncp" VERBOSE=1 VIRTUAL_TIME=1 os: linux compiler: gcc + - env: BUILD_TARGET="posix-app-pty" VERBOSE=1 + os: linux + compiler: gcc - env: BUILD_TARGET="android-build" VERBOSE=1 language: android android: diff --git a/.travis/before_install.sh b/.travis/before_install.sh index dd6b6579f..ce38d4d35 100755 --- a/.travis/before_install.sh +++ b/.travis/before_install.sh @@ -57,6 +57,10 @@ cd /tmp || die clang-format --version || die } + [ $BUILD_TARGET != posix-app-pty ] || { + sudo apt-get install socat expect || die + } + [ $BUILD_TARGET != scan-build ] || { sudo apt-get install clang || die } diff --git a/.travis/script.sh b/.travis/script.sh index e33f666a5..492767589 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -547,6 +547,52 @@ set -x PYTHONUNBUFFERED=1 OT_CLI_PATH="$(pwd)/$(ls output/posix/*/bin/ot-cli)" RADIO_DEVICE="$(pwd)/$(ls output/*/bin/ot-ncp-radio)" COVERAGE=1 make -f src/posix/Makefile-posix check || die } +[ $BUILD_TARGET != posix-app-pty ] || { + ./bootstrap + make -f examples/Makefile-posix + make -f src/posix/Makefile-posix + + SOCAT_OUTPUT=/tmp/ot-socat + 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/.\+') + CORE_PTY=$(head -n2 $SOCAT_OUTPUT | tail -n1 | grep -o '/dev/.\+') + break + fi + echo 'Waiting for socat ready...' + sleep 1 + done + echo 'RADIO_PTY' $DEVICE_PTY + echo 'CORE_PTY' $CORE_PTY + + RADIO_NCP_PATH="$(pwd)/$(ls output/*linux*/bin/ot-ncp-radio)" + $RADIO_NCP_PATH 1 > $RADIO_PTY < $RADIO_PTY & + OT_CLI_PATH="$(pwd)/$(ls output/posix/*linux*/bin/ot-cli)" + + expect <