Commit graph

1725 commits

Author SHA1 Message Date
Hu Zhenyu b962074a68 tests: net: socket: tls move to new ztest API
Move net/socket/tls tests to use new ztest API
TEST=twister -T tests/net/socket/tls

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-08-18 12:36:20 +02:00
Neil Armstrong 95c863e0f6 tests: net: lib: tls_credentials: Add tfm_trusted test
This enables the Trusted TLS Credentials Protected Storage
backend for this test.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2022-08-18 12:33:07 +02:00
Neil Armstrong 0690693d8f tests: tls_credentials: fix test
Fix test to not assume anymore that:
- credential iteration buffer has the same pointer as the buffer
  used in credential_add, now compare the length & content.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2022-08-18 12:33:07 +02:00
Henrik Brix Andersen 27eb12ed48 net: socketcan: decouple SocketCAN and CAN controller headers
Decouple the zephyr/net/socketcan.h and zephyr/drivers/can.h header files
by moving the SocketCAN utilities to their own header.

This is preparation for including the SocketCAN types defined in
socketcan.h in a native posix (Linux) SocketCAN driver context without name
clashes.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen ef1e492032 net: socketcan: SocketCAN supports classic CAN, not CAN-FD
SocketCAN does not support CAN-FD data lengths of up to 64 bytes
payload. Decouple the maximum supported SocketCAN data length from the
maximum supported CAN controller data length.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen d1d48e8304 net: socketcan: rename SocketCAN header from socket_can.h to socketcan.h
Rename the SocketCAN header from socket_can.h to socketcan.h to better
match the naming of the functionality.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen b40a8cb9fd net: socket: can: rename utility functions
Rename the SocketCAN utility functions to reflect the new naming of the CAN
controller API and SocketCAN API data types.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen 13c75417ba drivers: can: remove z prefix from public CAN API types
Remove the "z" prefix from the public CAN controller API types as this
makes them appear as internal APIs.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen d159947443 net: socket: can: prepend SocketCAN data types with socketcan
Rename the SocketCAN data types to "socketcan_*" in preparation of renaming
the low-level CAN controller API data types.

This breaks the naming compatibility with the similar SocketCAN data types
from the Linux kernel, but Zephyr and Linux SocketCAN are not 100%
compatible anyways (only the structure fields are compatible, extended
functionality such filtering, error reporting etc. are not).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen 6099e180b1 tests: move the SocketCAN tests to tests/net/socket/can
Move the SocketCAN tests from tests/drivers/can/utilities to
tests/net/socket/can to match the location of the code under test.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Hu Zhenyu f2077888a2 tests: net: virtual: move to new ztest API
Move net/virtual tests to use new ztest API
TEST=twister -T tests/net/virtual

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-08-15 08:13:15 +00:00
Kumar Gala 6124ccfccf drivers: ethernet: provide Kconfig means to disable ethernet drivers
There are several test cases that create fake ethernet devices and
expect the fake device to be the only ethernet device enabled.  Some
tests handle this be explicitly disabling actual ethernet drivers,
but this doesn't scale well.

Change drivers/ethernet/Kconfig to utilze a menuconfig option that
wraps all the drivers.  This allows us for those test cases that
don't want any actual ethernet drivers to disable them with a
simple CONFIG_ETH_DRIVER=n.

