mirror of
https://github.com/espressif/openthread.git
synced 2026-08-10 04:37:47 +00:00
[tests] add dns client tests (#5049)
This commit is contained in:
@@ -187,6 +187,18 @@ jobs:
|
||||
OT_OPTIONS=-DOT_READLINE=OFF VIRTUAL_TIME=0 NODE_MODE=rcp ./script/test clean build expect
|
||||
- name: Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
- name: Run TUN Mode
|
||||
run: |
|
||||
sudo apt-get install --no-install-recommends -y dnsmasq bind9-host
|
||||
sudo systemctl start dnsmasq
|
||||
host ipv6.google.com 127.0.0.1
|
||||
echo 'listen-address=::1' | sudo tee /etc/dnsmasq.conf
|
||||
echo 0 | sudo tee /proc/sys/net/ipv6/conf/all/disable_ipv6
|
||||
sudo systemctl restart dnsmasq
|
||||
host ipv6.google.com ::1
|
||||
OT_OPTIONS=-DOT_READLINE=OFF OT_NATIVE_IP=1 VIRTUAL_TIME=0 NODE_MODE=rcp ./script/test clean build expect
|
||||
- name: Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
|
||||
multiple-instance:
|
||||
runs-on: ubuntu-18.04
|
||||
|
||||
+20
-5
@@ -41,6 +41,7 @@ readonly COLOR_NONE='\033[0m'
|
||||
|
||||
readonly NODE_MODE="${NODE_MODE:-standalone}"
|
||||
readonly NODE_TYPE="${NODE_TYPE:-sim}"
|
||||
readonly OT_NATIVE_IP="${OT_NATIVE_IP:-0}"
|
||||
readonly THREAD_VERSION="${THREAD_VERSION:-1.1}"
|
||||
readonly VERBOSE="${VERBOSE:-0}"
|
||||
readonly VIRTUAL_TIME="${VIRTUAL_TIME:-1}"
|
||||
@@ -91,6 +92,10 @@ build_posix()
|
||||
options+=("-DOT_POSIX_VIRTUAL_TIME=ON")
|
||||
fi
|
||||
|
||||
if [[ ${OT_NATIVE_IP} == 1 ]]; then
|
||||
options+=("-DOT_PLATFORM_UDP=ON" "-DOT_PLATFORM_NETIF=ON")
|
||||
fi
|
||||
|
||||
OT_CMAKE_BUILD_DIR="${OT_BUILDDIR}/cmake/openthread-posix-${version}" "${OT_SRCDIR}"/script/cmake-build posix "${options[@]}" "${ot_extra_options[@]}"
|
||||
|
||||
if [[ ${version} == "1.2" ]]; then
|
||||
@@ -121,7 +126,7 @@ do_build()
|
||||
|
||||
do_clean()
|
||||
{
|
||||
rm -rfv "${OT_BUILDDIR}"
|
||||
rm -rfv "${OT_BUILDDIR}" || sudo rm -rfv "${OT_BUILDDIR}"
|
||||
}
|
||||
|
||||
do_unit()
|
||||
@@ -164,7 +169,7 @@ do_cert_suite()
|
||||
[[ ! -f fail.log ]] || rm fail.log
|
||||
|
||||
for test_case in "$@"; do
|
||||
rm -rf tmp
|
||||
rm -rf tmp || sudo rm -rf tmp
|
||||
if "${test_case}" &>test.log; then
|
||||
echo -e "${COLOR_PASS}PASS${COLOR_NONE} ${test_case}"
|
||||
pass_count=$((pass_count + 1))
|
||||
@@ -204,15 +209,25 @@ do_expect()
|
||||
if [[ ${NODE_MODE} == rcp ]]; then
|
||||
ot_command="${OT_CLI_PATH}"
|
||||
rcp_command="${RADIO_DEVICE}"
|
||||
test_pattern='posix-*.exp'
|
||||
if [[ ${OT_NATIVE_IP} == 1 ]]; then
|
||||
test_pattern='tun-*.exp'
|
||||
else
|
||||
test_pattern='posix-*.exp'
|
||||
fi
|
||||
else
|
||||
ot_command="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}/examples/apps/cli/ot-cli-ftd"
|
||||
test_pattern='cli-*.exp'
|
||||
fi
|
||||
|
||||
while read -r script; do
|
||||
rm -rf tmp
|
||||
OT_COMMAND="${ot_command}" RCP_COMMAND="${rcp_command}" "${script}" || {
|
||||
sudo rm -rf tmp
|
||||
{
|
||||
if [[ ${OT_NATIVE_IP} == 1 ]]; then
|
||||
OT_COMMAND="${ot_command}" RCP_COMMAND="${rcp_command}" sudo -E "${script}"
|
||||
else
|
||||
OT_COMMAND="${ot_command}" RCP_COMMAND="${rcp_command}" "${script}"
|
||||
fi
|
||||
} || {
|
||||
local exit_code=$?
|
||||
echo -e "${COLOR_FAIL}FAIL${COLOR_NONE} ${script}"
|
||||
exit "${exit_code}"
|
||||
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/expect -f
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
spawn $env(OT_COMMAND) "spinel+hdlc+uart://$env(RCP_COMMAND)?forkpty-arg=1"
|
||||
set timeout 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
send "panid 0xface\n"
|
||||
expect "Done"
|
||||
send "ifconfig up\n"
|
||||
expect "Done"
|
||||
send "thread start\n"
|
||||
expect "Done"
|
||||
sleep 5
|
||||
send "state\n"
|
||||
expect "leader"
|
||||
expect "Done"
|
||||
send "dns resolve ipv6.google.com ::1 53\n"
|
||||
set timeout 2
|
||||
expect "DNS response for ipv6.google.com"
|
||||
expect "Done"
|
||||
send "\x04"
|
||||
expect eof
|
||||
Reference in New Issue
Block a user