Commit graph

70 commits

Author SHA1 Message Date
Fin Maaß e354927895 tests: use appropriate sys_randX_get()
use the appropriate sys_randX_get() instead
of always sys_rand32_get().

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-04-05 10:57:45 -05:00
Alberto Escolar Piedras f532937e92 tests|scripts/net: Change native_posix references to native_sim
* As we are replacing native_posix with native_sim, let's
  refer to native_sim instead of native_posix in the comments
  of why we have 1 extra interface.

* scripts/net/run-sample-tests.sh builds for native_sim now,
  not native_posix => let's fix it

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-03-20 15:43:05 +01: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 f505dc528e tests: net: checksum_offload: Add tests involving IP fragmentation
Add test cases verifying proper checksum calculation involving
IPv4/IPv6 fragmentation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 5f8a73f6cb tests: net: checksum_offload: Move test code into helper function
Further reduce code duplication by moving test code for similar test
cases into a helper function, parametrized based on the test case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 736888be0c tests: net: checksum_offload: Move net context init to helper function
Move code responsible for net context initialization, repeated over
multiple test cases, to a helper function to reduce code duplication.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 08d1bb2c92 tests: net: checksum_offload: Cleanup and fixes for the test suite
When working on new test cases for checksum_offload test suite it turned
out that some existing test cases were already broken and not testing
what expected. This commit fixes the broken functionality:
  * Despite having two separate interfaces for offloaded and
    non-offloaded checksum scenario, all packets ended up in a single
    interface anyway due to src address matching. Therefore use
    different destination address, depending on tests.
  * Add separate semaphores for offloaded and non-offloaded case, to
    ensure that the packet ended up on the correct interface.
  * The packet loopback in RX cases was broken, the LL address, IP
    address and UDP port swap written data in wrong places.
  * The receive path was not tested in the offloaded case.

Additionally, do a small cleanup before adding more tests:
  * Fix net_context leak.
  * Configure IPv6 neighbor once, during setup.
  * Add before function to cleanup the flags before tests execute.
  * Split tests into separate test cases, as they're not really
    dependent on each other.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-30 09:26:19 +01: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
Flavio Ceolin e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03: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
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
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 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
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
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 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
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
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
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
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
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
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
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
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
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 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
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
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
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
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 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
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
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 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 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
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
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
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 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
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 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