Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate spec08 and task11, zephyr interop test #295

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions 08-interop/compile_zephyr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Get the directory of this file
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

cd /tmp

mkdir -p zephyrproject

docker run \
--privileged \
-e LOCAL_UID=$(id -u $USER) \
-e LOCAL_GID=$(id -g $USER) \
-v /tmp/zephyrproject:/workdir \
docker.io/zephyrprojectrtos/zephyr-build:latest \
/bin/bash -c '

west init -m https://github.com/zephyrproject-rtos/zephyr --mr 3.5.0
west update cmsis hal_atmel
west zephyr-export
ls ~
pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt

cd /workdir/zephyr
echo "CONFIG_CPP=n

CONFIG_NET_PKT_RX_COUNT=5
CONFIG_NET_PKT_TX_COUNT=5
CONFIG_NET_BUF_RX_COUNT=5
CONFIG_NET_BUF_TX_COUNT=5
CONFIG_NET_MAX_CONTEXTS=2
CONFIG_NET_MAX_CONN=1
CONFIG_NET_MAX_ROUTES=1
CONFIG_NET_MAX_NEXTHOPS=1

CONFIG_SHELL_STACK_SIZE=512
CONFIG_SHELL_CMD_BUFF_SIZE=32
CONFIG_SHELL_ARGC_MAX=6
CONFIG_SHELL_HISTORY_BUFFER=4

CONFIG_LOG_MODE_MINIMAL=y
CONFIG_NET_IP_DSCP_ECN=n
CONFIG_NET_STATISTICS=n
CONFIG_NET_MGMT_EVENT_STACK_SIZE=384
CONFIG_IEEE802154_RF2XX_RX_STACK_SIZE=384

CONFIG_UART_USE_RUNTIME_CONFIGURE=n" > samples/net/sockets/echo_server/boards/atsamr21_xpro.conf
west build -p auto -b atsamr21_xpro samples/net/sockets/echo_server -- -DOVERLAY_CONFIG=overlay-802154.conf
west flash
'
79 changes: 79 additions & 0 deletions 08-interop/test_spec08.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,82 @@ def test_task08(riot_ctrl):
lwip_node.riotctrl.term.expect_exact(
"00000000 " + " ".join(hex(ord(c))[2:] for c in "01234567"), timeout=3
)


# @pytest.mark.flaky(reruns=1, reruns_delay=30)
@pytest.mark.iotlab_creds
# nodes passed to riot_ctrl fixture
@pytest.mark.parametrize(
'nodes', [pytest.param(['iotlab-m3', 'samr21-xpro'])], indirect=['nodes']
)
def test_task11(riot_ctrl):
# run `./compile_contiki.sh` relative to this file
subprocess.check_call(
["./compile_zephyr.sh"],
cwd=os.path.dirname(os.path.realpath(__file__)),
)

build_path = "zephyr/build/zephyr/zephyr.elf"
flashfile = f"/tmp/zephyrproject/{build_path}"

gnrc_node, zephyr_node = (
riot_ctrl(0, GNRC_APP, Shell),
riot_ctrl(
1,
'examples/hello-world',
riotctrl.shell.ShellInteraction,
extras={"skip_flash": "1"},
),
)
zephyr_node.prompt = "uart:~$ "

# gnrc_netif, gnrc_addr = lladdr(gnrc_node.ifconfig_list())

# Get the ipv6 address, expected response:
# IPv6 support : enabled
# IPv6 fragmentation support : disabled
# Multicast Listener Discovery support : enabled
# Neighbor cache support : enabled
# Neighbor discovery support : enabled
# Duplicate address detection (DAD) support : enabled
# Router advertisement RDNSS option support : enabled
# 6lo header compression support : enabled
# Max number of IPv6 network interfaces in the system : 1
# Max number of unicast IPv6 addresses per network interface : 3
# Max number of multicast IPv6 addresses per network interface : 4
# Max number of IPv6 prefixes per network interface : 2

# IPv6 addresses for interface 0x20007d60 (IEEE 802.15.4)
# =======================================================
# Type State Lifetime (sec) Address
# autoconf preferred infinite fe80::d419:100:7ae4:9b3b/128
# manual preferred infinite 2001:db8::1/128
res = zephyr_node.cmd("net ipv6")
match = re.search("fe80::(?P<addr>[0-9a-f:]+)/128", res)
assert match
zephyr_addr = f"fe80::{match[1]}"

# Get the PAN ID, expected response: "PAN ID 43981 (0xabcd)"
res = zephyr_node.cmd("ieee802154 get_pan_id")
match = re.search(r"PAN ID (?P<pan_id>\d+) \(0x(?P<pan_id_hex>[0-9a-f]+)\)", res)
assert match
pan_id = match["pan_id_hex"]

# Get the Channel, expected response: "Channel 26"
res = zephyr_node.cmd("ieee802154 get_chan")
match = re.search(r"Channel (?P<channel>\d+)", res)
assert match
channel = match[1]

gnrc_netif, _ = lladdr(gnrc_node.ifconfig_list())

gnrc_node.ifconfig_set(gnrc_netif, "channel", channel)
gnrc_node.ifconfig_set(gnrc_netif, "pan_id", pan_id)
res = gnrc_node.cmd("udp server start 4242")
assert "udp server start 4242" in res

res = gnrc_node.cmd(f"udp send {zephyr_addr} 4242 \"RIOT Testing!\"")
assert "Success: sent 13 byte" in res

res = zephyr_node.riotctrl.term.readline()
assert "Received and replied with 13 bytes" in res
19 changes: 10 additions & 9 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,16 @@ def ctrl(
# need to access private member here isn't possible otherwise sadly :(
# pylint: disable=W0212
node._application_directory = os.path.join(riotbase, application_dir)
flash_cmd = "flash"
if "BINFILE" in node.env:
flash_cmd = "flash-only"
node.make_run(
[flash_cmd],
check=True,
stdout=None if log_nodes else subprocess.DEVNULL,
stderr=None if log_nodes else subprocess.DEVNULL,
)
if extras and not extras.get("skip_flash", False):
flash_cmd = "flash"
if "BINFILE" in node.env:
flash_cmd = "flash-only"
node.make_run(
[flash_cmd],
check=True,
stdout=None if log_nodes else subprocess.DEVNULL,
stderr=None if log_nodes else subprocess.DEVNULL,
)
if node.env.get("IOTLAB_NODE"):
# reset to prevent at86rf2xx `ifconfig` issue
time.sleep(1)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ pytest-rerunfailures
riotctrl
scapy
paho-mqtt
pyserial
Loading