def test_pktbuf_not_empty(): ctrl = init_ctrl(output=""" packet buffer: first byte: 0x5660dce0, last byte: 0x5660fce0 (size: 8192) position of last byte used: 1792 ~ unused: 0x5660de00 (next: (nil), size: 7904) ~""") shell = riotctrl_shell.gnrc.GNRCPktbufStats(ctrl) pktbuf_res = testutils.shell.pktbuf(shell) assert pktbuf_res assert not pktbuf_res.is_empty()
def test_gnrc_lorawan_send_fail(): LORAWAN_FAIL_TO_SEND = """ send 3 "Hello RIOT!" 4 Error sending packet: (status: -116) """ ctrl = init_ctrl(output=LORAWAN_FAIL_TO_SEND) shell = testutils.shell.GNRCLoRaWANSend(ctrl) with pytest.raises(RuntimeError) as error: shell.send(3, "Hello RIOT!") assert str(error.value) == LORAWAN_FAIL_TO_SEND
def test_lorawan_netif_no_lorawan(): ctrl = init_ctrl(output=""" ifconfig Iface 3 HWaddr: 26:01:24:C0 Frequency: 869524963Hz BW: 125kHz SF: 12 CR: 4/5 Link: up TX-Power: 14dBm State: SLEEP Demod margin.: 0 Num gateways.: 0 IQ_INVERT RX_SINGLE OTAA L2-PDU:2559 """) # noqa: E501 shell = riotctrl_shell.netif.Ifconfig(ctrl) res = testutils.shell.lorawan_netif(shell) assert res == 3
def test_gnrc_lorawan_send_success_downlink(): ctrl = init_ctrl(output=""" send 3 "Hello RIOT!" 2 PKTDUMP: data received: ~~ SNIP 0 - size: 4 byte, type: NETTYPE_LORAWAN (1) 00000000 AA AA AA AA ~~ PKT - 1 snips, total size: 4 byte Successfully sent packet """) shell = testutils.shell.GNRCLoRaWANSend(ctrl) res = shell.send(3, "Hello RIOT!") assert res is True
def test_ping6(): ctrl = init_ctrl(output=""" 12 bytes from ::1: icmp_seq=0 ttl=64 12 bytes from ::1: icmp_seq=1 ttl=64 12 bytes from ::1: icmp_seq=2 ttl=64 --- ::1 PING statistics --- 3 packets transmitted, 3 packets received, 0% packet loss""") shell = riotctrl_shell.gnrc.GNRCICMPv6Echo(ctrl) ping_res = testutils.shell.ping6(shell, "ff02::1", 3, 4, 1000) assert ping_res assert len(ping_res["replies"]) == 3 assert ping_res["stats"]["packet_loss"] == 0
def test_lorawan_netif_None(): ctrl = init_ctrl(output=""" ifconfig Iface 7 HWaddr: 76:F5:98:9F:40:22 L2-PDU:1500 MTU:1500 HL:64 RTR Source address length: 6 Link type: wired inet6 addr: fe80::74f5:98ff:fe9f:4022 scope: link VAL inet6 addr: fe80::2 scope: link VAL inet6 group: ff02::2 inet6 group: ff02::1 inet6 group: ff02::1:ff9f:4022 inet6 group: ff02::1:ff00:2 """) shell = riotctrl_shell.netif.Ifconfig(ctrl) res = testutils.shell.lorawan_netif(shell) assert res is None
def test_udp_client_send(dest_addr, port, payload, count, delay_ms, expected): ctrl = init_ctrl() shell = testutils.shell.GNRCUDP(ctrl) res = shell.udp_client_send(dest_addr, port, payload, count, delay_ms) # mock just returns last input assert res == expected
def test_udp_server_stop(): ctrl = init_ctrl() shell = testutils.shell.GNRCUDP(ctrl) res = shell.udp_server_stop() # mock just returns last input assert res == "udp server stop"
def test_udp_server_start_error(): ctrl = init_ctrl() shell = testutils.shell.GNRCUDP(ctrl) with pytest.raises(RuntimeError): shell.udp_server_start(1337) assert ctrl.term.last_command == "udp server start 1337"
def test_udp_server_start(): ctrl = init_ctrl(output="Success: server was started") shell = testutils.shell.GNRCUDP(ctrl) res = shell.udp_server_start(1337) assert res.startswith("Success:") assert ctrl.term.last_command == "udp server start 1337"
def test_udp_client_send_error(): ctrl = init_ctrl(output="Error: we don't want to send") shell = testutils.shell.GNRCUDP(ctrl) with pytest.raises(RuntimeError): shell.udp_client_send("ff02::1", 1337, 10, 1000, 1000)
def test_pktbuf_not_empty(): ctrl = init_ctrl(output=STRING_PKTBUF_NOT_EMPTY) shell = riotctrl_shell.gnrc.GNRCPktbufStats(ctrl) pktbuf_res = testutils.shell.pktbuf(shell) assert pktbuf_res assert not pktbuf_res.is_empty()