#!/bin/bash # # Copyright (c) 2020, The OpenThread Authors. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Test build and run otbr dbus server # set -euxo pipefail readonly OTBR_DBUS_SERVER_CONF=otbr-test-agent.conf on_exit() { local status=$? sudo killall otbr-agent || true sudo killall expect || true sudo killall ot-cli-ftd || true sudo killall ot-cli-mtd || true sudo killall dbus-monitor || true sudo rm "/etc/dbus-1/system.d/${OTBR_DBUS_SERVER_CONF}" || true grep -iE 'ot-cli|otbr' "${temp_dir}/dbus.out" & sleep 1 sudo "${CMAKE_BINARY_DIR}"/src/agent/otbr-agent -d7 -I wpan0 "spinel+hdlc+forkpty://$(command -v ot-rcp)?forkpty-arg=1" & if ! (tail -f "${temp_dir}/dbus.out" &) | timeout 10s grep -q Ready; then cat "${temp_dir}/dbus.out" exit 1 fi sleep 5 local ot_version local rcp_version local thread_version ot_version=$(sudo "${CMAKE_BINARY_DIR}"/third_party/openthread/repo/src/posix/ot-ctl version | grep -oE '^OPENTHREAD.*$' | tr -d '\r\n') rcp_version=$(sudo "${CMAKE_BINARY_DIR}"/third_party/openthread/repo/src/posix/ot-ctl rcp version | grep -oE '^OPENTHREAD.*$' | tr -d '\r\n') thread_version=$(sudo "${CMAKE_BINARY_DIR}"/third_party/openthread/repo/src/posix/ot-ctl thread version | grep -oE '^[0-9]+' | tr -d '\r\n') local property_names="array:string:" property_names+="OtHostVersion," property_names+="OtRcpVersion," property_names+="ThreadVersion," property_names+="Uptime," property_names+="RadioCoexMetrics," property_names+="RadioSpinelMetrics," property_names+="RcpInterfaceMetrics" local result_pattern="\s+variant\s+string\s+\"${ot_version}\"" result_pattern+="\s+variant\s+string\s+\"${rcp_version}\"" result_pattern+="\s+variant\s+uint16\s+${thread_version}" result_pattern+="\s+variant\s+uint64\s+\d+" # Uptime result_pattern+="\s+variant\s+struct\s+{(\s+uint32\s+\d+){18}\s+boolean\s+(true|false)\s+}" # RadioCoexMetrics result_pattern+="\s+variant\s+struct\s+{(\s+uint32\s+\d+){4}\s+}" # RadioSpinelMetrics result_pattern+="\s+variant\s+struct\s+{\s+byte\s+\d+(\s+uint64\s+\d+){7}\s+}" # RcpInterfaceMetrics sudo dbus-send --system --dest=io.openthread.BorderRouter.wpan0 --print-reply \ /io/openthread/BorderRouter/wpan0 \ io.openthread.BorderRouter.GetProperties \ "${property_names}" \ | grep -oPz "${result_pattern}" sudo "${CMAKE_BINARY_DIR}"/third_party/openthread/repo/src/posix/ot-ctl ifconfig up sudo "${CMAKE_BINARY_DIR}"/third_party/openthread/repo/src/posix/ot-ctl thread start sleep 12 update_meshcop_txt_and_check sudo "${CMAKE_BINARY_DIR}"/third_party/openthread/repo/src/posix/ot-ctl factoryreset sleep 1 sudo dbus-send --system --dest=io.openthread.BorderRouter.wpan0 \ --type=method_call --print-reply /io/openthread/BorderRouter/wpan0 \ org.freedesktop.DBus.Introspectable.Introspect | grep JoinerStart (sudo dbus-send --system --dest=io.openthread.BorderRouter.wpan0 \ --type=method_call --print-reply /io/openthread/BorderRouter/wpan0 \ io.openthread.BorderRouter.JoinerStart \ string:ABCDEF string:mock string:mock \ string:mock string:mock string:mock 2>&1 || true) | grep NotFound # Verify Eui64 property. 0x18b4300000000001 = 1780100529276321793 sudo dbus-send --system --dest=io.openthread.BorderRouter.wpan0 --print-reply /io/openthread/BorderRouter/wpan0 org.freedesktop.DBus.Properties.Get string:io.openthread.BorderRouter string:Eui64 \ | grep '1780100529276321793' # The ot-cli-ftd node is used to test Thread attach. expect <