Commit graph

101 commits

Author SHA1 Message Date
Jukka Rissanen 6924b0d49a tests: net: Exclude native_posix because of socket service
The native_posix board does not work well with eventfd so disable
it with tests that use socket service API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Robert Lubos 09c4328b2a tests: net: dhcpv4: server: Fix tests after including client ID
Client ID option is now expected in Request/Ack responses so tests need
to be updated accordingly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-03-22 10:24:15 +01:00
Alberto Escolar Piedras ac1610ec72 tests/net: Use hwmv2 native targets identifiers
For the 64 bit targets, change identifiers to the new hwmv2 ones

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-03-15 16:13:12 +01:00
Fin Maaß 1b76f828c9 tests: net: dhcpv4: add comments to sample packets
To make the content of the sample packets more more
understandable, comments describing it are added.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-03-05 10:22:21 -05:00
Matthias Breithaupt 2f84e7be83 tests: net: dhcpv4: tests for encapsulated vendor specific option callbacks
Add tests for the encapsulated vendor specific option callback API.
These test cases are focused on correct parsing of encapsulated
vendor specific options.
The sample DHCP messages have been extended accordingly.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Co-authored-by: Fin Maaß <f.mass@vogl-electronic.com>
2024-03-05 10:22:21 -05:00
Jukka Rissanen 1e85823fa6 tests: net: ipv4: Fix tests to support new netmask handling
Make sure that the tests work properly when each IPv4 address
in the network interface gets its own netmask.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-03 18:58:29 +01:00
Robert Lubos 3ea05cc958 tests: net: dhcpv4_server: Add tests for declined address expiry/reuse
Verify that declined addresses are not permanently blocked - i. e.
expire after configured timeout and in case of free address shortage,
can be reused.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-02-26 11:41:35 +00:00
Robert Lubos 6d6d5b438d tests: net: dhcpv4_server: Add test case for ICMP probing
Add test case which verifies that ICMP probing work as expected for the
DHCPv4 server. Make sure we build tests with both, probing enabled
(default) and disabled (enforced in testcase.yml) to make sure the
server is functional regardless of the probing feature.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-02-02 12:42:44 +01:00
Robert Lubos 5a08fea48e tests: net: dhcpv4_server: Add test to verify initialization
Add test that verifies that initialization fails if wrong arguments are
provided.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-31 12:06:23 +00:00
Robert Lubos 19722aa8e8 net: dhcpv4: Move DHCPv4 files to lib directory
As discussed during DHCPv4 server integration, group DHCPv4 client files
with DHCPv4 server in a single lib directory.

Renamed internal "dhcpv4.h" header to "dhcpv4_internal.h" so that it's
not confused with the public "dhcpv4.h" header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-29 13:47:05 +01:00
Robert Lubos 154e415c36 tests: net: dhcpv4_server: Add test suite for DHCPv4 server library
Add test suite covering DHCPv4 server library functionality.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-26 15:55:36 +00:00
Robert Lubos 9f1e1b4c60 tests: net: dhcpv4: Move DHCPv4 client tests to subdirectory
Move DHCPv4 client tests to subdirectory, to make room for DHCPv4 server
tests.

Rename test project to dhcpv4_client to better reflect its purpose.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-26 15:55:36 +00:00
Anas Nashif 345735d0a8 tests: remove CONFIG_ZTEST_NEW_API in all tests
Remove all usage of CONFIG_ZTEST_NEW_API from tests and sample as this
is now enabled by default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Matthias Breithaupt 82c39a7805 test: DHCPv4: Add test for option callbacks
Add tests for the option callback API. The test uses a previously unused
option already contained in the sample offer.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
2023-05-22 15:25:40 +02:00
Gerard Marull-Paretas 93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Robert Lubos 4d7b177a3f tests: net: dhcpv4: Increase buffer count for the test
Given that DHCP input packet is now released after
dhcpv4_handle_reply() function is called (and potentially new message
allocated/sent) the test needs more net buffers to work.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:01:13 +02:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02: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 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
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
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
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 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
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
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
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
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
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
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
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 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
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
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
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
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 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
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
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
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
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
Tomasz Bursztyka 77d1c86478 tests/net: Remove usage of net_pkt_ll() function
This function is planned to be removed, thus avoiding its usage.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka e97a543e9b net/pkt: Remove parameters to "reserve" some headroom
Such parameter is not used anymore, it was defaulted to 0 previously.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka c77d864841 tests/net: Get rid of the ll reserve
As it is unused now, let's default to 0.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01: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
Patrik Flykt 440b535602 tests: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Tomasz Bursztyka 72e1c2b4c1 tests/net: Apply L2 change everywhere where relevant
Many tests use either Ethernet or Dummy L2 and as such require
modifications towards the driver API on their fake devices.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08: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