Commit graph

377 commits

Author SHA1 Message Date
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
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
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
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
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 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
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 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 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
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 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
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
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
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
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
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
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 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 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 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
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
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
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
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
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
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 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 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
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
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
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
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 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
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
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 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
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
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
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
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
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
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
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
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
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
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
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
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
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
Anas Nashif 5060ca6a30 cmake: increase minimal required version to 3.13.1
Move to latest cmake version with many bug fixes and enhancements.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-01-03 11:51:29 -05:00
Jukka Rissanen 86689030e8 net: Clarify logging in networking code
Remove network specific default and max log level setting
and start to use the zephyr logging values for those.

Remove LOG_MODULE_REGISTER() from net_core.h and place the
calls into .c files. This is done in order to avoid weird
compiler errors in some cases and to make the code look similar
as other subsystems.

Fixes #11343
Fixes #11659

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-07 12:00:04 +02:00
Paul Sokolovsky 9aafe38828 tests: socket: Bump number of available fd's
These tests require much bigger number than default 4.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-11-04 22:04:11 +01:00
Reto Schneider 7eabab2f5d 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 every project "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 in the samples (and again, in
the tests folder) folder, small manual adjustments have been done.

Signed-off-by: Reto Schneider <code@reto-schneider.ch>
2018-10-27 21:31:25 -04:00
Jukka Rissanen f3f04bf9eb tests: net: Convert to new logging system
Use new logging system with support for network log level.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-04 14:13:57 +03:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Jukka Rissanen a81aad9756 tests: net: Run networking tests only for selected platforms
Run networking tests for native_posix, qemu_x86 and qemu_cortex_m3
platforms only as the tests are generic enough so no need to run
them in real physical device.

Fixes #9623 #9614 #9622 #9621 #9618

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-29 10:57:56 -04:00
Sebastian Bøe 55ee53ce91 cmake: Prepend 'cmake_minimum_required()' into 'app' build scripts
Prepend the text 'cmake_minimum_required(VERSION 3.8.2)' into the
application and test build scripts.

Modern versions of CMake will spam users with a deprecation warning
when the toplevel CMakeLists.txt does not specify a CMake
version. This is documented in bug #8355.

To resolve this we include a cmake_minimum_required() line into the
toplevel build scripts. Additionally, cmake_minimum_required is
invoked from within boilerplate.cmake. The highest version will be
enforced.

This patch allows us to afterwards change CMake policy CMP000 from OLD
to NEW which in turn finally rids us of the verbose warning.

The extra boilerplate is considered more acceptable than the verbosity
of the CMP0000 policy.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-08-15 04:06:50 -07:00
Paul Sokolovsky 028aae1ec9 net: config: Rename Kconfig options to correspond to library name
This finishes refactor of splitting off net_config library name from
net_app library, started in c60df1311, c89a06dbc. This commit makes
sure that Kconfig options are prefixed with CONFIG_NET_CONFIG_
instead of CONFIG_NET_APP_, and propagates these changes thru the
app configs in the tree.

Also, minor dependency, etc. tweaks are made.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-08-13 18:42:31 -07:00
Andrew Boie 18cec245ba net: introduce system calls for zsock socket APIs
Add system calls for the zsock implementations of socket,
close, bind, connect, listen, accept, sendto, recvfrom,
fcntl, poll, inet_pton, and getaddrinfo.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-08-13 07:19:39 -07:00
Anas Nashif 1f2627a638 tests: net: style, tag, and category fixes
Fix coding style, test tags and use categories.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-25 14:18:15 +05:30
Paul Sokolovsky e564d58b7d tests: socket: udp: Close test sockets
Close test sockets in test_send_recv_2_sock() to avoid Coverity
warnings.

Coverity-Id: 182764
Fixes: #6107

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-04-25 10:26:19 +03:00
Paul Sokolovsky 1d1db121d3 tests: socket: udp: Tighten up error checking
Add zassert's to check results of intermediate operations like
socket/bind/connect. Also, use symbolic expressions instead of
constants like 4 (for data length).

Coverity-Id: 182765, 182767
Fixes: #6104, #6106

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-04-23 15:26:43 +03:00
Stig Bjørlykke e8bcc6f1f0 tests: socket: Free resources with freeaddrinfo
In Zephyr this has no effect because getaddrinfo() returns a pointer
to a static array, but Coverity scan checks for this pattern.

Coverity-CID: 185273
Coverity-CID: 185279

Fixes #7085
Fixes #7091

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2018-04-20 10:48:52 +03:00
Paul Sokolovsky edc048e06f tests: socket: udp: Make sure client sockaddr fully initialized
Previously, some fields like sin6_scope_id weren't explicitly
initialized. Such aren't really used, but to keep Coverity
happy, let's zero out the entire address structure.