Note, the fake ethernet devices utilize CONFIG_ETH_INIT_PRIORITY so
we have it outside of the 'if ETH_DRIVER' block.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-12 11:33:43 +02:00
Xiao Song c35f1f977d tests: net: lib: move dns_addremove to new ztest API
Move tests/net/lib/dns_addremove/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-08-10 16:11:46 +02:00
Gerard Marull-Paretas b74a22924e net: lib: config: remove NET_CONFIG_IEEE802154_DEV_NAME
Remove NET_CONFIG_IEEE802154_DEV_NAME in favor of DT based choice using
zephyr,ieee802154.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-10 11:57:34 +02:00
Gerard Marull-Paretas f1e059a3e5 tests: net: ieee802154: use native_posix
All IEEE 802.15.4 tests use internal fake devices, so use native_posix
platform to run them as they are not meant to test IEEE 802.15.4 on
hardware.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-10 11:57:34 +02:00
Robert Lubos 3eaf55a364 tests: net: socket: Disable unstable tests for mps2_an385
Disable unstable tests cases for mps2_an385, which fail sporadically
due to timer stability issues on that platform (see #48608).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-08 22:18:23 +09:00
Martí Bolívar 4583ebe50d tests: net: socket: adjust fudge factors
Loosen some timing constraints in order to hack arond spurious
failures in upstream Zephyr's CI while working on an unrelated task.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-08 10:44:41 +02:00
Florian Grandel dcb2ead52c net: l2: ieee802154: rename *fragment to *6lo_fragment
6LoWPAN fragmentation is not related to IEEE 802.15.4 proper but is just
part of its IPv6-specific L3-adaptation layer. To make this more obvious
we rename all resources related to 6LoWPAN fragmentation.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-04 13:44:06 +02:00
Florian Grandel 2e5e761074 net: l2: ieee802154: decouple L2/L3 concerns
This change decouples the IEEE 802.15.4 (L2) layer from all IPv6 (L3)
concerns.

Applications may now choose to set CONFIG_NET_6LO=n and
CONFIG_NET_L2_IEEE802154=y at the same time.

Setting CONFIG_NET_6LO=n will build a vanilla IEEE 802.15.4-2006 specs
compliant L2 layer without any reference to 6LoWPAN or IPv6. This allows
application developers to design custom non-IP protocols on top of
IEEE 802.15.4-2006 and thereby makes the L2 layer much more re-usable.

Fixes #48585.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-04 13:44:06 +02:00
Gerard Marull-Paretas e6a345f967 drivers: ieee802154: uart_pipe: make driver DT-based
Use Devicetree to describe the UART UPIPE IEEE 802.15.4 driver. This
allows to remove usage of IEEE802154_UPIPE_DRV_NAME in preparation for
the removal of NET_CONFIG_IEEE802154_DEV_NAME.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-04 13:25:35 +02:00
Gerard Marull-Paretas 2df965f490 drivers: ieee802154: nrf5: make driver DT-based
Use Devicetree to describe the radio and IEEE 802.15.4. This allows to
remove usage of IEEE802154_NRF5_DRV_NAME in preparation for the
removal of NET_CONFIG_IEEE802154_DEV_NAME.

All SoC files have been updated with the addition of an ieee802154 node
(disabled and only on those SoCs that define ieee802154-supported. The
peripheral has been enabled in the nRF52840DK board (used for testing
ieee802154).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-04 13:25:35 +02:00
Gerard Marull-Paretas 7d5272db62 drivers: ieee802154: kw41z: make driver DT-based
Use Devicetree to describe the radio and IEEE 802.15.4. This allows to
remove usage of IEEE802154_KW41Z_DRV_NAME in preparation for the removal
of NET_CONFIG_IEEE802154_DEV_NAME.

KW41Z files have been updated with the addition of radio and an
ieee802154 nodes The peripheral has been enabled in the frdm_k41z board
(used for testing ieee802154).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-04 13:25:35 +02:00
Gerard Marull-Paretas dc0728fb2a drivers: ieee802154: cc2520: drop IEEE802154_CC2520_CRYPTO_DRV_NAME
The crypto driver is used internally, so there's no real need to expose
its name as a Kconfig option. Just drop it in favor of a plain string
with the same previous value.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-04 13:25:35 +02:00
Gerard Marull-Paretas 1ff6577e30 drivers: ieee802154: cc1200: make driver DT-based
Use Devicetree to describe the radio and IEEE 802.15.4. This allows to
remove usage of IEEE802154_CC1200_DRV_NAME in preparation for the removal
of NET_CONFIG_IEEE802154_DEV_NAME.

In this case, the driver already had bindings, however, it was still
using NET_DEVICE_INIT.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-04 13:25:35 +02:00
Stephanos Ioannidis 815b974382 tests: net: socket: tcp: Disable preempt test for mps2_an385
This commit disables the `net.socket.tcp.preempt` test on the
`mps2_an385` platform because it fails very frequently due to the
system timer stability issues.

For more details, refer to the issue zephyrproject-rtos/zephyr#48608.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-03 08:56:28 -04:00
Fabio Baltieri def230187b test: fix more legacy #include paths
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00
Xiao Song dd1eac6602 tests: net: lib: move mqtt_packet to new ztest API
Move tests/net/lib/mqtt_packet/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-08-01 17:59:57 +02:00
Sjors Hettinga fafcbf59b9 net: tcp: Implement randomized retransmission timeouts
It can happen that two similar stacks enter a retransmission cycle
due to a packet collision. If the transmission timeout is the same
both stacks will retry at the same moment resulting in another
collision.

By introducing a randomized retry timeout, the chance of
a second collision is reduced and it reduces furter the more
retransmissions occur.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-08-01 10:33:24 +02:00
Sjors Hettinga ea4f10fc58 net: tcp: Basic exponential backoff implementation
Apply an exponentially increasing wait time between tcp retries. This
is a good balance between reacting fast to single lost packets and reduce
the network load when an outage takes a little longer. It also allows the
connection to survive a longer interruption with less retransmissions.

Update the test to accommodate for the increased socket closure timeout

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-08-01 10:33:24 +02:00
Sjors Hettinga a0ca04b893 net: tcp: Explicitly wait for context closure instead of simply waiting
Previously the test waited for the worst case time till all sockets
where closed, this causes the test to wait for a long unnecessary time.
Secondly it does not ensure the sockets are actually closed before
starting the next tests.

For tests that are not conducted in user mode, wait until all the contexts
are close for a maximum time. If the contexts are not closed in time raise
an explicit assertion.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-08-01 10:33:24 +02:00
Hu Zhenyu 4f6011c981 tests: net: vlan: move to new ztest API
Move vlan tests to use new ztest API
TEST=twister -T tests/net/vlan

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 11:05:10 -04:00
Hu Zhenyu 8090fa3b33 tests: net: socket: select move to new ztest API
Move net/socket/select tests to use new ztest API
TEST=twister -T tests/net/socket/select

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:51:16 -04:00
Hu Zhenyu 74fdc04234 tests: net: socket: register: move to new ztest API
Move net/socket/register tests to use new ztest API
TEST=twister -T tests/net/socket/register

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:51:02 -04:00
Hu Zhenyu 79c68eb783 tests: net: socket: poll move to new ztest API
Move net/socket/poll tests to use new ztest API
TEST=twister -T tests/net/socket/poll

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:50:50 -04:00
Hu Zhenyu f40e50f519 tests: net: socket: net_mgmt move to new ztest API
Move net_mgmt tests to use new ztest API
TEST=twister -T tests/net/socket/net_mgmt

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:50:18 -04:00
Hu Zhenyu 8b39587f23 tests: net: socket: getnameinfo: move to new ztest API
Move getnameinfo tests to use new ztest API
TEST=twister -T tests/net/socket/getnameinfo

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:49:59 -04:00
Hu Zhenyu 2ff8588cd3 tests: net: socket: getaddrinfo: move to new ztest API
Move getaddrinfo tests to use new ztest API
TEST=twister -T tests/net/socket/getaddrinfo

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:49:45 -04:00
Hu Zhenyu 7bc775c479 tests: net: socket: af_packet_ipproto_raw move to new ztest API
Move af_packet_ipproto_raw tests to use new ztest API
TEST=twister -T tests/net/socket/af_packet_ipproto_raw/

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:49:28 -04:00
Xiao Song befcf017ea tests: net: checksum_offload: move to new ztest API
Move tests/net/checksum_offload/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-28 10:32:42 -04:00
Xiao Song e6049662ee tests: net: lib: move http_header_fields to new ztest API
Move tests/net/lib/http_header_fields/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-28 10:32:07 -04:00
Xiao Song 741dffa786 tests: net: lib: move dns_sd to new ztest API
Move tests/net/lib/dns_sd/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-28 10:31:25 -04:00
Xiao Song f87d13ffe8 tests: net: lib: move dns_resolve to new ztest API
Move tests/net/lib/dns_resolve/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-28 10:30:58 -04:00
Xiao Song 162fc5cdf7 tests: net: lib: move dns_packet to new ztest API
Move tests/net/lib/dns_packet/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-28 10:30:09 -04:00
Xiao Song 197969b3df tests: net: ipv6_fragment: move to new ztest API
Move tests/net/ipv6_fragment/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-28 10:29:36 -04:00
Hu Zhenyu ada34a250e tests: net: socket: move to new ztest API
Move net tests to use new ztest API
TEST=twister -T tests/net/socket/af_packet

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-27 18:47:21 +02:00
Hu Zhenyu 4fd935b6ef test: Update the new ZTEST APIs tests/net/socket/misc
TEST=twister -T tests/net/socket/misc

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-25 11:08:26 -04:00
Hu Zhenyu de40c4e986 test: Update the new ZTEST APIs tests/net/shell
TEST=twister -T tests/net/shell

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-21 13:57:47 +00:00
Kumar Gala e99652b67d drivers: ieee802154: cc2520: Convert to DEVICE_DT_INST_DEFINE
Move driver to use {NET_}DEVICE_DT_INST_DEFINE.  This lets us
remove the IEEE802154_CC2520_DRV_NAME Kconfig symobl.

We also update the ieee802154 build_all test to actually enable
the CC2520 driver.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 10:32:21 +02:00
Xiao Song 2218cb1094 tests: net: lib: move coap to new ztest API
Move tests/net/lib/coap/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-19 10:30:06 +02:00
Tomislav Milkovic 0fe2c1fe90 everywhere: Fix legacy include paths
Any project with Kconfig option CONFIG_LEGACY_INCLUDE_PATH set to n
couldn't be built because some files were missing zephyr/ prefix in
includes
Re-run the migrate_includes.py script to fix all legacy include paths

Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
2022-07-18 16:16:47 +00:00
Xiao Song 1f414faf58 tests: net: ip-addr: move to new ztest API
Move tests/net/ip-addr to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-14 10:40:19 +02:00
romain pelletant 3908b9dc74 net: lwm2m: Add Event Log object
Event Log object (ID:20) from OMA LwM2M support added

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2022-07-13 10:19:26 +02:00
Xiao Song 0b73446c5d tests: net: ieee802154: move l2 to new ztest API
Move tests/net/ieee802154/l2/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-12 12:26:16 +02:00
Xiao Song ec3a208f87 tests: net: ieee802154: move fragment to new ztest API
Move tests/net/ieee802154/fragment/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-12 12:26:16 +02:00
Xiao Song e19544a7c0 tests: net: ieee802154: move custom_l2 to new ztest API
Move tests/net/ieee802154/custom_l2/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-12 12:26:16 +02:00
Xiao Song eda0bef213 tests: net: hostname: move to new ztest API
Move tests/net/hostname/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-11 11:06:42 +02:00
Xiao Song 4d500f8f49 tests: net: bridge: move to new ztest API
Move tests/net/bridge/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-08 11:59:02 +02:00
Hu Zhenyu 7bfbbf5221 test: Update the new ZTEST APIs tests/net/ptp
TEST=twister -T tests/net/ptp

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-08 10:58:24 +02:00
Hu Zhenyu a2b49ec10c test: Update the new ZTEST APIs tests/net/promiscuous
TEST=twister -T tests/net/promiscuous

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-08 10:58:24 +02:00
Hu Zhenyu 21092ae367 test: Update the new ZTEST APIs tests/net/ppp
TEST=twister -T tests/net/ppp

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-08 10:58:24 +02:00
Hu Zhenyu aa3cb29b9e test: Update the new ZTEST APIs tests/net/pm
TEST=twister -T tests/net/pm

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-08 10:58:24 +02:00
Hu Zhenyu 1f09e66060 test: Update the new ZTEST APIs tests/net/npf
TEST=twister -T tests/net/npf

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-08 10:58:24 +02:00
Hu Zhenyu 42901b58ba test: Update the new ZTEST APIs tests/net/net_pkt
TEST=twister -T tests/net/net_pkt

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-08 10:58:24 +02:00
Hu Zhenyu 0aabf5942e test: Update the new ZTEST APIs tests/net/neighbor
TEST=twister -T tests/net/neighbor

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-08 10:58:24 +02:00
Hu Zhenyu 29b419b8bc test: Update the new ZTEST APIs tests/net/mld
TEST=twister -T tests/net/mld

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-08 10:58:24 +02:00
Hu Zhenyu 3c7387050c test: Update the new ZTEST APIs tests/net/mgmt
TEST=twister -T tests/net/mgmt # Only build

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-08 10:58:24 +02:00
Hu Zhenyu 2aa1890dfb test: Update the new ZTEST APIs tests/net/route_mcast
TEST=twister -T tests/net/route_mcast

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-08 09:37:02 +02:00
Hu Zhenyu 512ffec795 test: Update the new ZTEST APIs tests/net/route
TEST=twister -T tests/net/route

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-08 09:37:02 +02:00
Xiao Song 0c6210c2e0 tests: net: icmpv6: move to new ztest API
Move tests/net/icmpv6/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-07 15:13:08 +02:00
Anas Nashif 02f2896586 tests: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
Xiao Song 1f4db6fc90 tests: net: arp: move to new ztest API
Move tests/net/arp/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-06 11:11:47 +02:00
Andreas Chmielewski 363e2f3014 net: coap: make coap vars configurable
COAP_DEFAULT_MAX_RETRANSMIT and COAP_DEFAULT_ACK_RANDOM_FACTOR
should be configurable to determine the max transmission
timeout of a CoAP packet.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2022-07-05 21:56:34 +00:00
Xiao Song f10f900f10 tests: net: dhcpv4: move to new ztest API
Move tests/net/dhcpv4/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-05 11:13:24 -04:00
Xiao Song 3e40c590f8 tests: net: all: move to new ztest API
Move tests/net/all/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-05 12:17:32 +00:00
Xiao Song 257717ce83 tests: net: 6lo: move to new ztest API
Move tests/net/6lo/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-05 12:17:19 +00:00
Xiao Song 2c8841ac02 tests: net: buf: move to new ztest API
Move tests/net/buf/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-05 10:08:09 +02:00
Xiao Song 64981940c2 tests: net: udp: move to new ztest API
Move tests/net/udp/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-01 17:59:07 +00:00
Andrei Emeltchenko 30be920bd6 tests: net: socket: Add missing return code check
Add missing check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-30 10:34:40 +02:00
Andrei Emeltchenko 6360f75d0c tests: net: socket: Fix checking wrong variable
Check return code instead of parameter.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-30 10:34:40 +02:00
Krzysztof Chruscinski 041f0e5379 all: logging: Remove log_strdup function
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 13:42:23 +02:00
Marcin Niestroj 994f6c8630 tests: net: sockets: tls: increase ztest and sysworkq stack sizes
Increase threads stack sizes from 2k to 3k, so that it will pass without
stack overflow on qemu_x86 platform when SHA384 support will be reenabled.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-15 09:11:09 +02:00
Markus Rekdal 071a017b18 net: lwm2m: Add SenML CBOR content writer tests
This will add unit tests for the SenML CBOR content encoder/decoder

Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
2022-06-09 11:32:01 +02:00
Juha Heiskanen 2da8df8b7e net: lwm2m: Integrate JSON lib to LwM2M 1.0 JSON
Integrated updated JSON library to LwM2M 1.0 JSON.
Removed Old Json format default choice.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-06-06 12:06:43 +02:00
Andriy Gelman d67a130368 tests: net: Check leaks when appending frags to a cloned packet
This test checks that new frags appended to a cloned packet are properly
freed.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2022-06-05 14:29:19 +02:00
Andriy Gelman f119a368a2 tests: net: Add test to detect leak in pkt shallow clone
Checks that taking a shallow of a packet does not leak buffers after the
packet and its clone are unreffed.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2022-06-05 14:29:19 +02:00
Markus Rekdal 30dfcec45f net: lwm2m: Add raw CBOR content writer tests
Add unit tests for raw CBOR content encoder/decoder.

Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
2022-06-05 14:27:39 +02:00
Marcin Niestroj c4bd3f1e38 tests: net: socket: udp: verify that sent DGRAM was not fragmented
Datagrams should either be fully sent or not sent at all if networking
buffers or network interface MTU does not allow that.

Verify that by trying to send MTU+1 bytes in case of IPv4 (as IP level
fragmentation is not implemented) and IPv6 (should fail when IPv6
fragmentation support is not enabled and succeed otherwise). In case of
IPv6 try to send "total number of network buffers + 1", so that even with
IPv6 fragmentation enabled requested datagram will not be sent. In all
tested cases when datagram is too big, check that ENOMEM error code is set.

NOTE: Tested behavior is not 100% compliant with Linux, as on Linux
EMSGSIZE error code is set when trying to send datagram bigger than MTU,
when manually disabling IP fragmentation (by setting IP_MTU_DISCOVER to
IP_PMTUDISC_DO). However, it is not trivial to implement such
behavior (EMSGSIZE error due to MTU) now and there is always a risk of
running out of buffers (and getting ENOMEM), so for now implemented tests
just assume the latter case to always happen.

Add 3rd testcase, which enables IPv6 fragmentation support, so that UDP
socket behavior can be tested in that context.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-01 11:17:07 +02:00
Sjors Hettinga d55c921e2f tests: net: socket: tcp: Add test for a broken link
A reproducible case to the behavior when during a connection
the link gets broken and all data is lost, the TCP connection
should properly terminate.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-30 10:30:38 +02:00
Robert Lubos 3cd88c72b1 tests: net: sockets: Update packet socket tests
Fix the existing DGRAM packet socket test. The test will now specify
LL destination address and protocol type. Also, update the fake ethernet
device send handler, so that it sets the packet network interface
corretly, so that the packet is not rejected at Ethernet L2.

Additionally, add two additional test cases verifying datagram packet
sockets. Fist test will exchange packet between RAW and DGRAM socket,
making sure that net stack forwards/removes L2 header correctly. The
second test verifies that it's possible to recieve a packet on both RAW
and DGRAM socket, making sure the received data has correct format.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07:00
NingX Zhao 1bc003ad6a tests: net: Adjusting the memory buffer for ETH
The net cases failed to run on sam_e70b_xplained
platform because failed to reserve data net buffers,so
adjusting the memory buffer to fix this.

Fixes #42857

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-05-26 13:39:11 -07:00
Marcin Niestroj 084aca1aa4 tests: socket: tls: check sendmsg() behavior for datagrams
Datagrams (for DTLS connection) need to be sent using single API call to
mbedTLS and should not result in sending each fragment in a separate
datagram. Check if that is the case, so allow only single fragment data to
be sent and expect an error when multiple fragments were passed to
sendmsg().

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-05-25 14:20:09 +02:00
Robert Lubos f49ed7a539 tests: net: socket: Add test to verify POLLOUT functionality
Add test which verifies that POLLOUT is reported correctly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-18 11:09:17 +02:00
Sjors Hettinga c3158804d4 tests: net: socket: tcp: Add test to validate obstructed close
When there is no response from the server, a client side close
is obstructed, it should terminate and clean the context. This
tests breaks the connection after the accept and validates
this behavior.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-16 16:55:51 +02:00
Robert Lubos d63cb79383 tests: net: socket: Increase ztest stack size for offload_dispatcher
The test suite is failing on qemu_cotext_a9 due to stack overflow.
Apparently this issue can also be observed on main after enabling
STACK_SENTINEL, however the test only started crashing after TCP
changes.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-13 15:42:01 +02:00
Andrey Dodonov bc0cf10757 net: tcp: Remove unused config NET_TCP_BACKLOG_SIZE
Remove NET_TCP_BACKLOG_SIZE from KConfig and from test,
because it's not present anymore in current version of TCP stack.

Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2022-05-13 13:04:59 +02:00
Gerard Marull-Paretas ade7ccb918 tests: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all tests to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:02:14 +02:00
Sjors Hettinga 11288cdbdd tests: net: socket: tcp: Make test_vX_msg_waitall more robust
The close function on a TCP socket can return before the complete
socket has been closed, as there might be packets still in flight.
Add a wait at the end of the test so we are sure all sockets have
been closed before the next test starts.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-05 14:45:02 -05:00
Sjors Hettinga cf3466ff74 tests: net: socket: tcp: Make test_open_close_immediately more robust
The close function on a TCP socket can return before the complete
socket has been closed, as there might be packets still in flight.
Modify the test to wait briefly (less then the retransmit time), before
counting the number of still open net_contexts. This makes the test
outcome not dependent on the scheduling order of the different tasks.

Secondly the test actually checks the number of open contexts to be zero
so there is no need to wait for any open contexts to still close.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-05 14:45:02 -05:00
Sjors Hettinga 40ee401dd2 tests: net: socket: tcp: Add test to validate connect timeout
When there is no response from the server, a client side connect
should return a ETIMEOUT. This tests breaks the connection and validates
this behavior.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-05 14:45:02 -05:00
Flavio Ceolin d490358e28 tests: ipv6: Fix DAD timeout test
DAD timeout was wrongly checking the reply order. The code will always
assign sequentially the reply to 0-2 with the current uptime. This means
that we will always have dad[0] < dad[1] < dad[2]. Check it is useless.
Instead, let just check if we got all replies.

The test checking the time between the first and last request is to
fragile. It is testing a constant independently of the tested platform
failing in several of them. Just remove it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-04-27 12:35:34 -04:00
Robert Lubos 6da10468ad tests: net: Add socket dispatcher unit tests
Add unit tests for socket dispatcher module. The tests verify that:
* a socket is automatically dispatched to a regular socket on any
  first socket call, if the socket was not bound already before
  (according to the default priority rules)
* a socket is correctly dispatched to an offloaded/native socket
  implementation after a SO_BINDTODEVICE call
* a socket is correctly dispatched to a native TLS socket, with an
  underlying native/offloaded socket, if TLS_NATIVE and SO_BINDOTODEVICE
  socket options are used

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-04-20 11:27:05 +02:00
Mohan Kumar Kumar 2558d277e2 tests: net: tcp: Add new tests for get/set SO_SNDBUF
Test SO_SNDBUF option using getsockopt and setsockopt.

Signed-off-by: Mohan Kumar Kumar <mohankm@fb.com>
2022-04-11 10:23:31 +02:00
Sjors Hettinga 3b03344a8d tests: net: socket: tcp: Add test for big block data transfer
A reproducible case to see what happens when the TCP stack runs out
of buffers. It transfers a block, bigger then the number of buffers
available.
Also test by introducing packet loss in the loopback driver.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-04-01 12:36:14 -05:00
Mohan Kumar Kumar 4e7a74c547 tests: net: tcp: Add new tests for get/set SO_RCVBUF
Test SO_RCVBUF option using getsockopt and setsockopt.

Signed-off-by: Mohan Kumar Kumar <mohankm@fb.com>
2022-04-01 13:30:09 +02:00
Katarzyna Giadla 681e3a16c7 tests: Change duplicated names of the test cases
Some names of the test cases are duplicated within the project.
This commit contains the proposed names of the test scenarios.

Signed-off-by: Katarzyna Giadla <katarzyna.giadla@nordicsemi.no>
2022-03-30 17:42:01 -04:00
Robert Lubos c1f06c7442 tests: net: sokcets: tcp: Adjust net_pkt count
Since the loopback driver makes use of the RX packet pool now, adjust
the packet count for the test.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-30 11:08:22 +02:00
Emil Gydesen ae55dae454 sys: util: Change return type of ARRAY_SIZE to size_t
The ARRAY_SIZE macro uses sizeof and thus the return
type should be an unsigned value. size_t is typically
the type used for sizeof and fits well for the
ARRAY_SIZE macro as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-23 14:09:23 +01:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Robert Lubos cea2c8de3d tests: net: socket: Add getpeername() tests
Add tests for new getpeername() function.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-16 16:23:16 +01:00
Yong Cong Sin 4bcd33bb35 tests: net: all: Add shell MQTT backend
Test the compilation of shell MQTT backend.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-15 10:01:12 +01:00
Henrik Brix Andersen e9c9caa80d net: remove unmaintained 6LoCAN implementation
Remove the unmaintained, experimental 6LoCAN (IPv6 over CAN bus)
implementation.

Fixes: #42559

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-09 18:07:31 +01:00
Otavio Salvador e2edb3e405 scripts: Allow use of bash outside of /bin
Even though bash is commonly available as /bin/bash there are
exceptions (e.g NixOS). This commit allow the use of the scripts in my
environment and is generic.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2022-03-08 11:11:10 +01:00
Marcin Niestroj 4480831fc6 tests: socket: tcp: add shutdown(..., SHUT_RD) tests
Those tests cover behavior of shutdown(fd, SHUT_RD) and recv(fd, ...).

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2022-03-02 10:05:09 -08:00
Robert Lubos 9ac83be650 net: lwm2m: Add proper resource-level discovery attribute handling
In case an individual resource is being discovered, the LwM2M client
should not only fill the attributes assinged at the resource level, but
also the ones inherited from the object and object instance levels.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-22 10:12:27 -08:00
Carles Cufi e83a13aabf kconfig: Rename the TEST_EXTRA stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Carles Cufi 4b8f1c04ab kconfig: Rename the ZTEST stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Gerard Marull-Paretas 5314690c3b drivers: ieee802154: mcr20a: define as DT device
The device already has a DT compatible (and uses DT properties).
Instantiate the device using the DT-based macros and remove hardcoded
name.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-21 22:16:10 -05:00
Xabier Marquiegui 52be66919e net: gptp: convert clock sync ratio from float to double
Using clock sync ratio as double instead of float improves
synchronization smoothness

Signed-off-by: Xabier Marquiegui <xmarquiegui@ainguraiiot.com>
2022-02-11 10:03:05 -06:00
Yong Cong Sin 731241f8d0 kernel: workq: Fix type errors in delayable work handlers
A common pattern here was to take the work item as the subfield of a
containing object. But the contained field is not a k_work, it's a
k_work_delayable.

Things were working only because the work field was first, so the
pointers had the same value. Do things right and fix things to
produce correct code if/when that field ever moves within delayable.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-02-02 18:43:12 -05:00
Robert Lubos 21e5cc7a31 tests: net: lwm2m: Add link-format content writer tests
Add unit tests for LwM2M link-format content encoder/decoder.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos 960512fa13 tests: net: lwm2m: Add JSON content writer tests
Add unit tests for LwM2M JSON conent encoder/decoder.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos 735fd86c0e tests: net: lwm2m: Add OMA TLV content writer tests
Add unit tests for LwM2M OMA TLV conent encoder/decoder.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos 48fd29a081 tests: net: lwm2m: Add plain text content writer tests
Add unit tests for LwM2M plain text conent encoder/decoder.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Efrain Calderon 99e3e67661 test: net: coap: update tests
Update test to ensure that any file can be tranfered,
not only files that are aligned with the packet size.

Signed-off-by: Efrain Calderon <efrain.calderon@aquarobur.com>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:10:57 +01:00
Andrew Hedin 7f004f1b35 net: lwm2m: Add LwM2M gateway object
Add support for the gateway object [EXPERIMENTAL] used by the
MG100, BT510, and BT610 LwM2M demo.

Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2022-01-18 13:19:12 -05:00
Gerard Marull-Paretas ddc168fa78 pm: s/PM_DEVICE_(DT_(INST))_REF/PM_DEVICE_(DT_(INST))_GET
In order to align with macros used to obtain a device reference (e.g.
DEVICE_DT_GET), align the PM macros to use "GET" instead of "REF". This
change should have low impact since no official release has gone out yet
with the "REF" macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-18 12:14:06 -05:00
Nicolas Pitre a3a31257df net: npf: add the ability to do MAC address masked matching
Add the ability to do matching on partial MAC addresses.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-12-21 17:06:35 +01:00
Nicolas Pitre faa0b2a848 net: introduce a network packet filter framework
This provides the infrastructure to create network packet filter rules
and to apply them to the RX and TX packet paths. Rules are made of
simple condition tests that can be linked together, creating a facility
similarly to the Linux iptables functionality.

A couple of generic and Ethernet-specific condition tests are also
provided.

Additional tests can be easily created on top of this.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-12-21 17:06:35 +01:00
Robert Lubos 860e59e881 tests: net: ipv6: Verify Route Info data in Router Advertisment
Verify that Route Info data received in Router Advertisment creates a
route and correctly populates the net_route_entry structure.

Additionally, extend the MTU on the test interface, to accomodate the
extended Router Advertisement message.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-12-20 17:44:28 +01:00
Robert Lubos 111992bb71 tests: net: route: Add new route tests
Add new route tests to cover lifetime and preference functionality.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-12-20 17:44:28 +01:00
Robert Lubos e9db822635 net: route: Add support for route preference
Implement a concept of Route Preference, as specified in RFC 4191. The
Zephyr host will prefer routes with higher preference, if they lead to
the same prefix through different neighbours.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-12-20 17:44:28 +01:00
Kim Bøndergaard ee6c552805 boards: frdm_k64f: Solve conflict between UART3 and enet
Arduino compatible boards should have a working UART on pin 0 & 1.
On frdm_k64f this is handled by uart3

Unfortunately pinmuxing of uart3 was destroyed when enabling NETWORKING,
because the uart3 RX/TX pins was reconfigured for 1588 timers.

1588 timers are enabled by the enet child node, ptp which by some reason
is enabled by default.
1588 timers aren't needed in most cases when ethernet is being used,
so this fix ensures ptp is by default disabled. Likewise pinmuxing of
the 1588 timer functionality is now dependant of ptp being active

Signed-off-by: Kim Bøndergaard <kim.boendergaard@escoglobal.com>
2021-11-30 11:08:15 -06:00
Robert Lubos 2eb67b2fe4 tests: net: Add custom 802154 L2 tests
Add some basic custom 802154 L2 tests, verifying that a custom L2 can be
integrated with Zephyr properly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-11-29 18:55:13 -05:00
Gerard Marull-Paretas 89a4f36fc8 device: remove inclusion of pm/device.h
The device PM subsystem _depends_ on device, not vice-versa. Devices
only hold a reference to struct pm_device now, and initialize this
reference with the value provided in Z_DEVICE_DEFINE. This requirement
can be solved with a forward struct declaration, meaning there is no
need to include device PM headers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-29 11:08:38 +01:00
Robert Lubos 6dbd5c7876 net: icmpv6: Remove in6_addr from packed structs
Replace unpacked in6_addr structures with raw buffers in packed icmpv6
structs, to prevent compiler warnings about unaligned access.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-11-25 10:46:35 -05:00
Robert Lubos 666e9f80d6 net: ipv6: Remove in6_addr from packed net_ipv6_hdr struct
Replace unpacked in6_addr structures with raw buffers in net_ipv6_hdr
struct, to prevent compiler warnings about unaligned access.

Remove __packed parameter from `struct net_6lo_context` since the
structure isn't really serialized.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-11-25 10:46:35 -05:00
Robert Lubos 064200b420 net: ipv4: Remove in_addr from packed net_ipv4_hdr struct
Replace unpacked in_addr structures with raw buffers in net_ipv4_hdr
struct, to prevent compiler warnings about unaligned access.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-11-25 10:46:35 -05:00
Robert Lubos bbdeef4ac4 net: arp: Remove in_addr/in6_addr from packed net_arp_hdr struct
Replace unpacked in_addr/in6_addr structures with raw buffers in
net_arp_hdr struct, to prevent compiler warnings about unaligned
access.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-11-25 10:46:35 -05:00
Flavio Ceolin 6451626ce7 pm: Use pm_device_action_run instead of state_set
Since drivers implement a callback based on action and not the state,
we should be using the API based on the action instead of the one based
on the state.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-11-24 14:21:50 -05:00
Jordan Yates 8e99db5801 Kconfig: net: deprecate NET_BUF_USER_DATA_LEN
As user data sizes are now set on a per pool basis, this Kconfig option
has no purpose.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-24 16:04:50 +02:00
Jordan Yates 70649077a0 tests: net: buf: test per-pool data lengths
Validate that per-pool user data lengths are being set correctly.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-24 16:04:50 +02:00
Jordan Yates df327eeb58 net: buf: POOL_FIXED_DEFINE explicit user data
Update the macro prototype to explicitly require the length of the
desired user data. Update all in-tree usage of this macro.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-24 16:04:50 +02:00
Jordan Yates d17e0439c2 net: buf: POOL_HEAP_DEFINE explicit user data
Update the macro prototype to explicitly require the length of the
desired user data. Update all in-tree usage of this macro.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-24 16:04:50 +02:00
Jordan Yates 8236b600f7 net: buf: POOL_VAR_DEFINE explicit user data
Update the macro prototype to explicitly require the length of the
desired user data. Update all in-tree usage of this macro.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-24 16:04:50 +02:00
Jordan Yates 0b5e6f1f8f tests: net: buf: validate user_data_size fields
Validate the `user_data_size` field is populated correctly.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-24 16:04:50 +02:00
Gerard Marull-Paretas 39f21dc116 tests: pm: use new PM macros
Use PM_DEVICE_STATE_DEFINE to define PM state.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-19 10:11:32 +01:00
Christopher Friedt 3e86c627f7 kernel: atomics: update print specifiers for atomic_t
The print specifier for `atomic_t` should be updated
to `%ld`, `%lu`, or `%lx` to account for the type
change of `atomic_t` to `long`.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-11-15 09:59:01 -05:00
Tomasz Bursztyka 32db35a721 net/tcp: Rename TCP2 to TCP
TCP2 is no longer needed as it is the unique implementation since the
legacy one has been removed.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-11 07:26:41 -05:00
Tomasz Bursztyka 404f67ab5e tests/net: Raise TLS timeout option on waitall checks
Previous timeouts values were done when local TCP replies wourd occur
within sender's thread. This was a known behavior: no context switch,
shorter timings for sending packets (locally only) thus shorter
timeouts.

Such behavior changed when local replies had to go through TCP's work
queue. See commit 798588e709

Fixes #40129

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-09 12:51:44 +01:00
Andrew Hedin a6f831fea6 net: lwm2m: Add IPSO filling sensor object
Add support for the filling sensor object used by the MG100
and BT610 LwM2M demo.

Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2021-11-09 11:19:12 +01:00
Andrew Hedin e0715556e7 net: lwm2m: Add IPSO current sensor object
Add support for the current sensor object used by the MG100
and BT610 LwM2M demo.

Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2021-11-08 11:01:22 -05:00
Anas Nashif 6432289baf tests: add integration_platforms to socket/tls test
Run only on defined integration platforms in CI.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-05 09:23:41 -04:00
Tomasz Bursztyka 3718904a50 test/net: Make sure the tls server socket is accepting before connect
Client thread might run before the server gets to put itself on accept.
Leading to the server waiting forever.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-04 13:54:28 +01:00
Tomasz Bursztyka 174f489bec tests/net: Put the context down and not only the tcp part in tcp2 test
This will clean up the context properly and call net_tcp_put()
relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-04 13:54:28 +01:00
Tomasz Bursztyka f371f76e9a tests/net: Switch k_msleep to k_yield for tcp packet scheduling
TCP work queue is of higher priority so k_yield should do the trick, and
the test will not be affected by any timing.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-04 13:54:28 +01:00
Tomasz Bursztyka 1696f6de35 tests/net: TLS test requires more RX PKT and buffers
Due to the previous change on when to send TCP packet on local IP, pkt
may be held in a queue which is to run on a k_work. This changes the
scheduling, and due to that one of the test is failing to allocate a
RX net_pkt at the time it wants to. (previous TCP connection is not yet
fully closed and still own PKT that new connection cannot get then).

Of course all those waiting paquets require buffers so raising them.

It was verified that there is no leak, adding net_pkt_print() at
tcp_conn_unref() shows that when all tcp connection are finally unrefed:
all net_pkt get freed as well.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-04 13:54:28 +01:00
Gerard Marull-Paretas 18519ffe8d tests: use common PM action callback naming
The PM callback is no longer referenced as "pm_control" but
"pm_action_cb", so reflect this new naming on the callbacks.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-03 20:27:18 -04:00
Robert Lubos 20bdb6ee21 tests: net: all: Add LwM2M to build all test
LwM2M was not covered by networking build all test, leaving an opening
for possible regression in modules that are not enabled by default in
the sample.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-11-03 11:19:40 +01:00
Robert Lubos 477c0d9499 tests: net: net_pkt: Verify unchecked net_pkt functions results
Some net_pkt functions in `test_net_pkt_headroom_copy()` did not have
their return values verified, causing coverity complains.

CID: 240661

Fixes #39841

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-11-02 22:27:21 -04:00
Christopher Friedt 3ad85f41b5 tests: net: dns_sd, mdns: support service type enumeration
Tests for DNS-SD Service Type Enumeration.

Fixes #38673

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-10-01 20:11:50 -04:00
Robert Lubos 0dbdcc770d net: sockets: Add socket processing priority
When creating a socket, all of the registered socket implementation are
processed in a sequence, allowing to find appropriate socket
implementation for specified family/type/protocol. So far however,
the order of processing was not clearly defined, leaving ambiguity if
multiple implmentations supported the same set of parameters.

Fix this, by registering socket priority along with implementation. This
makes the processing order of particular socket implementations
explicit, giving more flexibility to the user, for example when it's
neeed to prioritze one implementation over another if they support the
same set of parameters.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-09-28 20:11:26 -04:00
Alex Sergeev e7778b8584 net: ptp: extract PTP interfaces outside gPTP subsys under NET_L2_PTP
As per #38352, we would like to start building out PTP (IEEE 1588)
support for superset of gPTP functionality in Zephyr. This is the first
step to abstract away some key interfaces from NET_GPTP umbrella to
NET_L2_PTP.

Signed-off-by: Alex Sergeev <asergeev@carbonrobotics.com>
2021-09-28 20:01:16 -04:00
Torsten Rasmussen 8e64038559 drivers: net: adding NET_DRIVERS menuconfig
Fixes: #38403

Adding NET_DRIVERS menuconfig so that network drivers are grouped
together in its own menu entry under drivers, similar to most other
drivers.

This further has the advantages that `CONFIG_NET_DRIVERS` can be used
for testing to determine if network drivers has been selected.

This changed revealed a dependency loop where both `select` (for SLIP)
and `depends` (for PPP) which both depends on NET_DRIVERS` where in use
in the dependency tree for Qemu networking, especially NET_SLIP_TAP.

This is handled by defaulting `NET_DRIVERS` to `y` when building for a
Qemu target.
`SLIP` had a dependency to `!QEMU_TARGET || NET_QEMU_SLIP`. This is
changed so that SLIP prompt depends on `!QEMU_TARGET` which provides
full user control in hardware but makes the symbol promptless on Qemu
targets.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-28 12:13:23 +02:00
Daniel DeGrasse b30ae46aa0 tests: ptp: Fixed PTP clock test failure on frdm_k64f
ptp_clock_test was failing when trying to access the ptp clock from user
mode. This was due to an arbitrary initialization priority between the
virtual PTP clock devices created by the ptp clocking test and the
physical PTP clock on the frdm_k64f board. Since the ptp test
initializes the virtual clock with the same device name as the physical
clock, if the physical clock was initialized first this test would
incorrectly reference the physical device during testing, instead of the
virtual one.

This fix simply defines the virtual ptp clock with a custom name, so
that the test will always locate the correct ptp clock.
Fixes #38731

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2021-09-23 04:17:40 -04:00
Jani Hirsimäki f7219e8a31 tests: net: socket: new tests for AF_PACKET&SOCK_RAW&IPPROTO_RAW
New test case for testing send/recv for
socket combo of: AF_PACKET&SOCK_RAW&IPPROTO_RAW.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2021-09-14 08:37:36 -04:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
Move to CMake 3.20.0.

At the Toolchain WG it was decided to move to CMake 3.20.0.

The main reason for increasing CMake version is better toolchain
support.

Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
Stancu Florin b4bf5cbf7a tests: ieee802154: fix test MAC addresses
Fake driver interface initialization and packet dst address were wrong.

Signed-off-by: Stancu Florin <niflostancu@gmail.com>
2021-08-17 09:19:39 -04:00
Gerard Marull-Paretas 7ccc1a41bc pm: use actions for device PM control
Instead of passing target states, use actions for device PM control.
Actions represent better the meaning of the callback argument.
Furthermore, they are more future proof as they can be suitable for
other PM actions that have no direct mapping to a state. If we compare
with Linux, we could have a multi-stage suspend/resume. Such scenario
would not have a good mapping when using target states.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 495672ab62 pm: cleanup pm control callback implementations
- Return -ENOTSUP if the requested state is not supported
- Remove redundant "noop style" functions.
- Use switch everywhere to handle requested state (not necessary in all
  drivers, but better take off with consistency in place after current
  changes).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas d41dadc569 pm: rename PM_DEVICE_STATE_SUSPEND to PM_DEVICE_STATE_SUSPENDED
The verb tense for the suspended state was not consistent with other
states. The likely reason: state was being used as a command/action.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 11eef4d8c8 pm: device: remove pointer usage for state
Since the state is no longer modified by the device PM callback, just
use the state value.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 9e7d545bb4 pm: device: remove ctrl_command callback argument
The ctrl_command is not used anymore, so remove it from the callback
signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas da0ff4ae46 pm: device: remove usage of ctrl_command
The callback is now invoked to set the device PM state in all cases, so
the usage of ctrl_command is redundant.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Fabio Baltieri 532a85ccd9 tests: net: dns-sd: add a test case for setup_dst_addr
Add a test case for mdns setup_dst_addr.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-07-26 10:46:50 -04:00
Nicolas Pitre 697f3544a7 net: bridge: test to exercise the bridge facility
This is accomplished with 3 fake ethernet interfaces hooked to a
common bridge, simulating incoming packets and controlling each
interface's transmission product.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-07-21 18:20:01 -04:00
Marcin Niestroj 1ce1d19bb5 net: pkt: introduce net_pkt_remove_tail()
Introduce a helper function for being able to remove any arbitrary
length from tail of packet. This is handy in cases when removing
unneeded data, like CRC once it was verified.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2021-07-15 06:54:33 -04:00
Robert Lubos 3fe94e088b tests: net: socket: select: Relax timing requirements
The test ocassionally fails on the mps2_an385 platform in the CI, due
to strict timing requirements of the test.

Relax the timeouts and acceptable fuzz time a bit, to prevent the
failures in the future.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-14 07:41:08 -04:00
Gerard Marull-Paretas 26ad8376bd pm: remove callback from control function
The callback is not used anymore, so just delete it from the pm_control
callback signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Gerard Marull-Paretas 217e610d8f pm: remove redundant callback usage
the device PM callback is not used anymore by the device PM subsystem,
so remove it from all drivers/tests using it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Robert Lubos bb0f061834 tests: net: coap: Convert unit tests to ztest API
Convert CoAP unit tests to ztest API.

Additionally, replace dynamic memory allocation with a static one, to
prevent memory leaks with ztest.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-10 12:21:48 -04:00
Jukka Rissanen fe3a11bafa tests: net: ethernet_mgmt: Fix tests when running in real hw
If the test is run in a board that has a network interface
enabled, then the tests might select and use wrong network interface
that is needed for the test. So this commit makes sure that
we always use the simulated network interface for the
Ethernet management tests.

Fixes #36419

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-07-07 21:01:27 -04:00
Gerard Marull-Paretas cc2f0e9c08 pm: use enum for device PM states
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.

All drivers and tests have been adjusted accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-07 14:13:12 -04:00
Robert Lubos fe6e017649 tests: net: coap: Extend existing tests with additional checks
Make sure that internal CoAP packet fields are set correctly after
packet creation/parsing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-07 07:40:55 -05:00
Robert Lubos f6a2d3ac7a tests: net: socketpair: Verify that poll is signalled correctly
Add unit tests which verifies that poll() function is signalled
correctly if called after data was written/read to/from a socket.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-02 22:22:42 -04:00
David Leach 6688f70996 tests: net: socket: tls_ext: Add platform filter
Network test cases are designed for emulated
environments so add platform_allowed filter to
only allow qemu platforms.

Fixes: #36418

Signed-off-by: David Leach <david.leach@nxp.com>
2021-07-02 09:46:04 -04:00
Jukka Rissanen e9bad8f0a2 tests: net: eth: Add TXTIME tests
Simple tests that verify that TXTIME parameters can be passed from
application code into the driver and vice versa.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-06-14 07:00:10 -04:00
Jukka Rissanen d1629c4a61 tests: net: eth: Add Qbu tests
Simple tests that verify that Qbu parameters can be passed from
application code into the driver and vice versa.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-06-14 07:00:10 -04:00
Jukka Rissanen 8adc0a7863 tests: net: eth: Add Qbv tests
Simple tests that verify that Qbv parameters can be passed from
application code into the driver and vice versa.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-06-14 07:00:10 -04:00
Robert Lubos 2f409f401e tests: net: socket: tls: Fix timing issue on nRF devices
The timings were too tight for TLS tests executing on nRF52840 with
hardware entropy source enabled. Increase the timings to make tests
pass.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-06-09 16:11:11 +03:00
Ievgen Glinchuk 1ce8d6fae4 net: dns: Fix multiple IP DNS resolution
Fixed mutli-IP DNS resolution as previously the same IP address was
used to populate all AI entries and added DNS_RESOLVER_AI_MAX_ENTRIES
config entry to define max number of IP addresses per DNS name to be
handled.

Signed-off-by: Ievgen Glinchuk <john.iceblink@gmail.com>
2021-06-07 23:54:55 -04:00
Jukka Rissanen 0106e83c74 tests: net: socket: Add userspace tests to SO_BINDTODEVICE
Change the SO_BINDTODEVICE tests so that we test also userspace
mode.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-06-07 10:37:22 +03:00
Stephanos Ioannidis 79788137cf tests: net: getaddrinfo: Increase newlib heap size
This commit increases the newlib heap size to 2048, which is the
recommended minimum required to ensure proper operation of the newlib
nano used by test (see #35799).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-02 08:50:45 -05:00
Jukka Rissanen dab391f253 tests: net: getaddrinfo: Disable onboard Ethernet controller
If the tests/net/socket/getaddrinfo is run in a board that has
Ethernet controller, then it is possible that it will interfere
the test if the Ethernet cable is connected. As the test only
needs loopback support to run, disable the Ethernet as it is
not needed by the test.

Fixes #34923

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-13 22:07:00 -04:00
Flavio Ceolin 0c607adb63 pm: device: Align state names with system states
Change device pm states to the same pattern used by system power
management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 18:35:12 -04:00
Flavio Ceolin 7eba310220 power: device: void *context -> uint32_t *state
The context parameter used across device power management is
actually the power state. Just use it and avoid a lot of
unnecessary casts.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Hake Huang ff4eb86903 net/virtual: test case need have random generator driver
add below to fitler out correct platforms
filter: CONFIG_ENTROPY_HAS_DRIVER

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-05-07 08:53:10 -05:00
Gerard Marull-Paretas 56f1a8ce98 pm: rename PM_DEVICE_GET/SET_POWER_STATE to PM_DEVICE_STATE_GET/SET
Adjust name to be consistent with device PM naming conventions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas 7988ab4a26 pm: rename device_set/get_power_state to pm_device_set/get
Make name consistent with other device PM APIs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas dbf46b3815 pm: rename device_pm_cb to pm_device_cb
Prefix all device PM functions/data structures with pm.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas 2c7b763e47 pm: replace DEVICE_PM_* states with PM_DEVICE_*
Prefix device PM states with PM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Jukka Rissanen 6e1df0d603 tests: net: Refactor tests when running in real hw
The network tests were expecting that network interfaces
are in certain order. As we cannot guarantee that, refactor
the tests like this:

* if test is using DUMMY L2 driver, then disable Ethernet L2
  and fetch only DUMMY L2 instead of default interface
* if test is using Ethernet L2 driver, then make sure that the
  test is using the Ethernet interface specified in the test
  instead of the one provided by the DUT

Fixes #34505

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-30 11:59:10 +03:00
Jukka Rissanen d367fc73c5 tests: net: igmp: Remove device_pm_control_nop
The use of device_pm_control_nop is deprecated so remove it
from the test as it will give warning in CI.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-29 14:23:11 -04:00
Marcin Niestroj 9f478e0a80 tests: net: dns_addremove: cover dns_resolve_reconfigure()
Add tests for just introduced dns_resolve_reconfigure() API, which
allows to replace old DNS servers with new ones.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-04-29 08:00:09 -04:00
Marcin Niestroj 71c31c45c7 net: dns: add dns_resolve_reconfigure() API
So far there was no dedicated mechanism for replacing DNS servers with
new list. Add dns_resolve_reconfigure() API that allows to achieve that
in a thread-safe manner.

Introduce 3rd state in DNS context lifetime by converting from 'bool
is_used' to 'enum dns_resolve_context_state state'. This new
DEACTIVATING state allows to mark a DNS context as busy and safely close
context without holding lock. Closing DNS context with released lock
prevents deadlock in case net_context_close() has to synchronize with a
separate thread executing handler passed to net_context_recv() (which is
the case for example with ESP-AT WiFi driver).

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-04-29 08:00:09 -04:00
Jukka Rissanen a4c119a23d tests: net: igmp: Add IPv4 IGMP tests
IGMP (Internet Group Management Protocol) support tests.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-29 14:49:55 +03:00
Gerard Marull-Paretas 5899b8a190 tests: net: remove usage of device_pm_control_nop
device_pm_control_nop is now deprecated in favour of NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 12:53:09 -04:00
Jukka Rissanen 91ff30513f tests: net: poll: Increase ztest thread stack size
The socket poll test was running out of ztest stack so increase
it by 256 bytes.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00
Jukka Rissanen a9b3057f15 tests: net: ptp: Compile only on relevant boards
The tests need gPTP support so set the options and boards
properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00
David Leach 70edc3c1d0 tests: net: tcp2: Perform tests on DUMMY interface
Tests are designed to run over the DUMMY interface but when run on
hardware, net_if_get_default() can return the actual hardware
interface.

Fixes: #31969

Signed-off-by: David Leach <david.leach@nxp.com>
2021-04-27 12:00:14 +03:00
Jukka Rissanen 9f2fa87e05 net: Remove support for CONFIG_NET_CONTEXT_TIMESTAMP option
This option was only able to collect statistics of transmitted
data. The same functionality is available if one sets the
CONFIG_NET_PKT_RXTIME_STATS and/or CONFIG_NET_PKT_TXTIME_STATS
options.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-26 10:46:43 +03:00
Lukasz Majewski b9f5ba2730 test: Rename interfaces defined in virtual networks test
This work is similar to one performed for ./net/ptp/clock/ test.

However, there is one notable extension - the check in iface_cb()
callback also checks for virtual interfaces defined in
subsys/net/l2/virtual/ipip/ipip.c. Those 'virtual' interfaces are
required for this test to be run.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-04-20 08:29:49 -04:00
Lukasz Majewski d1b6a80191 test: Lookup for struct net_if interface defined in ipv6 test
The tests/net/ipv6/src/main.c uses net_if_get_default() to get the
interface for testing. This is problematic when board introduces its own
linker script, which places board's network interface on the "default"
position - i.e. the first one.

To fix this issue - the lookup for network device defined for this test
is used instead.

Moreover, interfaces rename has been performed in a manner, which would
allow working with 'eth_native_posix' interface being added as linker
object when drivers/ethernet/eth_native_posix.c file is linked for
./zephyr/tests/net/ipv6 test on 'native_posix' board.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-04-20 08:29:49 -04:00
Lukasz Majewski f25dd77df2 test: Rename interfaces in ptp clock test
This change is required to allow correct tests operation after changing
the definition of linker script placement rule (to be more strict and
using the device name).

The struct net_if interfaces have been renamed to preserve correct
order.
Moreover, the iface_cb() function now immediately returns for
interfaces, which are not supposed to be used in this tests - for
example ones already defined on board on which the test is run.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-04-20 08:29:49 -04:00
Lukasz Majewski b8148922ee test: Rename interfaces defined in checksum offload test
The struct net_if object placement in linker 'net_if_area' section
now depends on the order of ETH_NET_DEVICE_INIT() macros in the source
code (for the same object file - like app/libapp.a(main.c.obj)).

Currently the 'eth_offloading_enabled_test' device is placed first,
followed by 'eth_offloading_disabled_test'.

This placement is important when one would like to access those
interfaces with net_if_get_default() function.

After the rename the order is explicit, when we append the device name
to the ._net_if.static.<dev name> object in linker's net_if_area.

The code now works as all struct net_if interfaces are placed as
'._net_if.static.net_if' objects.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-04-20 08:29:49 -04:00
Lukasz Majewski a18be0cdbb test: Lookup for struct net_if interface defined in arp test
The struct net_if object placement in linker 'net_if_area' section
now depends on the order of liked libraries (like
app/libapp.a(main.c.obj). As a result interfaces defined in testing
applications are placed first in the 'net_if_area' section.

Problem arises when board has other interfaces, which are placed on the
first (i.e. default) position. In this case the test just fails as wrong
network interface is used.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-04-20 08:29:49 -04:00
Peter Bigot 188cb2cb7c net: Conversion of k_work API
Replace all existing deprecated API with the recommended alternative.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-14 07:07:40 -04:00
Robert Lubos 71532eb8c2 tests: net: sockets: Implement SO_BINDTODEVICE option tests
Add tests for SO_BINDTODEVCIE socket option.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-02 07:23:17 -04:00
Robert Lubos 814fb71bf3 net: socket: Implement SO_BINDTODEVICE socket option
Implement SO_BINDTODEVICE socket option which allows to bind an open
socket to a particular network interface. Once bound, the socket will
only send and receive packets through that interface.

For the TX path, simply avoid overwriting the interface pointer by
net_context_bind() in case it's already bound to an interface with an
option. For the RX path, drop the packet in case the connection handler
detects that the net_context associated with that connection is bound to
a different interface that the packet origin interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-02 07:23:17 -04:00
Hake Huang 6d397801e7 tests: disable long time case from NXP FRDM_KW41Z
CMSIS_DSP and net_socket tests are either too
slow or too large for this platform, also drop
bluetooth for test

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-04-01 10:57:19 -05:00
Jukka Rissanen 8ea7eb9e51 tests: net: virtual: Add unit tests for checking tunneling
Add tests to verify that IP tunneling works as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-29 07:40:24 -04:00
Kumar Gala 0bb4665df7 include: Move ptp_clock.h to drivers/ptp_clock.h
Move ptp_clock.h out of the top level include/ dir into
include/drivers/ptp_clock.h and deprecated the old location.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-25 10:09:33 +02:00
Christopher Friedt 5b1d71259b tests: sockets: add test for socket api tls extensions
This change adds a test for the socket API TLS extensions.

Fixes #30936

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-03-23 14:09:08 +02:00
Robert Lubos 8929b40b78 tests: net: sockets: tls: Add MSG_TRUNC flag tests
Add unit tests for MSG_TRUNC flag.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-23 13:16:30 +02:00
Robert Lubos d93003e267 tests: net: sockets: Add MSG_TRUNC flag tests
Add unit tests for MSG_TRUNC flag.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-23 13:16:30 +02:00
Jukka Rissanen 0af89fc4ec net: Remove legacy TCP stack
Remove legacy TCP stack as it is replaced by the new TCP2 stack.
The TCP2 stack has been the default stack since 2.4 release.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-22 13:06:54 -04:00
Guðni Már Gilbert 01252c2b6b tests: net: socket: getaddrinfo: fix resource leak
Fix resource leak detected by coverity by adding missing
zsock_freeaddrinfo(res) calls.

Coverity-CID: 219527
Fixes #32919

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2021-03-19 17:22:31 +02:00
Peter Bigot 1c7bf96019 net: dns: update to new k_work API
Switch to the new API for delayed work related to DNS queries.

In the previous solution it was assumed that the work item could be
immediately cancelled at the point the query slot was released.  This
is not true.  We need a secondary condition to record the fact that
the query was completed while the work item was still pending, and an
additional check to detect when the work item completed and the slot
reclaimed.

Also annotate functions to indicate when they require the lock on
query content to be held, add some helpers that abstract core
operations like invoking a callback or releasing a query slot, and fix
some more cases where query slot content was accessed outside of the
new lock infrastructure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-03-15 17:19:54 +02:00
Guðni Már Gilbert 4d5566adf1 tests: net: socket: af_packet: fix resource leak
Fix resource leak by closing opened AF_PACKET sockets

Coverity-CID: 219491
Fixes #32949

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2021-03-15 17:19:39 +02:00
Anas Nashif 15b9565b37 Revert "tests: net: socket: af_packet: fix resource leak"
This reverts commit a1ae45fecd.

The test is failing now, reverting until properly fixed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-12 19:50:54 -05:00
Robert Lubos 5de148d8c0 tests: net: sockets: tls: Add unit test for TLS MSG_WAITALL flag
Add a unit test that covers MSG_WAITALL flag functionality for TLS
sockets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-12 13:57:11 -05:00
Robert Lubos 4582e57903 tests: net: sockets: tcp: Add unit test for MSG_WAITALL flag
Add a unit test that covers MSG_WAITALL flag functionality for TCP
sockets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-12 13:57:11 -05:00
Jukka Rissanen 8140fb8d2f tests: net: getaddrinfo: Verify that we receive all queries
The previous implementation of process_dns() handler did not
properly catch how many queries we sent.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-12 11:26:16 -05:00
Guðni Már Gilbert a1ae45fecd tests: net: socket: af_packet: fix resource leak
Fix resource leak by closing opened
sockets

Coverity-CID: 219491
Fixes #32949

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2021-03-12 09:22:26 -05:00
Andy Ross 3d81464194 tests: samples: Add targetted platform_excludes for intel_adsp_cavs15
This platform has a tiny handful of remaining tests that fail.  We
will track them as issues, but let's exclude them from integration
testing to allow full runs to complete.  Often a hung device in one
test will break an entire twister run.

Tests with known (and tracked) failures:

  samples/application_development/external_lib
  samples/posix/eventfd
  samples/userspace/hello_world_user
  tests/kernel/fatal/message_capture
  tests/net/socket/socketpair
  tests/portability/cmsis_rtos_v2

These tests never fail in isolated testing, but are reliable timeouts
when run in sequence in a big twister run.  It's possible that the bug
here may be in twister or the flash/serial scripts:

  tests/crypto/tinycrypt
  tests/subsys/logging/log_immediate
  tests/subsys/logging/log_output

See: #32836

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 19:25:25 -05:00
Andy Ross 589c781506 tests: No thread-shared/synchronized data on stack (coherence)
CONFIG_KERNEL_COHERENCE forbids synchronized data on the stack: no
spinlocks, IPC primitives, or things that contain them.  Application
code obviously doesn't have to follow these inconvenient rules, but
our test code needs to run on platforms with incoherent stack memory.

Make these things static.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 19:25:25 -05:00
Jukka Rissanen 865ed89b1d tests: net: checksum_offload: Use proper network interface
Instead of hardcoding the network interface value, use
net_if_ipv6_select_src_iface() so that proper network interface
gets used.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-04 16:05:52 +02:00
Jukka Rissanen 15e3355d85 tests: net: select: Increase the timeout to 20ms
The timeout might take more than 10ms in a heavily loaded system,
so increase the timeout to 20ms.

For example this is often seen for mps2_an385 platform.

  Assertion failed at \
  WEST_TOPDIR/zephyr/tests/net/socket/select/src/main.c:101: \
  test_select: (tstamp <= FUZZ is false)

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-02-24 08:01:43 -05:00
Hubert Miś ca87d134b5 tests: Socket send timeout option
This patch adds tests for SO_SNDTIMEO socket option.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-24 14:16:33 +02:00
Christian Taedcke c467149ad9 net: pkt: Add function net_pkt_get_contiguous_len()
This returns the available contingous space in the packet starting from
the current cursor position.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2021-02-24 09:43:52 +02:00
Reto Schneider 545fb92fc1 net: pkt: Fix headroom edge case
This commit fixes some edge cases when using net_bufs with reserved
bytes (headroom) as fragments of a net_pkt.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2021-02-22 19:33:16 +02:00
Reto Schneider d0144da95a net: pkt: Expose headroom edge case
When operating on a net_pkt using the cursor functionality, reserved
bytes (headroom) are currently not respected.

This commit adds test cases exposing this problem. Fix will be
introduced in a later commit.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2021-02-22 19:33:16 +02:00
Jukka Rissanen 7699563d81 net: mgmt: Use proper coop thread priority value
If user sets CONFIG_NUM_PREEMPT_PRIORITIES=0, then the priority
of the net_mgmt thread will be -1 which is the same as idle thread.
This will trigger assert in kernel as then the minimum coop priority
is -2 in this case. Remove the net_mgmt thread priority setting from
Kconfig file as it is low value and set the coop thread priority
the same way as other network threads are doing it.

Fixes #32375

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-02-17 16:42:15 +02:00
Hubert Miś 2f02ca0b39 tests: net: socket: SO_PROTOCOL socket option
This patch adds tests to verify getting SO_PROTOCOL socket option for
TCP, UDP, and TLS sockets.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-17 10:36:58 +02:00
Hubert Miś a6e83eb769 tests: net: socket: SO_TYPE socket option
This patch adds tests to verify getting SO_TYPE socket option for
TCP, UDP, and TLS sockets.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-17 10:36:58 +02:00
Hubert Miś 2e2915a596 tests: net: coap: Acknowledgement initialization
New test that verifies CoAP Acknowledgement initialization function
that create a response packet for given request. Both request and
expected response packets are given in the test as PDU.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-15 10:17:11 +02:00
Hubert Miś 77c68aa070 net: coap: clean up token usage in samples and tests
This patch replaces magic numbers with COAP_TOKEN_MAX_LEN value and
removes unnecessary castings of token buffer type.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-02 14:03:01 -05:00
Hubert Miś 22687c34e3 net: coap: define default CoAP version
RFC 7252 (CoAP) specifies value of the Version (Ver) field in the
protocol header to value 1. This patch defines value of the Version
field to make packet initialization easier. All samples and tests
are updated to use the new COAP_VERSION_1 field when initializing
a CoAP packet.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-02 14:03:01 -05:00
Flavio Ceolin 1335716b5f tests: socket: Fix compiler warnings
../src/main.c:662:13: warning: cast from pointer to integer of different
size [-Wpointer-to-int-cast]
  662 |  int sock = (int)p1;
      |             ^
../src/main.c: In function 'spawn_child':
../src/main.c:671:4: warning: cast to pointer from integer of different
size [-Wint-to-pointer-cast]
  671 |    (void *)sock, NULL, NULL, 0, K_USER,

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-27 08:05:48 -05:00
Hubert Miś 401ee4ae5b tests: Socket receive timeout option
This patch adds tests for SO_RCVTIMEO socket option for UDP and
TCP sockets.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-01-19 17:11:25 -05:00
Hubert Miś 13aa4b2f9e net: coap: define Content-Format option values
CoAP protocol defines registry of Content-Format option values.
This patch adds this enumeration to coap header file to make it
available to all applications using CoAP protocol. It modifies
code using CoAP service to use new enumeration.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-01-19 16:07:20 -05:00
Robert Lubos 538e19ee2e net: coap: Rework pending retransmission logic
Introduce retransmission counter to the coap_pending structure. This
allows to simplify the retransmission logic and allows to keep track of
the number of remaining retranmissions.

Additionally, extend the `coap_pending_init()` function with `retries`
parameter, which allows to set the retransmission count individually for
each confirmable transaction.

Fixes #28117

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-01-18 23:22:37 -05:00
Jukka Rissanen 5723f381e9 tests: net: ptp clock: Increase main stack size
The main stack size is too small by default in many boards.
Increase the size to 1024 bytes which works fine with
sam_e70_xplained board.

Fixes #31342

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-01-17 15:09:58 +02:00
Martin Åberg 4604c45541 tests: enable and run many tests on RISC-V
This commit enables lots of tests on riscv32 and riscv64 which were
previously disabled.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2021-01-15 13:06:33 -05:00
Jukka Rissanen ebd077b258 tests: net: af_packet: Increase main stack size
The main stack size is too small by default in many boards.
Increase the size to 1024 bytes which works fine with
sam_e70_xplained board.

Fixes #31343

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-01-15 12:14:53 -05:00
Lukasz Majewski 33028963c8 test: af_packet: Add test for passing UDP packet to open RAW socket
The af_packet test has been augmented to check if sent UDP packet from
one port to another (via net interface) is also passed to open SOCK_RAW
connection.
The test_packet_sockets() function has been reused to setup the SOCK_RAW
sockets for this test.
It is important to note that the packet is passed to receive part of net
stack after being sent.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-01-15 09:30:17 +02:00
Lukasz Majewski 4987c7ba47 test: af_packet: Do not change proto to network order when creating socket
The setup_socket() function calls socket() with proto changed to network
order. In this case functions with zsock_* prefix are called instead of
zpacket_*. The problem is with 'packet_is_supported()' method from
sockets_packet.c, which returns false when ETH_P_ALL proto is converted
with htons().

This patch fixes this issue by removing the htons() call.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
Suggested-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-01-15 09:30:17 +02:00
Fabio Baltieri 4a4c63519d net: if: check for multicast address already registered
Add a check to stop a multicast address to be registered multiple times.
This can happen if the application is using net_if_ipv6_maddr_add()
directly.

Tested on the existing bluetooth/ipsp sample:

<wrn> net_if: Multicast address ff02::1 is is already registered.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-01-14 16:57:07 +02:00
Jukka Rissanen 408a6ceff3 tests: net: tcp2: Add tests for TCP recv data queueing
Make sure that received and out-of-order TCP segments are queued
until we receive proper segments.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-01-12 13:40:05 +02:00
Peter Bigot acd43cbaac net: timeout: refactor to fix multiple problems
The net_timeout structure is documented to exist because of behavior
that is no longer true, i.e. that `k_delayed_work_submit()` supports
only delays up to INT32_MAX milliseconds.  Nonetheless, use of 32-bit
timestamps within the work handlers mean the restriction is still
present.

This infrastructure is currently used for two timers with long
durations:
* address for IPv6 addresses
* prefix for IPv6 prefixes

The handling of rollover was subtly different between these: address
wraps reset the start time while prefix wraps did not.

The calculation of remaining time in ipv6_nbr was incorrect when the
original requested time in seconds was a multiple of
NET_TIMEOUT_MAX_VALUE: the remainder value would be zero while the
wrap counter was positive, causing the calculation to indicate no time
remained.

The maximum value was set to allow a 100 ms latency between elapse of
the deadline and assessment of a given timer, but detection of
rollover assumed that the captured time in the work handler was
precisely the expected deadline, which is unlikely to be true.  Use of
the shared system work queue also risks observed latency exceeding 100
ms.  These calculations could produce delays to next event that
exceeded the maximum delay, which introduced special cases.

Refactor so all operations that use this structure are encapsulated
into API that is documented and has a full-coverage unit test.  Switch
to the standard mechanism of detecting completed deadlines by
calculating the signed difference between the deadline and the current
time, which eliminates some special cases.

Uniformly rely on the scanning the set of timers to determine the next
deadline, rather than assuming that the most recent update is always
next.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-07 11:14:38 +02:00
Jordan Yates bd2c974c0c tests: net: buf: validate push & remove impl
Add test cases for checking the previously untested `net_buf_push_*`
functions in terms of the new `net_buf_remove_*` functions.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-01-05 14:31:13 +02:00
Hubert Miś 4ca7942411 tests: net: Test resolving literal IPv6 addresses
This patch adds a test for the network address resolver module
that verifies resolving literal IPv6 addresses.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2020-12-22 15:44:00 +02:00
Kumar Gala 1706bd2b41 tests: convert DEVICE_AND_API_INIT to DEVICE_DEFINE
Convert tests to DEVICE_{DT_}DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 20:05:40 -05:00
Watson Zeng 7a3f9c4e39 tests: add filter for some tests using newlib
some tests configured with CONFIG_NEWLIB_LIBC=y,
it's better to add a filter filter: TOOLCHAIN_HAS_NEWLIB == 1
in those tests yaml file.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2020-12-16 08:57:40 -05:00
Seppo Takalo 3492e8e248 tests: socket: getaddrinfo: Add tests for getaddrinfo() with NULL host
Also improve test coverage on hints, when queried with numerical
host.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2020-12-15 19:22:50 +02:00
Anas Nashif dd931f93a2 power: standarize PM Kconfigs and cleanup
- Remove SYS_ prefix
- shorten POWER_MANAGEMENT to just PM
- DEVICE_POWER_MANAGEMENT -> PM_DEVICE

and use PM_ as the prefix for all PM related Kconfigs

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-09 15:18:29 -05:00
Andy Ross e95db3a366 tests/net/socket/udp: Increase kernel heap size
On userspace platforms, this test needs a little bit of kernel heap.
The old mem_pool number was specified without metadata overhead
(i.e. it reflected 128 bytes of actual data available and the metadata
was stored silently somewhere else), where the new heap specifies the
size of the contiguous buffer in memory that stores both data and
chunk headers, etc...

Increase to 256 bytes.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-12-07 21:50:14 -05:00
Jukka Rissanen 0ed6a3cd69 tests: net: tcp2: Add RST packet handling tests
Verify that TCP2 will drop invalid RST packets and accept
valid ones.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-11-24 13:08:39 +02:00
Peter Bigot 4ce7cafdf4 tests: net: socketpair: use system instead of user work queue
The socket pairs created for this test when run under user mode are
accessible only from the thread that created them.  Although it is
possible for that thread to grant access to another thread:

* there does not appear to be a way to do that when referencing a
  descriptor rather than a pointer to a kernel object;
* there is no public API that supports granting the object rights to a
  user thread that animates a work queue.

Until these gaps are addressed use the system work queue run
supervisor-mode threads to verify the asynchronous behavior of the
API.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-21 14:49:40 +02:00
Jukka Rissanen b88d5b6c67 tests: net: Adjust the thread priorities
Adjust the test thread priority so that the test / IP stack
has a chance to run and the test passes.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-11-20 12:57:29 +02:00
Paul Sokolovsky 9fa33f27e1 tests: socket: tcp: Add test for ENOTCONN behavior
A socket which didn't undergo completed connect() or accept() calls
should react with ENOTCONN to recv() call. This test checks both
a freshly created socket ("client" one) and a socket in LISTEN
state ("server").

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-11-19 16:58:37 -05:00
Martin Åberg 137e8528ec net: run the net.pm test on LEON
Adds the test to at least one big-endian system.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-17 11:44:16 +02:00
Martin Åberg 5dcdf198da net: improved test for IPv6 pton() and ntop()
Represent IPv6 addresses as groups of 16-bit values in test vectors.

This commit corrects the following two test issues on big endian
systems:

  START - test_ipv6_pton_1
  Failed to verify ff08::
  against 0:ff08::

  START - test_ipv6_ntop_1
  Failed to verify 0:ff08::
  against ff08::

Makes the following tests pass on qemu_leon3:
- net.util

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-17 11:44:16 +02:00
Christopher Friedt 0ddce66d86 tests: net: dns: dns-sd: tests for dns service discovery
Tests for DNS-SD (RFC 6763)

Fixes #29099

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-11-09 16:15:02 -08:00
Jukka Rissanen accaab2112 net: shell: Add network mgmt events monitor support
Add "net events [on|off]" command that can be used to monitor
the generated network management events.

The monitor output looks like this when enabled:

EVENT: L2 [1] up
EVENT: L3 [1] IPv6 mcast address add ff02::1:ff00:1
EVENT: L3 [1] IPv6 mcast join ff02::1:ff00:1
EVENT: L3 [1] IPv6 address add 2001:db8::1
EVENT: L4 [1] connected
EVENT: L3 [1] IPv6 prefix add 2002:5b9b:41a0::
EVENT: L3 [1] IPv6 address add 2002:5b9b:41a0:0:fec2:3dff:fe11:c147
EVENT: L3 [1] IPv6 neighbor add fe80::9ec7:a6ff:fe5e:4735
EVENT: L3 [1] IPv6 router add fe80::9ec7:a6ff:fe5e:4735
EVENT: L3 [1] IPv6 DAD ok fe80::fec2:3dff:fe11:c147
EVENT: L3 [1] IPv6 DAD ok 2001:db8::1
EVENT: L3 [1] IPv6 DAD ok 2002:5b9b:41a0:0:fec2:3dff:fe11:c147
EVENT: L3 [1] IPv4 address add 192.168.1.69
EVENT: L3 [1] DHCPv4 bound 192.168.1.69

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-13 13:42:50 +03:00
Oliver Hitz 0c70877ceb net: IPv4 bcast address recognized as multicast
Modified net_ipv4_is_addr_mcast() to not wrongly classify an IPv4
broadcast address as a multicast address.

Signed-off-by: Oliver Hitz <oliver@net-track.ch>
2020-10-09 10:26:38 +03:00
Jukka Rissanen d4347b4015 net: dhcpv4: Generate start/bound/stop mgmt events
The L4 connected/disconnected events are usually used to detect
when the application is connected to the network. Unfortunately
if the device has also a static address, then the connected event
might be created (for the static address) even if DHCPv4 is not
ready yet and application would not be able to connect (yet) to the
network. In order to allow the application to fine tune the network
connection creation, generate start, bound and stop events for DHCPv4.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-03 17:15:15 +03:00
Jan Pohanka 9e5dc213cb net: mqtt: fix tests to use zsock_ functions
Use zsock_ variants of socket functions in mqtt tests.

Signed-off-by: Jan Pohanka <xhpohanka@gmail.com>
2020-10-01 17:35:45 +03:00
Jukka Rissanen 4a27246c06 tests: net: tcp2: Fix crash in frdm_k64f
Lowering the connection timeout in order to avoid spin lock assert
in frdm_k64f device. This error was seen with this device

ASSERTION FAIL [z_spin_lock_valid(l)] @ zephyr/include/spinlock.h:92
        Recursive spinlock 0x20003590

Fixes #28602

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-23 13:02:04 -05:00
Robert Lubos c18f15f694 net: mqtt: Remove unused defines from the sample and tests
APP_TX_RX_TIMEOUT and APP_NET_INIT_TIMEOUT were not used in any way
in the sample and test apps.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-09-09 15:46:24 +03:00
Jukka Rissanen 57a894a5ee tests: net: dns_packet: Disable Ethernet when test is run
The test was failing when run in sam_e70_xplained board.
Because the test does not use any network packet TX/RX functionality,
disable Ethernet support so that when run in a board with network
capabilities, the network interface is not created.

Fixes #28000

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-03 18:05:51 -04:00
Jukka Rissanen 747d2f4483 tests: net: af_packet: Fix the test when run in fast hw
If the recvfrom() in the test returns EAGAIN, try again in order
to make sure that we have really received the data.

Fixes #27963

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-03 10:59:11 +03:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Jukka Rissanen 6493af2714 tests: net: dns: Add tests for catching malformed packets
Add more tests to verify that we discard malformed packets.
In order to simplify the testing, separate message validation to
dns_validate_msg() function in resolve.c. Allow that function to
be called from unit test. This way we can construct invalid DNS
messages in unit test and verify that they are discarded when
needed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-27 08:05:52 -04:00
Anas Nashif dca317c730 sanitycheck: inclusive language
change whitelist -> allow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-27 07:04:07 -04:00
Jukka Rissanen 1a01aacd16 tests: net: af_packet: Initial tests for SOCK_DGRAM types
Add some tests for testing AF_PACKET and SOCK_DGRAM type
sockets. These are sockets where Ethernet header is automatically
added, caller just needs to provide upper stack header.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-27 10:56:06 +03:00
Philip Serbin b7b73d0160 net: ipv6: added interface multicast group filtering
Added additonal checks in net_ipv6_input to ensure that multicasts
are only passed to the upper layer if the originating interface
actually joined the destination multicast group.

Signed-off-by: Philip Serbin <philip.serbin@lemonbeat.com>
2020-08-24 13:53:15 +03:00
Jan Georgi 5931a29979 net: route: multicast routing feature
net: route: Add prefix-based ipv6 multicast forwarding

This adds/reenables the feature of multicast routing/forwarding.
The forwarding decision is based on the added multicast routes
and the new network interface flag:
NET_IF_FORWARD_MULTICASTS.

Signed-off-by: Jan Georgi <jan.georgi@lemonbeat.com>
2020-08-19 09:46:25 -04:00
David Leach c5f3da22ae tests: net: Fixes coverity issue CID 210552
Function scope of 'socket' was not closed before exiting
the function.

Fixes #25792

Signed-off-by: David Leach <david.leach@nxp.com>
2020-08-16 09:29:41 -04:00
David Leach c16711c7e6 tests: net: Fix coverity issue CID 211047
Assert check that the net_ipv6_nbr_lookup() did  not return NULL

fixes #26359

Signed-off-by: David Leach <david.leach@nxp.com>
2020-08-16 09:29:41 -04:00
Jukka Rissanen a5f4b44ab8 tests: net: socketpair: Fix debug logging
Only one LOG_MODULE_REGISTER() is allowed in the files that are
linked together. The other files must use LOG_MODULE_DECLARE()

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-14 09:47:51 -07:00
Tomasz Bursztyka 98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Jukka Rissanen 18b145a5d5 tests: net: poll: Increase the TX/RX pkt counts and MAX_CONN
TCP2 uses slightly more network packets and connections in the
socket poll test, so increase the values for the test.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-07 10:35:48 +03:00
Jukka Rissanen 5007509c3f tests: net: tcp: These unit tests are only for legacy TCP
Run the TCP tests in tests/net/tcp only for legacy TCP stack.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-07 10:35:48 +03:00
Jukka Rissanen 7d90812f26 tests: net: af_packet: Fix running in real hw
The tests were failing when run on those boards that had
physical Ethernet support. In that case there were three Ethernet
interfaces, two simulated ones for testing, and the third one
was provided by the board. This extra Ethernet interface caused
the test to fail as the test was sending data to wrong interface.

Fixes #27238
Fixes #26568

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-07-30 12:25:49 +02:00
Jukka Rissanen 5eef2c5f24 tests: net: iface: Modify tests to verify userspace access
Modify the tests so that they verify that only allowed thread
is able to modify network interface data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-07-29 08:13:22 -04:00
Oleg Zhurakivskyy 8aed3aa669 tests: net: tcp2: Update test_sem_take()
Fail solely on semaphore timeout.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-07-20 13:55:22 +03:00
Oleg Zhurakivskyy 31aff65165 tests: net: tcp2: Check for failed connect on SYN resend
Since the peer isn't replying on SYN resend, update the
test to check for failed connect.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-07-20 13:55:22 +03:00
Oleg Zhurakivskyy f5a94e5877 tests: net: tcp2: Update timeout values
Since the connect is now blocking, update the timeout values
for the tests to pass.

In case of resend test, set the timeout to 1000ms to account
for the retransmission.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-07-20 13:55:22 +03:00
Flavio Ceolin c4f7faea10 random: Include header where it is used
Unit tests were failing to build because random header was included by
kernel_includes.h. The problem is that rand32.h includes a generated
file that is either not generated or not included when building unit
tests. Also, it is better to limit the scope of this file to where it is
used.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-07-08 21:05:36 -04:00
Stephanos Ioannidis 4b66aae3d3 tests: net: vlan: Fix typos
Fix typos in the test assert messages ("numer" to "number").

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-07-02 08:37:17 -04:00
Paul Sokolovsky 1ca1193a9d tests: socket: getaddrinfo: Explicitly ignore return of sys_mutex_lock
This is a test, and the function is called with K_FOREVER, so it's not
supposed to fail.

Fixes: #25735
CID: 210582

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-06-30 10:02:46 -04:00
Anas Nashif 98c75038c8 tests: net: remove duplicate test
remove duplicate, no need to specify test twice (one for userspace,
another for default).

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-06-25 22:36:17 -05:00
Jukka Rissanen 6ecea4b3dd net: conn: Handle multi interface AF_PACKET recv() properly
If we have multiple network interfaces and we are waiting incoming
network packets, make sure to honor the bind of the socket so that
correct socket will receive data in certain network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-24 23:34:27 +03:00
Lukasz Maciejonczyk 8acebb5cd0 tests: net: Add tests for IPv6 mesh addresses
This tests make sure that the right source address is chosen during
the mesh multicasting.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-16 19:14:52 +02:00
Marcin Niestroj f74bea04aa tests: net: poll: disable NET_IPV4
Unit test code uses IPv6 only, so disable IPv4.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-15 10:31:37 +03:00
Marcin Niestroj 0995246edb tests: net: poll: select NET_CONFIG_NEED_IPV6
Unit test code requires IPv6 to be ready. Select
CONFIG_NET_CONFIG_NEED_IPV6=y to ensure that.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-15 10:31:37 +03:00
Marcin Niestroj acd8b8d93e tests: net: select: disable NET_IPV4
Unit test code uses IPv6 only, so disable IPv4.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-15 10:31:37 +03:00
Marcin Niestroj ec57ebff66 tests: net: select: select NET_CONFIG_NEED_IPV6
Unit test code requires IPv6 to be ready. Select
CONFIG_NET_CONFIG_NEED_IPV6=y to ensure that.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-15 10:31:37 +03:00
Reto Schneider 0b4b3ae4dd cmake, samples, tests: Use semi-accurate project names
When using an IDE (e.g. Eclipse, Qt Creator), the project name gets
displayed. This greatly simplifies the navigation between projects when
having many of them open at the same time. Naming multiple projects
"NONE" defeats this functionality.

This patch tries to use sensible project names while not duplicating
too much of what is already represented in the path. This is done by
using the name of the directory the relevant CMakeLists.txt file is
stored in. To ensure unique project names, small, manual adjustments
have been done.

See also 7eabab2f5d ("samples, tests: Use semi-accurate project names")

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2020-06-09 08:18:29 -04:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Andrew Boie 4482f83cdb tests: net: tcp: test zsock_get_context_object
Add test case to prove that this new API works.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-03 22:33:32 +02:00
Andrew Boie 9a27ba57bb tests: net_mgmt: grant socket access
This socket is shared by all the test cases which run in
different threads. Just make it a global object here.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-03 22:33:32 +02:00
Jukka Rissanen a2f0a9effe net: sockets: Fix sendmsg() user mode param checks for aux data
If we are calling sendmsg() without any aux data, then msg_controllen
is 0 and msg_control is NULL. Check these allowed values properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-03 18:33:59 +02:00
Jukka Rissanen d3dde1ad1c net: sockets: Fix sendmsg() user mode param checks for dst address
If we are calling sendmsg() for a connected socket, then msg_namelen
is 0 and msg_name is NULL. Check these allowed values properly.

Also modify unit tests so that we test this scenario.

Fixes #25925

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-03 18:33:59 +02:00
Christopher Friedt 79728a63ab tests: socket: socketpair: init param before passing by ref
Fixes #25797
Coverity-CID: 210607

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-06-03 18:33:19 +02:00
Christopher Friedt 3f30ce21cb tests: socket: socketpair: init param before passing by ref
Fixes #25796
Coverity-CID: 210579

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-06-03 18:33:19 +02:00
Christopher Friedt 15a2a6ddb7 tests: socket: socketpair: assert recvfrom returns >= 0
Fixes #25731
Coverity-CID: 210568

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-06-03 18:33:19 +02:00
Jukka Rissanen 1bb41c49ce tests: net: udp: Enable more usermode tests for sendmsg()
Some of the sendmsg() tests were not run when in usermode.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-02 15:22:47 +02:00
Marc Herbert debade9121 tests: make find_package(Zephyr...) REQUIRED
... because it is (required).

This makes a difference when building with CMake and forgetting
ZEPHYR_BASE or not registering Zephyr in the CMake package registry.

In this particular case, REQUIRED turns this harmless looking log
statement:

-- Could NOT find Zephyr (missing: Zephyr_DIR)
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- ...
-- ...
-- ...
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:8 (target_sources):
  Cannot specify sources for target "app" which is not built by
  this project.

... into this louder, clearer, faster and (last but not least) final
error:

CMake Error at CMakeLists.txt:5 (find_package):
  Could not find a package configuration file provided by "Zephyr" with
  any of the following names:

    ZephyrConfig.cmake
    zephyr-config.cmake

  Add the installation prefix of "Zephyr" to CMAKE_PREFIX_PATH or set
  "Zephyr_DIR" to a directory containing one of the above files.  If
  "Zephyr" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-05-29 10:47:25 +02:00
Tomasz Bursztyka 9dd822dc93 tests/net: Test network power management awareness
A quick test on a dummy device that:
- opens a socket (success)
- sends data (success)
- suspends (success)
- suspends (failure)
- sends data (failure)
- resumes (success)
- resumes (failure)
- sends data (success)

This permits to show that PM states are properly handled in network
stack.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-26 21:41:00 +02:00
Oleg Zhurakivskyy 593f7c4556 tests: net: tcp2: Avoid trying to free net_pkt twice
For success cases, the net_pkt is handled by the IP stack
so no need to free the net_pkt. The double free is not causing
any issues as the net_pkt code will just ignore the request but
we should avoid doing it because of error prints that are printed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Christopher Friedt ecf32b6eca tests: socket: socketpair: fix userspace thread permissions
Kernel objects were being directly accessed without previously
calling k_thread_access_grant().

This change allows each test that requires an asynchronous
event to send it to a common work queue with correct
permissions.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-05-20 10:34:07 +02:00
Wentong Wu 72227574d8 timer: remove QEMU_TICKLESS_WORKAROUND
Qemu icount mode enabled, remove QEMU_TICKLESS_WORKAROUND.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-05-14 13:52:07 +02:00
Anas Nashif ad82b38b8f tests: ztest: prefix tests with test_
Tests should always start with test_, otherwise detection of subtests
will not work through sanitycheck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-05-13 18:16:07 +02:00
Christopher Friedt 3bfc765aad tests: socket: socketpair: tests for socketpair(2) syscall
Tests for issue #24366

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-05-10 17:46:43 +02:00
Kumar Gala db725c0ec9 drivers: Replace GPIO_CS Kconfig with devicetree detection
Use DT_INST_SPI_DEV_HAS_CS_GPIOS() in drivers to determine if we should
utilize CS_GPIO base SPI chipselect handling.  This allows us to remove
Kconfig option for this feature.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-09 13:07:05 +02:00
Stephanos Ioannidis ff2cba56a9 tests: net: websocket: Remove redundant logging configurations
This commit removes the redundant `LOG` and `LOG_IMMEDIATE` selections
in `prj.conf`, since the `TEST_LOGGING_DEFAULTS`, which is enabled by
default for all tests, selects `LOG` and `LOG_MINIMAL`.

This effectively allows the test to run with the default test logging
policy, set by the testing subsystem.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-05-07 14:47:35 +02:00
Jukka Rissanen f95c349c36 tests: net: dns: Increase stack size for coverage support
Increase stack size so that coverage information can be generated.

Fixes #17323

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-06 13:43:17 +03:00
Jukka Rissanen 65a1bebe85 net: Replace NET_WAIT_FOREVER by SYS_FOREVER_MS
As we now have SYS_FOREVER_MS, use that instead of network
specific NET_WAIT_FOREVER.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-05 16:29:23 +03:00
Jukka Rissanen 8160385b57 net: pkt: Fix removal of empty buffers in net_pkt_pull()
If we have removed first net_buf, then we must not restore the
original cursor as that will point to wrong head net_buf.
Add also unit test to check that the packets are removed
properly.
Clarify the documentation that we are removing data from
beginning of the function, also document that the cursor
is reset after this call.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-05 13:39:45 +03:00
Ravi kumar Veeramally d9c505c745 tests: net: tcp2: Add flags checks
Verify TCP header flags.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-04-30 12:52:11 +03:00
Jukka Rissanen 3d3801ab27 tests: net: pkt: Add more tests for net_pkt_pull()
Add test that pulls more than one net_buf amount of data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-30 09:27:16 +03:00
Stephanos Ioannidis 773de88db0 tests: net: Rename local PORT definition
This commit renames all local definitions with the name `PORT` in the
net tests, in order to prevent name conflict with certain HALs
(notably, Atmel SAM E5x HAL).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-28 09:57:04 +03:00
Jukka Rissanen ba9f20a6eb tests: net: mgmt: Change timeout back to u32_t
No point to change the throw_sleep to k_timeout_t because we
are calculating the timeout beforehand which can lead to
unexpected results if using k_timeout_t.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-27 10:35:17 +03:00
Ravi kumar Veeramally 4c8ad3b0c6 test: net: tcp2: Tests for connection close
Added tests for FIN_WAIT_1, FIN_WAIT_2 and CLOSING
states.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-04-22 12:41:39 +03:00
Jukka Rissanen cb4c09d702 tests: net: tcp2: Add more debugging info
It is useful to know which test fails to semaphore timeout so
add line number of the failing test to assert print.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-19 11:10:37 +03:00
Ravi kumar Veeramally 3b3c7e71a0 tests: net: tcp2: Add minimal unit tests
Minimal tests for TCP2 functionality added.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-04-17 14:49:18 +03:00
Robert Lubos 073ec8d4aa net: mqtt: Refactor because of timeout overhaul
Align MQTT with timeout API changes.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-09 21:58:42 +03:00
Jukka Rissanen 7e56d90ccd tests: net: route: Fix timeout data type
Convert to use k_timeout_t

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen 19d7031d15 tests: net: udp: Fix timeout value type
Convert to use k_timeout_t

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen 66d394d97a net: getaddrinfo: Fix timeout data type
Convert to use k_timeout_t

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen 38dd9bc299 net: mgmt: Refactor because of timeout overhaul
Convert to use k_timeout_t

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen 005ee2f768 net: ipv6: nbr: Refactor because of timeout overhaul
Convert minimal parts to support k_timeout_t values.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen 63a7b92fd8 net: if: Refactor because of timeout overhaul
Convert to use k_timeout_t

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen e56fa75ade net: context: Refactor because of timeout overhaul
The net_context API will change, the s32_t timeout parameter
will be changed to k_timeout_t. All the Zephyr users of this API will
be changed in subsequent commits. This is internal Zephyr API only,
so the API is not deprecated etc.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen 9f17c33b60 net: sockets: Refactor because of timeout overhaul
Use k_timeout_t internally, no change to user API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen 5cf75fe091 net: websocket: Refactor because of timeout overhaul
Mention in websocket API documentation that the timeout value
is in milliseconds. Check timeout values properly using K_TIMEOUT_EQ()
macro.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen a49741ff66 net: dns: Refactor because of timeout overhaul
Use k_timeout_t internally, no change to user API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Robert Lubos 1fb418df4c net: ieee802154_radio: Allow to specify TX mode
Even though radio driver can report in its capabilities that it does
support CSMA CA, there's no way in the driver to select how the frame
should be transmitted (with CSMA or without). As layers above radio
driver (Thread, Zigbee) can expect that both TX modes are available, we
need to extend the API to allow either of these modes.

This commits extends the API `tx` function with an extra parameter,
`ieee802154_tx_mode`, which informs the driver how the packet should be
transmitted. Currently, the following modes are specified:
* direct (regular tx, no cca, just how it worked so far),
* CCA before transmission,
* CSMA CA before transmission,
* delayed TX,
* delayed TX with CCA

Assume that radios that reported CSMA CA capability transmit in CSMA CA
mode by default, all others will support direct mode.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-03 14:07:41 +03:00
Johan Hedberg b3f39226ec net: tests: Fix timeout passed to k_sleep()
Use the appropriate K_SECONDS() or K_MSEC() macros to pass a timeout to
k_sleep() and other kernel APIs.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-04-01 20:03:15 +03:00
Robert Lubos b173c177db net: mqtt: Improve PUBLISH message length validation
Identify when received PUBLISH message is malformed and overall packet
length received is smaller than parsed variable header lenght.
Add unit test to cover this case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-03-28 09:36:12 +02:00
Robert Lubos 1ad165a62d net: mqtt: Fix packet length decryption
The standard allows up to 4 bytes of packet length data, while current
implementation parsed up to 5 bytes.

Add additional unit test, which verifies that error is reported in case
of invalid packet length.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-03-28 09:36:12 +02:00
Torsten Rasmussen 407b49b35c cmake: use find_package to locate Zephyr
Using find_package to locate Zephyr.

Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.

Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.

It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Tomasz Bursztyka 4ae72db135 net: Enable PM settings on network devices
By changing the various *NET_DEVICE* macros. It is up to the device
drivers to either set a proper PM function or, if not supported or PM
disabled, to use device_pm_control_nop relevantly.

All existing macro calls are updated. Since no PM support was added so
far, device_pm_control_nop is used as the default everywhere.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-03-27 14:48:30 +02:00
Ravi kumar Veeramally 2f6bb980e8 tests: net: Improve ICMPv4 tests
Earlier tests were not going through ICMP echo
core stack handlers. Due to that unable to verify
echo reply. Tests are improved to verify replies.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-03-16 14:34:24 +02:00
Marcin Niestroj 67527ce4b7 tests: mqtt_packet: use MQTT_UTF8_LITERAL() to simplify code
Using MQTT_UTF8_LITERAL() allows to reduce code and make it less error
prone, since utf8 length is calculated automatically by the macro.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-03-13 10:06:18 +02:00
Jukka Rissanen ad4a267cbd tests: net: af_packet: Add test for binding with multiple interfaces
Add a simple test to verify that the bind() can be called multiple
times if AF_PACKET is set and there are multiple network interfaces
in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-03-10 14:58:30 +02:00
Ravi kumar Veeramally cfd0f3e18d tests: net: Enable NET_IPV4_HDR_OPTIONS in tests
Test case for IPv4 header options was added but
CONFIG_NET_IPV4_HDR_OPTIONS option was not enabled.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-03-03 16:50:32 +02:00
Ravi kumar Veeramally 2709b14bcb tests: net: Add wrong options length case
Wrong option length in IPv4 header options testcase
added. This should cover malformed packet case.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-02-28 22:34:11 +02:00
Ravi kumar Veeramally 01867fa28c tests: net: Simple test for net_pkt clone
Added simple test case for net_pkt_clone() to verify
cursor position after cloning.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-02-21 16:49:14 +02:00
David D b45b1e393c test: net: pkt: Added a test case for net_pkt_pull()
Added a test case for net_pkt_pull() with large packet buffers

Signed-off-by: David D <a8961713@gmail.com>
2020-02-03 10:47:08 +02:00
Robert Lubos ece552c644 drivers: wifi: simplelink: Rework offloading mechanism
Switch to `NET_SOCKET_REGISTER` mechanism over the offloaded API
registration.

Including the following fixes from the review:

* The fd returned by the socket accept call needs to be finalized,
  similar to how it is done for socket creation.

* sl_RecvFrom() in TI SimpleLink Host driver does not support NULL
  pointers for 'from' address and address length, and sl_SendTo() does
  not ignore the destination address when in connection mode, so passing
  NULL would cause a failure. These issues have been reported to TI
  (CC3X20SDK-1970, CC3X20SDK-1971).

  Let's use sl_Recv and sl_Send to implement recvfrom/sendto in the case
  of NULL addresses.

* simplelink_poll() should not process negative file descriptors in the
  fds array after sl_Selecti() returns. A negative fd value indicates
  that the entry is invalid and should be ignored.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-31 11:36:02 -05:00
Robert Lubos ac12066800 tests: net: mqtt: Fix failure at disconnect
It's no longer needed to call `mqtt_input` after `mqtt_disconnect`.
Doing this will actually return an error as the MQTT connection is no
longer active after calling `mqtt_disconnect`.

Fixes #22360

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-31 17:13:35 +02:00
Jukka Rissanen b957581391 tests: net: websocket: Add TX unit tests for websocket API
Add simple tests for testing sent and received websocket data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-01-28 19:49:16 +02:00
Jukka Rissanen 86b688d43f tests: net: websocket: Add RX unit tests for websocket API
Add simple tests for testing receiving websocket data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-01-28 19:49:16 +02:00
Robert Lubos 7e7f05546d modules: nordic: Allow separate nRF 802.15.4 radio driver build
So far, nRF 802.15.4 radio driver build was dependent on the 802.15.4
subsystem in Zephyr. While this was a reasonable approach for samples,
it prevented the radio driver from being built as a standalone entity,
which could be useful in some applications (e. g. running core nRF
802.15.4 radio driver tests with Zephyr).

Resolve this, by providing a separate set of Kconfigs for the radio
driver, therefore allowing to build it as a separate entity. The 802154
subsystem simply enables the radio driver module in this case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-28 15:18:42 +01:00
Robert Lubos 8801fd015f tests: net: ieee802154: Set LL addresses on a packet
The reworked 6lowpan implementation asserts when no LL source or
destination address is set on a packet. This caused the fragmentation
tests to fail before they completed.

Fix the issue, by setting a dummy address on a packet during a setup.

Fixes #19761

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-22 11:57:11 -06:00
Ulf Magnusson ae900a94d0 tests: net: all: kconfig: Do not assign promptless NET_INIT_PRIO
Assignments have no effect on promptless symbols. Flagged by
https://github.com/zephyrproject-rtos/zephyr/pull/20742.

NET_INIT_PRIO (defined in subsys/net/ip/Kconfig) is currently hardcoded
to 90 (it's not set via any Kconfig.defconfig files either). Maybe it
could be given a prompt or be removed, but just remove the assignment
for now.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-17 10:01:58 +02:00
Ulf Magnusson 8e4a9774f7 tests: net: all: kconfig: Do not assign promptless NET_ROUTING
Assignments have no effect on promptless symbols. Flagged by
https://github.com/zephyrproject-rtos/zephyr/pull/20742.

The prompt was removed in commit 2ec7e70509 ("net: routing: Hide routing
option temporarily").

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-17 10:01:43 +02:00
Ulf Magnusson ba98e72db2 tests: net: all: kconfig: Do not assign promptless NET_RAW_MODE
Assignments have no effect on promptless symbols. Flagged by
https://github.com/zephyrproject-rtos/zephyr/pull/20742.

This symbol is selected by IEEE802154_RAW_MODE, defined in
drivers/ieee802154/Kconfig.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-16 14:34:41 -05:00
Ulf Magnusson 4d32d0ae02 tests: all: kconfig: Do not assign promptless NET_L2_IEEE802154_SUB_GHZ
Assignments have no effect on promptless symbols. Flagged by
https://github.com/zephyrproject-rtos/zephyr/pull/20742.

This symbol is enabled through being selected by IEEE802154_CC1200 and
IEEE802154_RF2XX.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-16 08:05:00 -06:00
Ulf Magnusson 95e5ac11ba tests: net: kconfig: Do not assign promptless NET_L2_IEEE802154_MGMT
Assignments have no effect on promptless symbols. Flagged by
https://github.com/zephyrproject-rtos/zephyr/pull/20742.

This symbol is already enabled indirectly through being selected by
NET_L2_IEEE802154_RFD, which is enabled in the configuration file.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-14 16:35:51 -05:00
Ulf Magnusson e0848a8d61 tests: net: kconfig: Do not assign promptless NET_ROUTE symbol
Assignments have no effect on promptless symbols. Flagged by
https://github.com/zephyrproject-rtos/zephyr/pull/20742.

(There doesn't seem to be any way to enable this symbol, because it's
not being select'ed either.)

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-13 14:19:08 -05:00
Joakim Andersson 9483e432d8 tests: net: arp: Fix net_buf assert in ARP unit test
Fix ASSERTs that appears when enabling asserts in net buf.
Asserts are:
 - Pulling from net buf before any data has been added.
 - Pulling more data than has been allocated for the buf.

Fix warning:
W: You have 1 IPv4 net_if addresses but 2 network interfaces
W: Consider increasing CONFIG_NET_IF_MAX_IPV4_COUNT value.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Joakim Andersson 0484c5af4d tests: net: buf: Fix byteorder test writing beyond buffer
Fix byteorder test writing past the data pointer. This would otherwise
have been caught by the assert, but net buf asserts were not enabled in
the test. Reset the buffer between different tests to re-use the same
16-byte buffer.

Turning on asserts gives:

starting test - net_buf_test_byte_order
ASSERTION FAIL [net_buf_simple_tailroom(buf) >= len] @
	ZEPHYR_BASE/subsys/net/buf.c:775
E: r0/a1:  0x00000004  r1/a2:  0x00000307  r2/a3:  0x00000000
E: r3/a4:  0x00006d79 r12/ip:  0x00000000 r14/lr:  0x000028ad
E:  xpsr:  0x61000000
E: Faulting instruction address (r15/pc): 0x000050b0
E: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Joakim Andersson 3797832030 tests: net: ipv6: Fix net_buf asserts in fragment unittest
Fix ASSERTs that appears when enabling asserts in net buf when adding
more data than has been allocated for the buf.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Ulf Magnusson 04f966ed3e tests: all: Remove assignment to promptless NET_GPTP_CLOCK_ACCURACY
Assignments have no effect on promptless symbols. Flagged by
https://github.com/zephyrproject-rtos/zephyr/pull/20742.

Also remove the assignments to the other NET_GPTP_CLOCK_ACCURACY_*
symbols. They are all in the same choice (in
subsys/net/l2/ethernet/gptp/Kconfig), meaning only one of them can be
enabled, and the choice already defaults to
NET_GPTP_CLOCK_ACCURACY_UNKNOWN, which is the symbol assigned last.

The symbol assigned last becomes the choice selection when multiple
symbols in a choice are assigned to. The other choice symbols still
become n. Dependencies override assignments.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-13 13:51:16 +01:00
Oleg Zhurakivskyy 8a77b53053 net: core: Drop NET_ASSERT_INFO() macro
A single assert macro can serve a purpose here.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-01-08 14:10:21 +02:00
Jukka Rissanen 0b7844e0be tests: net: icmpv4: Test NULL ptr in proper time
The code tried to use the allocated pkt ptr before checking for
NULL value.

Fixes #21699
Coverity-CID: 206608

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-01-07 19:27:11 +02:00
Jukka Rissanen 07489a1aa2 tests: net: poll: Fix the test name and add proper tag
The test name did not reflect the purpose of the test.
Also add "poll" tag so that we can more easily launch just
this test.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-01-03 11:26:46 -08:00
Jukka Rissanen cbf77c1c18 tests: net: poll: Add test case for POLLOUT
We were not testing POLLOUT case so add it here.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-01-03 11:26:46 -08:00
Alberto Escolar Piedras 0b8678a2b0 samples & tests: Correct main() type
The application main() in Zephyr is defined as having a prototype:
void main(void), as expected by the kernel init (bg_thread_main).

So, correct the different samples and tests that were defined
otherwise.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-12-16 11:27:56 +01:00
Ravi kumar Veeramally 50631d66b9 tests: net: icmpv4: Add unit tests
ICMPv4 basic unit tests.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-12-16 11:35:24 +02:00
Ulf Magnusson d748cb6118 tests: net: all: check_net_options.sh: Use lowercase for internal vars
This makes it possible to tell at a glance which variables are internal
to the script and which ones are parameters to it, which is very
helpful.

This convention is pretty common. See e.g. Google's shell style guide at
https://google.github.io/styleguide/shell.xml#Naming_Conventions, and
https://github.com/icy/bash-coding-style#naming-and-styles. It's older
than those though.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-10 14:34:46 -08:00
Kumar Gala 6561b19bc5 include: Fix use of <crc.h> -> <sys/crc.h>
Fix #include <crc.h> as it has been deprecated and
should be #include <sys/crc.h>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-10 08:39:37 -05:00
Kumar Gala 24ae1b1aa7 include: Fix use of <misc/FOO.h> -> <sys/FOO.h>
Fix #include <misc/FOO.h> as misc/FOO.h has been deprecated and
should be #include <sys/FOO.h>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-10 08:39:37 -05:00
Luiz Augusto von Dentz dd94be3ffc tests: buf: Add byte order tests
This adds tests for reading and writing 16, 24, 32, 48 and 64 bits in
different byte orders.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-12-10 09:55:30 +02:00
Anas Nashif 70758c4374 tests: fix test identifiers
The seasonal overhaul of test identifiers aligning the terms being used
and creating a structure. This is hopefully the last time we do this,
plan is to document the identifiers and enforce syntax.

The end-goal is to be able to generate a testsuite description from the
existing tests and sync it frequently with the testsuite in Testrail.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-09 15:53:44 -05:00
Ravi kumar Veeramally 434a92e48f tests: net: Fix CoAP coverity issues
Fix unintended sign extension (SIGN_EXTENSION).

The result of "coap_block_size_to_bytes() * (iter - 1)"
extending the sign type.

Issue is the conversion of iter from u8_t to int because it's
an unsigned operand in an binary subtraction with 1 which is
a signed operand with higher conversion rank (int).

Fixes #20880
Fixes #20881
Fixes #20882
Fixes #20883

Coverity CID :205780
Coverity CID :205786
Coverity CID :205806
Coverity CID :205808

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-11-26 13:35:20 +01:00
Ravi kumar Veeramally 94e048559c tests: net: Fix TCP tests Coverity issue
Check return values of function.

Fixes #20540
Coverity CID :205656

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-11-22 10:01:23 -05:00
Daniel Leung b7eb04b300 x86: consolidate x86_64 architecture, SoC and boards
There are two set of code supporting x86_64: x86_64 using x32 ABI,
and x86 long mode, and this consolidates both into one x86_64
architecture and SoC supporting truly 64-bit mode.

() Removes the x86_64:x32 architecture and SoC, and replaces
   them with the existing x86 long mode arch and SoC.
() Replace qemu_x86_64 with qemu_x86_long as qemu_x86_64.
() Updates samples and tests to remove reference to
   qemu_x86_long.
() Renames CONFIG_X86_LONGMODE to CONFIG_X86_64.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-10-25 17:57:55 -04:00
Maksim Masalski 11d6385ebe tests: remove duplicate names for the net tests
According to the comment in #20008 I found out that some test cases
for different tests have same names.
To get rid of it, I decided to change test cases names.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2019-10-24 06:31:48 -04:00
Ulf Magnusson 9d46779ca7 net: ieee802154: kconfig: Remove unused fragmentation debugging symbol
Unused after commit a76814bfb6 ("net: Convert core IP stack to use log
levels").

Found with a script.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-22 13:10:52 +03:00
Jukka Rissanen 1f97946358 tests: net: icmpv6: Increase the TX buf counts
If the ICMPv6 test is run in real hw, we need a bit more buffers
to pass the test.

Fixes #19915

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-10-22 09:12:24 +03:00
Jukka Rissanen feb6cf56f4 tests: net: shell: Increase the main stack size
Stack size might be too small when running the test in real
board like sam-e70.

Fixes #19914

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-10-21 09:58:56 +03:00
Maksim Masalski 03e6d3bb41 tests: updated names for the dns tests
After run Sanitycheck script I found out that
some test cases have a same test case name
in the test result .xml file.
For boards mimxrt1050_evk, qemu_x86, sam_e70_xplained
in .xml files that cases were dublicated.
Problem happened only with cases net.dns.no_ipv6.init
and net.dns.init. Only that cases were dublicated.
To solve it, I decided to change test cases names for the dns tests.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2019-10-18 15:30:06 +03:00
Ulf Magnusson 2d8bd31b37 tests: net: Remove CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS assignment
This symbol is not user-configurable (has no prompt), so assignments in
prj.conf have no effect on it.

(It has no defaults either, and isn't selected/implied, so nothing in
vanilla Zephyr will ever enable it.)

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-18 09:13:49 +02:00
Jukka Rissanen d500ac87c4 tests: net: tls: Increasing stack size
The default main stack is too small for some boards so increasing
it to 2048. The issue was seen with sam_e70_xplained.

Fixes #19762

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-10-17 17:01:23 +03:00
Jukka Rissanen 6188185c57 tests: net: tcp: Initialize TCP header properly
When constructing TCP packet, make sure the TCP header is
initialized.

Fixes #19775

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-10-15 11:01:20 +03:00
Peter Bigot e28f330a8e coccinelle: standardize k_thread create/define calls with integer timeouts
Re-run with updated script to convert integer literal delay arguments
to k_thread_create and K_THREAD_DEFINE to use the standard timeout
macros.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-09 08:38:10 -04:00
Jukka Rissanen 8a4fa570ac tests: net: hostname: Set MAC address properly to all interfaces
The test creates two network interfaces, but does not set MAC
address of one of them correctly (MAC address is all zeros).
This is not good and the issue fixed in commit 9468cb6eb1
could have been revealed earlier.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-10-04 17:42:14 +03:00
Jan Van Winkel 9468cb6eb1 tests: net: hostname: Corrected unique hostname conversion
Replaced net_bytes_from_str in hostname_get test by a new function that
converts the unique part of the hostname in a byte array.

net_bytes_from_str can not be used as it assumes that the string input
is of the format "xx:xx:xx:xx:xx:xx" where as the unique part of the
hostname is a MAC address string without colons. If net_bytes_from_str
is used this could result in buffer overrun on the input string.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-10-02 12:52:16 +03:00
Jukka Rissanen 49a4144ac5 tests: net: hostname: Add tests for hostname set/get
Add tests that set or get system network hostname.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-09-20 11:42:51 +03:00
Andrew Boie c91b9b37d0 tests: net: stop whitelisting
This is bad practice and may conceal issues on platforms
not in the whitelist.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-20 09:21:11 +03:00
Jukka Rissanen a077bdd417 tests: net: shell: Add some simple tests for net-shell
Make sure net-shell is started properly and it does not crash.
The purpose of this test is to catch issues described in #19178
where UART was not working which was seen as net-shell crashing
at startup.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-09-17 22:41:56 +08:00
Jukka Rissanen 8e6aaaf919 tests: net: socket: Test that non-blocking accept() works
Mark socket non-blocking and make sure that accept() will return
immediately.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-09-13 10:41:33 +03:00
Jukka Rissanen f6c5ea6c81 tests: net: dhcpv4: Increase the buffer count
Test requires more network buffers to work properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-09-12 17:33:44 +03:00
Jukka Rissanen 117d385de8 tests: net: socket: register: Fix unit tests when proto == 0
Make sure the tests pass properly if the socket() is called
with proto 0.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-09-12 11:22:45 +03:00
Jukka Rissanen b14856589e tests: net: getaddrinfo: Logging was missing log_strdup() call
A call to log_strdup() was missing which caused tests to fail if
logging was enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-09-11 16:17:42 +03:00
Jukka Rissanen 8108f06113 tests: net: getaddrinfo: Resolve using wrong address family
Make sure that resolving IPv4 address but returning IPv6 address
(and vice versa) is failing and we catch that scenario.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-09-11 16:17:42 +03:00
Jukka Rissanen 8fa6dfbe5a tests: net: tcp: Test connection cleanup after receiving SYN
Make sure the net_context is properly removed if done after
receiving SYN.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-09-10 22:53:12 +03:00
Jukka Rissanen b73a3de4ed tests: net: poll: Increase the poll timeout value
Got several sanity failures with this information

Assertion failed at tests/net/socket/poll/src/main.c:76: \
  test_poll: (tstamp >= 30U && tstamp <= 30 + FUZZ is false)

In one of the failed tests, the tstamp was 50. Dunno what is
wrong here but in order to proceed with this, increasing the
timeout temporarily. This commit can be removed if the root
cause for this timeout is figured out.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-09-10 12:45:38 +03:00
Jukka Rissanen a76b786eb6 tests: net: poll: Moving config options from yaml to conf file
Moving Kconfig options from testcase.yaml file to prj.conf so
that we can run the test app easily from command line and without
sanitycheck.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-09-10 12:45:38 +03:00
Charles E. Youse cda625b726 drivers/ethernet/eth_dw: remove DesignWare Ethernet driver
This was only used on the Quark SoCs. It is no longer used, can no
longer be tested, and it's reliant upon the deprecated legacy PCI
subsystem. Remove it to prevent bitrot.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-09-08 22:09:10 -04:00
Ioannis Glaropoulos 571b42e74e tests: net: dns_addremove: increase main stack size
We need to increase the stack size of the main thread, to
avoid stack overflow, when executing the tests on various
platforms.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-08-27 11:02:18 +02:00
Vincent Wan fdf0af3b5a tests: net: trickle: use separate semaphore for second trickle timer
A second semaphore is used for the second trickle timer, so that if the
first timer expires twice before the second one, the test would still
wait before proceeding to check on cb_2_called.

Fixes #18598.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-08-26 12:57:56 +02:00
Jan Van Winkel 029189cb68 tests: mqtt Corrected memcmp in mqtt pubsub tests
Corrected payload memcmp in function publish_handler of mqtt pusub
tests.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-08-26 11:29:53 +02:00
Tomasz Bursztyka 7ea5ec8baf tests: net: Fix for coverity CID 203499
Adding an assertion on returned allocation.

Coverity-CID: 203499
Fixes #18454

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-08-19 16:27:23 +02:00
Kumar Gala deae969de3 tests: net: lib: dns: dns_addremove: Increase stack size for FRDM-K64F
CONFIG_MAIN_STACK_SIZE was originally 1344 in this test.  The following
commit removed setting the stack size in the test:

commit 7b3cd7d371
Author: Cami Carballo <cami.carballo@intel.com>
Date:   Fri Jul 26 10:59:16 2019 -0400

    tests: net: increase stack size

However getting the default stack size on FRDM-K64F of 512 causes the
following panic:

FATAL: ***** BUS FAULT *****
FATAL:   Stacking error
FATAL:   Imprecise data bus error
FATAL:   NXP MPU error, port 3
FATAL:     Mode: Supervisor, Data Address: 0x20002ff0
FATAL:     Type: Write, Master: 0, Regions: 0x8200
FATAL: r0/a1:  0x00000000  r1/a2:  0x00000000  r2/a3:  0x00000000
FATAL: r3/a4:  0x00000000 r12/ip:  0x00000000 r14/lr:  0x00000000
FATAL:  xpsr:  0x200002f4
FATAL: Faulting instruction address (r15/pc): 0x00000000
FATAL: >>> ZEPHYR FATAL ERROR 2: Stack overflow
FATAL: Current thread: 0x2000182c (main)
FATAL: Halting system

Bump stack back to original 1344 fixes the issue.

Fixes #18292

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-08-16 09:20:45 +02:00
Jukka Rissanen 7da78796de tests: net: udp: We need to reserve enough space for the data
We are trying to pass 64-bit value to the driver, but we only
allocate space for an integer. This will not work and will cause
invalid memory access.

Fixes #18205

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-14 09:15:34 +03:00
Cami Carballo 7b3cd7d371 tests: net: increase stack size
fixes issues with tests/net when code coverage is enabled in qemu_x86

Signed-off-by: Cami Carballo <cami.carballo@intel.com>
2019-08-08 13:50:32 -07:00
Jukka Rissanen ed10c9068e tests: net: sendmsg: Verify that connected UDP sock works
Add new tests that make sure that sendmsg() works when using
connected UDP socket and when not setting msghdr destination
address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-08 23:13:51 +03:00
Alexander Wachter 35f01673ac net: l2: 6LoCAN implementation
This commit is an implementation of 6LoCAN, a 6Lo adaption layer for
Controller Area Networks. 6LoCAN is not yet standardised.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-08-08 13:25:01 +03:00
Alexander Wachter c8c5f3bbf3 net: canbus: Rename canbus to canbus_raw
Rename the socket_can implementation from CANBUS to CANBUS_RAW.
This is a preperation for 6LoCAN which is a CANBUS L2 for IPv6.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-08-08 13:25:01 +03:00
Jukka Rissanen fc79a789c7 tests: net: context: Let the net_context cb to run first
An issue was seen after changes introduced in #17933.
The net_context callback was run after we checked that it
was run ok. This test failed of course in that case. Simple
solution is to k_yield() which will make sure that the
callback gets called before we continue. This works for this
test as our threads have suitably selected priorities.
There is also no need to use K_NO_WAIT here so replacing the
timeout with K_FOREVER.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-05 16:25:18 +03:00
Anas Nashif 578ae40761 boards: remove quarl_se_c1000
This board and SoC was discontinued some time ago and is currently not
maintained in the zephyr tree.
Remove all associated configurations and variants from the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-07-29 21:30:25 -07:00
Anas Nashif ffaba63b10 boards: remove arduino 101 and related boards
This board and SoC was discontinued some time ago and is currently not
maintained in the zephyr tree.
Remove all associated configurations and variants from the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-07-29 21:30:25 -07:00
Jukka Rissanen d09248219d tests: net: ppp: Add unit tests for PPP driver
Make sure that we are able to parse incoming PPP data
correctly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Alexander Wachter 62ded2ded4 tests: net: 6Lo: Add test criterion HDR diff
This commit adds a test criterion that checks how many bytes
are compressed.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-07-25 15:19:28 +03:00
Alexander Wachter 0f8c2acece tests: net: 6lo: Adapt tests to deal with headers in multiple frames
The testcases are adapted to handle more than one net buffer in
a net_pkt. After the IPHC optimization it is possible that IP header
is not in the same buffer than the UDP header.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-07-25 15:19:28 +03:00
Jukka Rissanen c470fff3c9 tests: net: txtime: Add tests for SO_TXTIME and SCM_TXTIME
Make sure that SO_TXTIME socket option can be set and get.
Verify also that TX time is passed properly to network device
driver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-24 10:17:16 +03:00
Jukka Rissanen 4a8154f6c1 tests: net: udp: Add tests for sendmsg() call
Make sure we are able to pass ancillary data using the
sendmsg() API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-24 10:17:16 +03:00
Nicolas Pitre 6609c12516 tests: enable native_posix_64 testing
Whenever conditions are applied to native_posix, they should apply to
native_posix_64 too.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-16 10:41:11 -07:00
Marc Herbert c429051380 tests/net/: samples/net/: add a few 'userspace' tags
See commit message 4afcc0f8af for the long story.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-07-15 09:05:10 -04:00
Jukka Rissanen 600c1d6fa7 tests: net: trickle: Adjust config options to avoid error prints
Noticed this error print when running in mps2_an385 platform.

   <err> net_if: There is no network interface to work with!

Adding CONFIG_NET_LOOPBACK=y removes this error. After this
the CONFIG_NET_IPV6_MLD=n needed to be added in order to avoid
crashes when IPv6 MLD is done which is not needed for this test.

Removed also the whitelisting as that is not really needed and
we want to run these in as many platforms as possible.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-10 18:55:37 +03:00
Jamie McCrae 3e734ddbce tests: net: lib: dns: dns_addremove
Adds test code for new net_mgmt events relating to adding and
removing DNS servers

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdtech.com>
2019-07-09 17:04:55 +03:00
Jukka Rissanen 0d8b0c6714 tests: net: dhcpv4: Make sure we get DNS add/del events
Verify that DNS server add/del event is received properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-09 17:04:55 +03:00
Nicolas Pitre d19a5f9119 net: socket: mgmt: use uintptr_t for the nm_pid field
This may contain a pointer so make sure it is sufficiently wide
on 64-bit targets.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-05 10:06:23 -04:00
Jukka Rissanen ac56fd8d27 tests: net: Increase stack sizes for coverage testing
We need to increase the stack sizes if user enables CONFIG_COVERAGE
option. You can test this by this command

    sanitycheck --coverage -p qemu_x86 -T tests/net/udp \
                -T tests/net/mgmt  -T tests/net/mld

This is partial fix for issues described in #17323

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-04 09:42:44 -07:00
Jukka Rissanen 06136e5670 tests: net: socket: register: Do not close invalid fd
If the socket descriptor is invalid (fd < 0), there is no
need to try to close it.

Coverity-CID: 198949
Fixes #16785

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-04 07:23:50 -04:00
Marc Herbert 5acb622171 tests/net/ptp/clock: add 'userspace' tag
... because this test does use userspace, as seen in the source or
demonstrated by the failure of this command:

  sanitycheck --extra-args=CONFIG_TEST_USERSPACE=n

See commit message of 4afcc0f8af for the long story.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-07-04 11:44:11 +03:00
Jukka Rissanen 4bb57c481e tests: net: tx_timestmp: Fix the tests
Fix tests because of changes in TX timestamping options.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-03 09:42:45 +03:00
Jukka Rissanen efd99e6634 tests: net: ip-addr: Avoid possible null pointer dereference
Check return value of net_if_ipv6_get_ll() before accessing it.

Coverity-CID: 199437
Fixes #17201

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-02 11:37:05 +03:00
Jukka Rissanen 3b3844a921 tests: net: socket: mgmt: Add tests for get|setsockopt()
Test AF_NET_MGMT API getsockopt() and setsockopt() functions that
they work properly when called from kernel or from userspace.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen 40ec4bc15c tests: net: socket: mgmt: Add unit tests for net_mgmt sockets
Almost the same as the net_mgmt socket sample but can be run by
sanitychecker.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen 8cf4d59180 tests: net: utils: Add userspace tests for net_addr_ntop/pton()
Add unit tests to net_addr_ntop() and net_addr_pton() in order to
verify that the functions can be called from userspace.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen eb018f8109 tests: net: mgmt: Verify that info_length is correct
If info is sent by net_mgmt, make sure it contains correct data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen 02b3826fa0 net: mgmt: Add info length to event wait API
The info parameter is difficult to use if the caller does not
get information how long the info struct is. So add info_length
parameter to net_mgmt_event_wait_on_iface() and
net_mgmt_event_wait() APIs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen 7063921e87 net: if: Add userspace support to IPv4 gateway set function
Allow application to call net_if_ipv4_set_gw_by_index()
and set the gateway if enabled by configuration.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
Jukka Rissanen 813ae63f6b net: if: Add userspace support to IPv4 netmask set function
Allow application to call net_if_ipv4_set_netmask_by_index()
and set the netmask if enabled by configuration.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
Jukka Rissanen 01fa8a6fe2 tests: net: if: Test userspace support in net_if
Add more tests to test userspace enabled APIs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
Jukka Rissanen f3b0b441ed tests: net: dns: Add tests for dns_unpack_answer()
Make sure that dns_unpack_answer() works as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 09:44:29 +03:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 0c9e280547 cleanup: include/: move misc/mutex.h to sys/mutex.h
move misc/mutex.h to sys/mutex.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Jukka Rissanen c9aaab74db net: ptp: clock: Add usermode support to ptp_clock_get()
It is useful that the ptp_clock_get() function can be called from
the userspace. Create also unit test for calling that function
from userspace.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-25 15:22:51 +03:00
Jukka Rissanen 95e8498c27 net: ptp: Add usermode support to net_eth_get_ptp_clock_by_index()
Make net_eth_get_ptp_clock_by_index() clock API to work with user space.
Create also unit test for testing this user mode support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-25 15:22:51 +03:00
Jukka Rissanen 2c4b2a16a5 tests: net: getaddrinfo: Make sure we receive two queries
If user supplies AF_UNSPEC, we need to do two queries, one for
IPv4 A record and one for IPv6 AAAA record.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-20 14:45:43 +03:00
Håkon Øye Amundsen 05cd3420ac net: mqtt: add mqtt_readall_publish_payload()
This function uses mqtt_read_publish_payload_blocking to perform a
blocking read of the specified number of bytes.

When reading out a payload, the normal use case is to read the
entire payload. This function facilitates that use case.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2019-06-20 13:06:08 +03:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Andrew Boie 86586b2d8d tests: getaddrinfo: set newlib heap size
Some MPU systems require region power-of-two alignment
and can't automatically use remaining RAM for the newlib
heap. Set it for this case. Fixes this test on mps2_an385.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-19 10:57:33 +03:00
Jukka Rissanen 194893d52d tests: net: udp: Add tests for SO_PRIORITY and setsockopt
Verify that user is able to set SO_PRIORITY socket option.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-09 12:54:05 +03:00
Jukka Rissanen 1cbda7d4ac tests: net: socket: register: Close socket after test
The file descriptor was not closed after the test which caused
Coverity to complain about resource leak.

Coverity-CID: 198640
Fixes #16493

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-06 17:49:01 +08:00
Marc Herbert 4afcc0f8af sanitycheck: CONFIG_TEST_USERSPACE / userspace tag cleanup
- Delete CONFIG_TEST_USERSPACE=n no-ops because it's the default
since commit 7b1ee5cf13

- Some tests have a "userspace" tag pretending to TEST_USERSPACE but
don't and vice versa: fix missing or spurious "userspace" tags in
testcase.yaml files.

Tests have a _spurious_ "userspace" tag when they PASS this command
cause none should pass:

  ./scripts/sanitycheck --tag=userspace -p qemu_x86 \
      --extra-args=CONFIG_TEST_USERSPACE=n  \
      --extra-args=CONFIG_USERSPACE=n | tee userspace.log

All tests run by this command must either fail to build or fail to run
with some userspace related error. Shortcut to look at all test
failures:

 zephyr_failure_logs() {
     awk '/see.*log/ {print $2}' "$@"
 }

Tests _missing_ "userspace" tag FAIL to either build or to run with some
userspace related error when running this:

  ./scripts/sanitycheck --exclude=userspace -p qemu_x86 \
      --extra-args=CONFIG_TEST_USERSPACE=n  \
      --extra-args=CONFIG_USERSPACE=n | tee excludeuserspace.log

Note the detection methods above are not 100% perfect because some
flexible tests like tests/kernel/queue/src/main.c evade them with #ifdef
CONFIG_USERSPACE smarts. Considering they never break, it is purely the
test author's decision to include or not such flexible tests in the
"userspace" subset.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-05-30 08:45:39 -04:00
Tomasz Bursztyka c3c6dfaaeb tests/net: Fix IPv6 and UDP test as UDP got stricter on checking header
Now length of the UDP header is checked, and obviously these test were
avoiding setting it properly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-30 13:01:30 +08:00
Nicolas Pitre 4d4cd7e3c8 test/net: fix PTP clock test code
The various ptp_clock_driver_api methods receive a struct ptp_context
not a struct eth_context, and the later must be obtained from a
reference stored in the former. Failing to do so by directly
interpreting driver_data as a struct eth_context instance does end up
corrupting memory past the actual struct ptp_context storage. The test
may still pass as ptp_clock_get() reads from the same out-of-bounds
memory as the previous ptp_clock_set() and therefore the content
matches, and with luck the corrupted memory is not essential to the
completion of the test. But that wasn't my case which allowed me to
find this issue.

Fix this by properly obtaining a reference to the struct eth_context
instance via the actual struct ptp_context, and adding a test like
the one found in eth_tx() to make sure we got the right memory.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-05-30 10:53:24 +08:00
Paul Sokolovsky 4d8941a91d tests: net: getaddrinfo: Add cases for numeric IPv4 addr
And also for AI_NUMERICHOST flag.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-05-29 17:46:56 +08:00
Jukka Rissanen 0c639a8a9a tests: net: socket: Add tests for socket family registration
Make sure that socket registration does something sane.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-10 22:43:27 +03:00
Robert Lubos b8494d9a51 net: lib: mqtt: Enable blocking PUBLISH payload readout
It is convenient to have a blocking version of
`mqtt_read_publish_payload` function, for cases when it is called from
the event handler. Therefore, extend the 'mqtt_read_publish_payload'
argument list with information whether the call should block or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-05-07 22:08:30 -04:00
Tomasz Bursztyka b2b21412ae net/connection: Removing cache feature
There were various flaws in it that motivated its removal:

- No hash collision handling mechanism. In case that would happen, the
behavior of the network connection would be unknown. This is the main
drawback
- The lookup is not that much more efficient than the default one. The
only difference of gain is in connection comparison (a u32t comparison
vs a full connection compare). But the list handling is the same. It's
made worse by the presence of a negatives match array which can be
easily filled in and becomes then fully usless, appart from consuming
CPU. As well as adding a new connection: it requires the whole cache
to be cleared which is unefficient.
- Not memory efficient, even compared to a proper hash table.
Two arrays instead of one etc...

All of this could be fixed by using a proper hash table, though it
remains to be seen if such object could fit in Zephyr core.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-07 15:40:53 +03:00
Maksim Masalski f1f1a9f38a tests: fix unchecked return value in test_net_pkt_basics_of_rw
Inside function test_net_pkt_basics_of_rw result of function call
net_pkt_read_be16 is not checked which might result performance
of the program and cause errors.

Coverity-CID 198003
Fixes #15776

Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
2019-05-07 15:27:31 +03:00
Paul Sokolovsky b2bfcc27b9 tests: socket: misc: Add tests for inet_pton()
Basic testcases for accepting correct input and rejecting invalid.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-05-07 08:30:32 +03:00
Jukka Rissanen 758a2468fd tests: net: mqtt_publisher: Allow compilation in every platform
Fixes the compile errors in various platforms like:
* sam_e70_xplained (too few network buffers)
* galileo, cc3220sf_launchxl and mps2_an385 (missing random number
  generator configuration options)

Fixes #15878

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-04 18:28:37 -04:00
Andrew Boie e9b5fe333e tests: ieee802154: set min_ram
Fix a sanitycheck failure on usb_kw24d512 with the
whitelist removed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-03 14:21:45 -04:00
Andrew Boie 643d689107 tests: mqtt_publisher: enable random numbers
tls_entropy_func() requires an entropy source.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-03 14:21:45 -04:00
Andrew Boie dc27ec3e05 tests: ethernet_mgmt: enable random generator
net_if_ipv6_calc_reachable_time() requires sys_rand32_get().
Enable the test random number generator so the build doesn't
fail.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-03 14:21:45 -04:00
Andrew Boie 543c5c1b7f tests: getaddrinfo: fix stack overflow
This thread was blowing its stack if code coverage was
enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-02 11:13:31 +03:00
Jukka Rissanen 960e6d9504 tests: net: getaddrinfo: Fix test to check the query is sent
As the getaddrinfo() test is suppose to be self contained, then
we will need to install handler for the sent DNS query. After we
receive the query in process_dns() thread, we verify that the
query was sent properly. We do not return DNS reply back to
the caller in this case as we do not want to create DNS server
just for this simple test application. This can be changed later
if we get DNS server functionality in Zephyr network stack.

Fixes #15193

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-04-30 09:56:01 -07:00
Ravi kumar Veeramally 7fbe087d8d net: tests: ipv6_fragment: Use NET_DBG instead of DBG
ipv6_fragment tests registered log module but still use DBG
macro of printk. Replaced them with NET_DBG.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-04-26 10:45:45 +03:00
Ravi kumar Veeramally d19097f8c5 tests: net: Add more tests to ipv6 fragmentation
IPv6 fragmentation test case for reassembly.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-04-26 10:45:45 +03:00
Jukka Rissanen fcf392c6c8 tests: net: all: Add more options to catch-all test
Add more Kconfig options to prj.conf file. In the future we need
to compile also in other hw than qemu_x86 in which case we need to
create separate test cases for those configurations.

Fixes #15282

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-04-23 10:29:38 +03:00
Jukka Rissanen 6bf369f306 tests: net: pkt: Verify that net_pkt_write() writes correct data
Write the net_pkt using net_pkt_write() and then verify that the
data is actually written into net_buf.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-04-17 10:50:09 -04:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Andrew Boie 7b1ee5cf13 tests: CONFIG_TEST_USERSPACE now off by default
Unlike CONFIG_HW_STACK_PROTECTION, which greatly helps
expose stack overflows in test code, activating
userspace without putting threads in user mode is of
very limited value.

Now CONFIG_TEST_USERSPACE is off by default. Any test
which puts threads in user mode will need to set
CONFIG_TEST_USERSPACE.

This should greatly increase sanitycheck build times
as there is non-trivial build time overhead to
enabling this feature. This also allows some tests
which failed the build on RAM-constrained platforms
to compile properly.

tests/drivers/build_all is a special case; it doesn't
put threads in user mode, but we want to ensure all
the syscall handlers compile properly.

Fixes: #15103 (and probably others)

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie 027b6aaf89 tests: set userspace tag for all tests that use it
This lets us quickly filter tests that exercise userspace
when developing it.

Some tests had a whitelist with qemu_cortex_m3; change
this to mps2_an385, which is the QEMU target with an
MPU enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie ce6b80470d net: add missing syscall for gethostname()
We need all the socket APIs to work from user mode.
tests/net/socket/misc now runs in userspace.

Fixes: #15227

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie 1d0369f606 tests: net: getnameinfo: run in user mode
The test is designed to run in user mode, but was disabled
for some reason.

Re-enable, and add mps2_an385 to the whitelist as this is
the QEMU target that emulates an MPU.

Fixes: #15228

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie 0ccaa5d908 tests: mqtt_packet: run in user mode
Various globals for the test cases have been moved to
the ztest memory domain data section via ZTEST_DMEM tags
so that user mode can access them.

Some anonymous arrays whose address was being placed in
the msg_subackX structs have been split out so they
are in ztest memory domain.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-03 13:47:45 -04:00
Patrik Flykt 21358baa72 all: Update unsigend 'U' suffix due to multiplication
As the multiplication rule is updated, new unsigned suffixes
are added in the code.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Ravi kumar Veeramally 65d100e7f0 tests: net: Add more tests to ipv6 fragmentation
IPv6 fragmentation test case without any extra header (HBHO)
added.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-03-26 15:55:15 -04:00
Jukka Rissanen 079a2919cb tests: socket: tcp: Increase the buf count
With default buf count, we ran out of bufs in connect() in
test_v6_sendto_recvfrom().

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-26 07:29:26 -05:00
Ravi kumar Veeramally 2f941d2630 tests: net: ipv6: Add one more test case
Test case added for IPv6 neighbors. This will add more than
CONFIG_NET_IPV6_MAX_NEIGHBORS neighbors. Network stack should
remove oldest neighbor which is in STALE state and it should
add new neighbor. So call to net_ipv6_nbr_add() should succeed.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-03-25 22:49:52 -04:00
Tedd Ho-Jeong An 2d8ac0cf5e tests: net: mld: Check return after updating packet
This patch checks the return value after updating the packet.

Fix Bugs: #14821
Coverity CID: 196635

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-03-25 15:53:13 -04:00
Tomasz Bursztyka cf322c44db net: Switch usage of net_pkt_get_reserve to net_pkt_alloc
Some places were still using the old allocator. Using the new one does
not change any behavior. This will help to remove the useless data_len
attribute in net_pkt which legacy allocator was still setting.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 03bfc5dd0f net/context: Remove token parameter from net_context_send/sendto
And also to the relevant callbacks.

That parameter is not used anywhere so it is useless.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka d6d52ce9e5 net/pkt: Remove _new suffix to net_pkt_write functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka a25f054cbd net/pkt: Remove _new suffix to net_pkt_read functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka f8a091104e net/pkt: Remove _new suffix to net_pkt_get_data_new function
Now that legacy - and unrelated - function named net_pkt_get_data has
been removed, we can rename net_pkt_get_data_new relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 820f3ad006 net/ipv6: Replace legacy net_ipv6_create by the new one
Thus removing the legacy one, and renaming the new one to legacy name.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka ca58b4c761 net/ipv4: Replace legacy net_ipv4_create by the new one
Thus removing the legacy one, and renaming the new one to legacy name.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 172fe5a87b net/context: Remove _new suffix on net_context_send/sendto functions
Now that legacy functions are removew, let's rename the new functions by
removing the _new suffix.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Andrei Emeltchenko 99403c5b13 net: ethernet: Define and use Ethernet frame and datagram size
Remove magic numbers from Ethernet drivers and tests by defining
NET_ETH_MAX_DATAGRAM_SIZE and NET_ETH_MAX_FRAME_SIZE.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-15 06:44:13 -05:00
Paul Sokolovsky f38c4c97ce tests: socket_helpers: Use zsock_ prefixed socket functions
Don't depend on CONFIG_NET_SOCKETS_POSIX_NAMES being defined (e.g.,
it's going to conflict with POSIX API).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-03-15 06:00:21 +01:00
Jukka Rissanen dc41aad2a5 tests: net: mld: Check null ptr dereference
If pkt allocation fails, then prepare to handle NULL pointer.

Coverity-CID: 195844
Fixes #14405

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-14 13:01:01 +01:00
Tedd Ho-Jeong An 401a598503 tests: net: iface: Handle pkt allocation failure
This patch handles null pointer when packet allocation fails.

Fixes: #14390
Coverity-CID: 195903

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-03-14 12:06:21 +01:00
Jukka Rissanen 6301ae74d9 tests: net: tcp: Check null ptr dereference
If pkt allocation fails, then prepare to handle NULL pointer.

Coverity-CID: 195819
Coverity-CID: 195860
Coverity-CID: 195921

Fixes #14412
Fixes #14399
Fixes #14388

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-13 05:39:41 -05:00
Jukka Rissanen 55cd97bc43 tests: net: dhcpv4: Check null ptr dereference
If pkt allocation fails, then prepare to handle NULL pointer.

Coverity-CID: 195880
Coverity-CID: 195816

Fixes #14413
Fixes #14395

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-13 05:38:26 -05:00
Jukka Rissanen bafdf5b329 tests: net: ipv6: Check null ptr dereference
If pkt allocation fails, then prepare to handle NULL pointer.

Coverity-CID: 195835
Fixes #14409

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-13 05:34:46 -05:00
Thomas Stenersen 7516476386 kconfig: Use depend on instead of select to avoid kconfig loop
Remove use of select to "force" enabling other configs in subsys/fs
and subsys/net/l2. The forcing will cause infinite kconfig recursion.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2019-03-12 19:42:40 +01:00
Tedd Ho-Jeong An 922f53864f tests: net: mqtt: Fix the error handling aftre read
If the rc = -EAGAIN from mqtt_read_publich_payload(), it shouldn't be
used in memcpy() since it is a negative value, and instead, it should
try to read again.

Fix: #13825
Coverity-CID: 191002

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-03-09 10:50:25 -05:00
Tomasz Bursztyka 462fc32f7c tests/unit: Switch vlan test to new net_pkt/net_context API
Use the new net_pkt allocator. Fix a small leak in the test as well.

No need to build the net_pkt, just send the data directly through
net_context_sendto_new()

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka a03efe1928 tests/net: Fix vlan test timeout values
s/0/K_NO_WAIT for all timeouts

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka ab1d38c3c3 tests/net: Reducing utils test by removing redundant ones
The very first test was basically testing the checksum calculation. And
that's already tested in more relevant tests. It was also trying in a
cumbersome way to generate packets scattered over many net_buf. But
that's also already tested in various other tests, and it's not at all
part of core utils anyway.

In any case, that all redundant, so let's remove it.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 6a1387d1cf tests/net: Switch tx timestamp test to new net_context API
No need to build the net_pkt, just send the data directly through
net_context_sendto_new()

Use the new net_context option to enable timestamping of outgoing
packet (NET_CONTEXT_TIMESTAMP).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 3e6e0922fe tests/net: Fix tx timestamp test timeout values
s/0/K_NO_WAIT for timeouts

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 3fb49d89d6 tests/net: Switch traffic class test to new net_context API
No need to build the packet by ourselves.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 5cff958a4f tests/net: Fix traffic class test timeout values
s/0/K_NO_WAIT for all timeouts

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka eca8f1072a tests/net: Switch tcp test to new net_pkt API
Switch to new allocators and r/w functions.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 344962270e tests/net: Switch promiscuous test to new net_pkt API
Switch to new allocator and write function.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 2a18ec99bf tests/net: Switch MLD to new net_pkt API
Switch to new allocators and r/w functions.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 07d34b0f3e tests/net: Replace the legacy net_pkt API test by the new one.
Just a quick rm/mv. The new API is going to be the only one, so legacy
test can disappear.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka da37c67aba tests/net: Switch ipv6 fragmentation test to new net_pkt API
Switch to new allocators and r/w functions.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 07f9040ebb tests/net: Switch ipv6 test to new net_pkt API
Switch to new allocators and r/w functions.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 32dfb13b03 tests/net: Switch iface test to new net_pkt API
No need to play with net_buf by ourselves.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 8e8bd65783 tests/net: Switch icmpv6 test to new net_pkt API
No need to play with net_buf by ourselves.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka ae94e2ec1d tests/net: Switch context test to new net_context API
No need to build the net_pkt, just send the data directly through
net_context_sendto_new()

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka a05c29f0db tests/net: Fix context test timeout values and function calls
s/0/K_NO_WAIT for all timeouts
And fix tcp context connect call (it's not net_context_listen obviously,
and one parameter was missing).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 8b857dadc5 tests/net: Switch checksum test to new net_context API
No need to build the net_pkt, just send the data directly through
net_context_sendto_new()

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Ravi kumar Veeramally a391daa95a net: tests: Migrate ARP tests
Migrate ARP tests to new net_pkt API.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-03-08 07:18:19 -05:00
Ravi kumar Veeramally 746618460b net: tests: Migrate UDP tests
Migrate UDP tests to new net_pkt API.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-03-07 07:17:36 -05:00
Paul Sokolovsky 1b837d64de tests: socket: tcp: Test handling of EOF condition on socket
If peer socket closed, the other side should get 0 from recv(), and
should get in stable manner (no matter how much time went from the
closure and/or how many times recv() is called).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-03-06 15:57:40 -05:00
Ravi kumar Veeramally 0aa61651ce net: tests: Fix DHCPv4 tests
net_pkt_alloc_with_buffer() takes IP header and protocol header
length while calculating total length internally. Need not
specify explicitly. Also mutex was not properly initialized.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-03-05 08:29:02 -05:00
Maksim Masalski b324f35e61 macros: deleted macros SECONDS(), MSEC(), USEC()
Changed everywhere these macros to the K_MSEC(), K_SECONDS()

Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
2019-03-04 19:04:21 -05:00
Sebastian Bøe 4e5300ba7f cmake: Drop all in-tree usage 'set_conf_file'
Port all users of 'set_conf_file' to use the built-in rules
instead. This follows the convention-over-configuration principle to
make the system as a whole simpler and more consistent.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-03-01 09:44:09 +01:00
Ravi kumar Veeramally c4f2ab143d net: tests: Migrate DHCPv4 tests
Migrate DHCPv4 tests to new net_pkt API.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-26 02:25:14 +01:00
Tomasz Bursztyka ca7b3b3703 net/ieee802154: Switch fragmentation support to new net_pkt API
- differentiating actual "fragment" to buffer element from a net_pkt
- instead of copying data (and thus allocating buffer) let's just take
the fragment buffer and put it into result packet.
- fixing compilation issue in relevant test

It's more efficient that way, as we use already allocated fragment
buffer instead of reallocating/deallocating after each fragment
reception.

A possible optimization would be to calculate the actual size + header
difference if only the actual size is close to the target size.
It would avoid to get a dry run of the header decompression for each
fragment received. The difficulty being in finding the sweet spot when
it is relevant to calculate the header difference.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-23 07:44:59 -05:00
Paul Sokolovsky 49341e0065 tests: socket: Add test for getnameinfo()
Basic test for IPv4/IPv6 addresses conversion.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-02-19 17:34:57 -05:00
Jukka Rissanen d4d61895b8 tests: net: ipv6_fragment: Fix interface index values
The test needs to use interface index starting from 1.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-18 15:10:54 -05:00
Jukka Rissanen 299832738e tests: net: ip-addr: Fix interface index values
The test needs to use interface index starting from 1.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-18 15:10:54 -05:00
Jukka Rissanen 3043b50403 tests: net: dns: Fix test as the interface index starts from 1
The test was using index 0 which is no longer correct.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-18 15:10:54 -05:00
Carlos Stuart 75f77db432 include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.

This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.

All files that use these macros have been updated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-14 22:16:03 -05:00
Tomasz Bursztyka 2b22b71e42 net/pkt: Remove useless legacy net_frag_linearize function
Now that the stack does not use this function, it can be removed
safely.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka bc5411816a net/pkt: Remove useless legacy net_pkt_append_memset function
Now that the stack does not use this function, it can be removed
safely.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 1fab039102 net/pkt: Remove useless legacy net_pkt_split function
Now that the stack does not use this function, it can be removed
safely.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 09b782a82d net/pkt: Remove useless legacy net_pkt_pull function
Now that the stack uses the new API from net_pkt for pulling, no need
to keep the legacy one around.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka c65304f088 net/pkt: Rename net_pkt_copy_new to net_pkt_copy
Now that legacy net_pkt_clone function has been removed, the new
function can be renamed accordingly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 895c8eb0e3 net/pkt: Remove useless legacy net_pkt_copy/_all functions
Now that the stack uses the new API from net_pkt for copying, no need
to keep the legacy one around.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 38a3e79f9b net/pkt: Rename net_pkt_clone_new to net_pkt_clone
Now that legacy net_pkt_clone function has been removed, the new
function can be renamed accordingly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka a6426620da net/private: Rename net_hexdump_frags to net_pkt_hexdump
And remove the parameter "full" as there is no "ll reserve" distinction
anymore. The parameter was unused since the ll reserve concept removal.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 909eb7271a net/udp: Remove net_pkt_udp_data() function
It is now useless and can be replaced by net_udp_get_hdr() directly, in
the 2 unit tests it was used.

Removing as well the dbg function too_short_msg()

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 8ceedafdc4 net/udp: Switch net_udp_get/set_hdr to new net_pkt API
Let's use the new API for these 2 functions. Note that in some places,
using these functions is under-optimized (like in llmnr-responder in
dns: it gets the ip/udp headers already from the recv callback. That
will need to be taken care of later).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 674d7c47b4 net/udp: Remove useless net_udp_set_chksum
It was only used in ipv6_fragment unit test and could be easily
replaced.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka d8624513e6 net/icmp: Remove useless icmp functions using legacy net_pkt API
net_pkt_icmp_data was only used in ipv6 unit test and could be easily
replaced.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 04966ac10d net/tcp: Remove useless tcp function using legacy net_pkt API
net_pkt_tcp_data was only used in tcp unit test and could be replaced by
local net_tcp_get_hdr.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka fd1401495b net/tcp: Move net_tcp_set_hdr() away from net core
Only the unit test needs it now, so let's move it there.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 1a54cabe5e net/ipv4: Rename net_ipv4_finalize since legacy version disappeared
s/net_ipv4_finalize_new/net_ipv4_finalize

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 0c80a84bc7 net/ipv6: Rename net_ipv6_finalize since legacy version disappeared
s/net_ipv6_finalize_new/net_ipv6_finalize

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka b93df74fa2 net/context: Let's use the new net_ipv4_finalize
And removing the legacy and unused one.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 31a079023f net/context: Let's use the new net_ipv6_finalize
And removing the legacy and unused one.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 78198810ac net/tcp: Move net_tcp_get_hdr() away from net core
Only the unit test needs it now, so let's move it there.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka 024a7e0502 net/sockets: Adapt net_pkt_get_src_addr to new net_pkt API
This function is only used in sockets, thus making it a private function
of socket library and renaming it relevantly.

Note that sockets should be reviewed at some point to avoid using such
function: zsock_received_cb() already get the ip header and the protocol
header, so it could grab the src addr/port from there. It would be way
more optimized to do so, since net_pkt_get_src_addr is costly as it
parses all over again the ip/protocol headers.

utils unit test is updated and the test of the former
net_pkt_get_src_addr/net_pkt_get_dst_addr are removed.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Jukka Rissanen 8de351c45f tests: net: ipv6: Fix the DAD failure in the test
The DAD was failing because we received the DAD network packet
even when should not had received it. Fix it by discarding all
the ICMPv6 NS packets that we receive.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-08 14:24:03 +02:00
Tomasz Bursztyka 499ffd6573 net/ethernet: Remove inserted L2 header buffer
The packet can be referenced somewhere else and letting the newly added
L2 header will generate corrupt packet. If the same packet is being
resent, ethernet will add again its L2 header. Thus the need to remove
such L2 header every time a packet has been sent, successfully or not.

Fixes #12560

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-08 14:24:03 +02:00
Andrei Gansari 0730ab8bef tests: CONFIG_NET* fixup
Fixed typo: CONFIG_NET_NET_PKT_LOG_LEVEL_DBG, removed extra _NET.
Removed debug macro CONFIG_NET_DEBUG_NET_PKT that is not used.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2019-02-08 13:57:55 +02:00
Paul Sokolovsky 36e437f537 tests: socket: misc: Add test for gethostname()
Just a basic test.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-02-08 10:39:30 +02:00
Jukka Rissanen 85c8c0fe3c tests: net: context: Fix invalid address family test
The test had hard coded address family with value 4. This test
was failing as we have now AF_CAN family with value 4. Use 99
as an invalid address family value instead.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-07 18:08:27 +02:00
Ravi kumar Veeramally f0fb82dce9 net: ip: Add protocol family type to conn handler
As we are adding more protocol families and protocol types
to connection handlers, some values might be same across
different types. Current connection handler only stores
proto type to match the handler, which is not enough if
we add more types. Also combination of family and types
may vary too. So adding family to connection handler to
figure out best match.

Also changing proto variable in net_conn from u8_t to u16_t.
net_context has 16 bit proto.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-07 14:43:30 +02:00
Robert Lubos 418b9236fa net: lib: mqtt: Get rid of _sock suffix
As the legacy library has been removed, we no longer need to
differentiate betwen MQTT implementations. Therefore align the library
folder name with other libraries and remove the `_sock` suffix.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-02-05 11:05:26 -05:00
Ravi kumar Veeramally 1e47f26d1c net: coap: Remove legacy CoAP implementation
As we are removing net_app and net_pkt based libraries and
applications, CoAP legacy based libraries and apps are moved
to socket based implementations. So removing legacy CoAP.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-04 16:49:59 -05:00
Paul Sokolovsky 92962ddc5e tests: socket: poll, select: Fix non-blocking timing tests
As written originally, the tests assumed that if k_uptime_get_32()
returns times in milliseconds, that it also has millisecond
resolution. That however doesn't have to be the case, and indeed,
default timer interrupt period used by Zephyr is 10ms, and so system
time is incremented in such units. So, instead of "<= 1" tests to
account for timing increment, use "<= FUZZ".

For blocking tests, increase the timeout from previously used 10ms,
so we can reliably tests delays under the conditions described.

Also, enable CONFIG_QEMU_TICKLESS_WORKAROUND. Most other
timing-related tests have this enabled, and it may affect
stability of QEMU testing too.

Fixes: #12994

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-02-04 15:31:10 -05:00
Tomasz Bursztyka 968d423a44 net/pkt: Allocate relevant size on AF_UNSPEC
In case of Ethernet, if the requested size is larger than MTU and if
AF_UNSPEC is provided, the allocator will need to take into account
the ethernet header size which is not accounted in the MTU.

Other current L2 do not follow that rule as their MTU is based on IP
one (IPv6 most of the time). What they declare as MTU is the full frame
size they handle (minus the FCS for instance in 15.4). So with
AF_UNSPEC, such assumption on L2 header size is unrelevant.
(On 15.4 the header size is variable anyway and cannot be known until
the frame is parsed).

Fixes #12982

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-04 17:15:52 +02:00
Tomasz Bursztyka 4b78a251d7 net/context: Make recv_cb providing the ip and protocol headers
If status is 0, both ip_hdr and proto_hdr will own a pointer to the
relevant IP and Protocol headers. In order to know which of ipv4/ipv6
and udp/tcp one will need to use respectively net_pkt_family(pkt) and
net_context_get_ip_proto(context).

Having access to those headers directly, many callbacks will not need
to parse the packet again no get the src/dst addresses or the src/dst
ports. This will be change after this commit.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka e4ebe486b8 net/ip: Let's make public the 2 utility unions for ip/proto headers
Though these are currently used by the core only, it will be then used
by net_context as well. This one of the steps to get rid of net_pkt's
appdata/appdatalen attributes.

Also normalizing all ip/proto parameters name to ip_hdr and proto_hdr.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka 6596c304fb test/net: Quick sample explaining/testing the new net_pkt buffer API
This goes through basic allocation, atomic read/write, data
getter/setter and cloning/copying.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka 99dbe467e5 tests/icmpv6: Real packet length must be given
The test counts the '\0' of the data copied, though it does not belong
to the packet.

Since the test by-passes net_ipv6_input, which would update the packet
length according to what is in the IPv6 header, the checksum calculation
fails.

Before, checksum calculation used to grab the length from IPv6 header,
but that changed to use net_pkt_get_len(): that one must provide the
real lenth.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka 8d21c68718 net/tcp: Switch rest of TCP to new net_pkt API
Only next to be removed functions like net_tcp_set_checksum() are left
untouched. All the rest is switched.

Adding net_tcp_finalize() to follow the same logic as for UDP and else.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka baa9784008 net/tcp: Apply connection callback signature change
This proovse to drastically reduce runtime overhead as it does not need
to parse IP nor TCP header all over again in a lot of places.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka 118a0f0d22 net/conn: Change callback signature to pass TCP/IP headers
As these were parsed already by IPv4/6 input functions let's use them.

Applying the change on trivial UDP usage. TCP usage will have its own
commit.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka e04914a963 net/ipv6: Switch sending fragmented IPv6 packet to new API
This optimizes the memory quite a bit since we do not need to clone nor
split the original packet at any time.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka 88f5672e4c net/ipv6: Switch MLD join, leave and report to new net_pkt API
Most of the code had to be reworked due to the new API: it's more
logical to do everything sequentially (first headers, then MLD part)
than the contrary with inserting headers at the end.

Using get_data/set_data as well it makes the code clearer.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka ae7243b0d5 net/ipv6: Switch RA msg handler to new net_pkt API
Reworking the logic to reduce the amount of variables.
This part was heavier to change as it was not accessing the headers
directly but instead was read parts by parts.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka 9a6027ba5c net/icmpv6: Improve callback signature to pass icmp header
In nbr part, this is a useful information. Since net_icmpv6_input has
already parsed the icmpv6 header, let's get pass it, instead of
retrieving/parsing it again in various handler functions.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka 47f3b339eb net/icmpv6: Rework relevant signatures to pass ipv6 header pointer
This is meant to remove the need for macro NET_IPV6_HDR(), since we
don't know in future if accessing the header that way will be valid.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka 86ac993e0c net/ipv6: Rework input function
Use the new net_pkt API to proceed through IPv6 header and all the
extension header as well.

Use udp/tcp input functions relevantly, and call net_conn_input
afterwards.

Note: This commit temporarly disable IPv6 fragmentation support
in the code directly. Which support will be re-enabled afterwards.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka c0db7efff9 tests/net: Avoid using net_udp_get_chksum()
checksum_offload is now the only one using that function, let's get rid
of such usage.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Jukka Rissanen d1162600e9 net: app: Remove net-app API files
The net-app API is removed. Users should use the BSD socket API
for application development.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-01 12:29:21 +02:00
Jukka Rissanen 8b8d1dd300 tests: net: dns: Temporarily disable IPv6 query test
The disabled test causes crash in qemu_x86, so temporarily disable
it until a proper fix is found.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-01-31 08:53:58 -05:00
Vincent Wan ef049cc976 tests: net: port mqtt tests to cc3220sf_launchxl
This commit makes the necessary changes to allow the following tests
to run on cc3220sf_launchxl:
- mqtt_packet
- mqtt_publisher
- mqtt_subscriber
- mqtt_pubsub

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-01-31 06:36:08 -05:00
Jukka Rissanen 34b07b99da tests: net: context: Fix tests when using locking
There was a false timeout error because we did not check the
return value correctly. This issue is seen now because code
flow in core IP stack is happening in different order than
before.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-01-31 11:20:26 +02:00
Tomasz Bursztyka 12995b95c2 net/ip: Protocol family do not have to follow any other OS's value
It is the macro name that matters, not its value. Here, that will help
to save 1 bit in struct net_pkt later on.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-01-30 16:27:18 +02:00
Daniel Glöckner d678f309b8 net: pkt: convert remaining users of ref to atomic_ref
The previous commit replaced the net_pkt element ref with an element
atomic_ref. CI tests turned up more places where ref was used directly.
This commit converts them to use the new element.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
2019-01-29 09:22:14 +02:00
Jukka Rissanen 4043909d69 net: http: Remove HTTP client and server APIs
The old legacy APIs use net-app library and as that is being
removed, then the dependencies need to be removed also.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-01-25 11:21:20 -05:00
Jukka Rissanen 1cba0161ed net: websocket: Remove the websocket as HTTP APIs are removed
Remove the experimental websocket code as it uses HTTP APIs
which are being removed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-01-25 11:21:20 -05:00
Paul Sokolovsky 858684a72c tests: socket: select: Add actual tests for select()
Ported from earlier poll() test.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-25 10:35:39 +02:00
Paul Sokolovsky 9ff4d47a8f tests: socket: poll: Add test for poll()
Basic test for poll() behavior. UDP sockets are used for simplicity
so far (poll-related paths for UDP and TCP are similar, though later
adding TCP explicitly for full coverage may be useful).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-25 10:35:39 +02:00
Paul Sokolovsky 3339de34eb tests: net: socket: Add "socket" tag to testcase.yaml's
So it was easy to run all socket tests without remembering
the exact path(s).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-25 10:35:39 +02:00
Paul Sokolovsky 3ede9feb97 tests: net: socket: socket_helpers.h: Factor out socket test helpers
The idea is that we should have many, many tests. The only reasonable
way to achieve that is by making tests easy and pleasant to write,
and that requires common, easy to reuse infrastructure.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-25 10:35:39 +02:00
Paul Sokolovsky 0d0ce47c4e tests: net: socket: udp: Refactor and elaborate tests.
1. Consistently use prepare_sock helpers.
2. Test not just client->server sending, but sending reply.
3. Send large packets (>1 net_buf fragment), not just small.
4. Check POSIX behavior on recv()ing datagram incompletely (the rest
should be discarded and next recv() should read next datagram.
5. More cleanroom testing, e.g. explicitly reinitialize input params
on each call (without assumptions that they're left with suitable
values from previous calls), clear input buffers before each read
operations, etc.
6. Reformat code. Previously it was very sparse, giving long test
functions, and thus impression that tests are complicated and hard
to write.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-25 10:35:39 +02:00
Paul Sokolovsky 10442a3f9f tests: socket: select: Basic test for select().
Currently actually just tests fd_set manipulation.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-24 17:14:43 +02:00