Coverity-Id: 182763
Fixes: #6108

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-04-20 10:47:27 +03:00
Stig Bjørlykke 97b83ffc2c net: sockets: Check for errors from dns_get_addr_info
When dns_get_addr_info() returns an error it does not call the
resolve callback, and thus the semaphore will not be given.

This fix will avoid a deadlock situation for various errors.

Added some small tests for getaddrinfo().

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2018-04-03 14:15:43 +03:00
Patrik Flykt 41d21bd123 tests: socket: Enable loopback and net tests
Enable the loopback driver and set up network testing so that it
will not require a SLIP driver. Move values from the extra test
config so that they are always enabled.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-03-29 12:39:43 +03:00
Stig Bjørlykke 7c9c825138 net: sockets: Support MSG_PEEK flag in zsock_recvfrom
Add support for MSG_PEEK flag in recv and recvfrom.

This flag is needed when using non-zephyr embedded applications with
Zephyr's socket API.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2018-03-20 15:55:04 +02:00
Anas Nashif 23f81eeb42 tests/samples: fixed yaml syntax
Use a map directory, avoid the list which makes parsing a bit
cumbersome.

Fixes #5109

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Kumar Gala 6b38f57225 Add missing license and copyright headers
The following files didn't have any copyright or license headers on them
when they got contributed.  So add the SPDX Apache license and
appropriate copyright info:

boards/arm/stm32l476g_disco/pinmux.c
samples/basic/threads/src/main.c
tests/net/socket/tcp/src/main.c

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-12-05 08:21:05 -06:00
Paul Sokolovsky d775ab5c26 tests: socket: Make runnable with sanitycheck
Relies on loopback network interface added recently and being able
to run QEMU without connecting to host networking.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-11-21 06:54:01 -05:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Aska Wu a9b2d57664 tests: sockets: Check the value-result argument
The addrlen of accept() and recvfrom() should be updated to the actual
value of source address.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-11-06 20:59:05 +02:00
Aska Wu 34b5ca6122 tests: sockets: Add TCP test cases
- Test ipv4/ipv6 send() and recv().
- Test ipv4/ipv6 sendto() and recvfrom().
- Test ipv4/ipv6 sendto() and recvfrom() with NULL dest address.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-11-01 15:08:39 +02:00
Aska Wu 939aad913f tests: sockets: Make udp test cases self-contained
Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-10-30 14:53:13 +02:00
Anas Nashif 0356590df5 tests: samples: fix yaml syntax
Fix indentation and syntax and make it pass yamllint tool.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-15 08:15:00 -04:00
Aska Wu 7c60eadd58 tests: sockets: Add tests of sendto() and recvfrom()
- Add test cases of ipv4/ipv6 sendto() and recvfrom()
- Set the main stack size to 2048 to enable both ipv4 and ipv6 on
  qemu_x86.
- Use net app for network setup.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-10-03 14:40:05 +03:00
Aska Wu e7acafd967 net: sockets: Fix a link error if CONFIG_NET_TCP is not enabled
Always support net_pkt_sent() and net_pkt_set_sent().

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-08-04 16:50:37 +03:00
Anas Nashif ca0ad13a61 net: enable SLIP only on QEMU targets
In many networking tests we had to configure SLIP in the prj.conf
leaving those configurations Qemu specific. This change enables SLIP for
QEMU targets automatically and allows reuse of prj.conf for multiple
boards.

Additionally, the TUN options is removed. This option was not used
anywhere.

To enable self-contained networking tests that do not depend on SLIP, we
introduce the new option NET_TEST which disables TAP and allows testing
in QEMU without the need for a host interface.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-26 10:57:48 -04:00
Kumar Gala ebc948d818 tests: net: limit tests to boards with enough memory to build them
A number of the network tests have minimal memory requirements that not
all boards are able to meet.  Add in those memory requirements so we
don't attempt to build these tests for those platforms.  Utilized the
frdm_kl25z (with 16K of memory) and cc2650_sensortag (with 20K) to test
the limits.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-25 15:51:18 -05:00
Jukka Rissanen 45eac217a2 net: tests: Enable net tests for all suitable platforms
Instead of only running net tests in qemu_x86, enable those
tests in all suitable platforms. The tests are disabled for
bbc_microbit as that platform does not have enough memory.

The tests/net/arp and tests/net/ieee802154/l2 are disabled
for qemu_xtensa as the qemu crashed when running the tests.
For tests/net/all there was a weird build error for qemu_xtensa
so that test is also disabled for that platform.

Increased the trickle timeout to 3 secs in tests/net/trickle as
occacionally there was timeout error in qemu_cortex_m3 when the
test was run.

Jira: ZEP-2398

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-25 10:46:44 -04:00
Anas Nashif 6c05ccb226 tests: convert testcase.ini to new format
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-28 09:20:36 -05:00
Paul Sokolovsky b650fa8a72 tests: net: Add test for Sockets API UDP socket/bind/connect/send/recv
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-06-28 16:07:55 +03:00