Commit graph

85 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
Jukka Rissanen d1ef9167da net: if: Make sure no other interface has same name
When setting a name to a network interface, verify that no other
interface has the same name as that would make very difficult to
select an interface by a name.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-27 14:32:34 +00: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
Pieter De Gendt 408babb00f tests: net: iface: Test foreach multicast helper functions
Add test cases for IPv4/IPv6 foreach functions that iterate all
multicast addresses assigned to an interface.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-02-28 13:18:06 -06:00
Jukka Rissanen 67d21c8b1d tests: net: if: Add test to check device readiness
Add tests that check if device is ready or not, and
then verify the functionality of net_if_up() in that case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-14 14:21:31 +01:00
Benedikt Schmidt aa25e212d1 tests: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Jukka Rissanen 1005fbe16c tests: net: iface: Do not use eth0 name in the test
If the first Ethernet interface is not the first network
interface, then there might be two interfaces with the same name.
The test does not like that.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 09:05:04 +02: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
Jukka Rissanen bb5885580f tests: net: iface: Add unit test for interface name support
Check that we can set and get the network interface name.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-08-31 14:43:36 +02:00
Robert Lubos ea9d8b7295 tests: net: if: Add tests to verify net_if_ipv4/6_addr_foreach()
Add tests cases which verify that net_if_ipv4/6_addr_foreach() executes
callbacks properly on assigned addresses.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-25 14:18:54 +02:00
Florian Vaussard 90355f143f tests: net: iface: verify multicast address not removed if used
If two IPv6 addresses have the same solicited-node multicast address
because they derive from the same EUI-64 interface identifier, make sure
that the solicited-node multicast address is not removed when one of the
IPV6 address is removed but only when both addresses are removed.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2023-06-28 06:51:21 +00:00
Florian Vaussard 6837229ff2 tests: net: iface: remove useless assignment
The value of in6addr_mcast is overwritten in iface_setup() before being
assigned to the interface. Remove the useless initial value since it is
never used, in order to avoid misleading information.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2023-06-28 06:51:21 +00: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 0090ad718a net: Fix build issues with arm-clang
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined.  To fix this add needed ifdef'ry.

Build various network samples that utilize ethernet but don't have
CONFIG_NET_PROMISCUOUS_MODE will get a link error for:

	Error: L6218E: Undefined symbol
	net_mgmt_NET_REQUEST_ETHERNET_SET_PROMISC_MODE
	(referred from ethernet.o).

Fix by adding ifdef protection around promisc code.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-25 19:59:06 +02:00
Gerard Marull-Paretas 1eb683a514 device: remove redundant init functions
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Robert Lubos 42c78e2af1 tests: net: iface: Add test to verify operational state transitions
Add test which verifies that interface operational state changes
correctly when carrier and dormant status is updated.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Hu Zhenyu 724bbcbc05 tests: net: iface: move to new ztest API
Move net iface tests to use new ztest API
1. Add teardown, remove addr and interface down
2. Add pkt unref
3. Combine interface up/down, promisc off/on, addr add/rm

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-08-30 14:18:11 +00: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
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
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
Fabio Baltieri 4a4c63519d net: if: check for multicast address already registered
Add a check to stop a multicast address to be registered multiple times.
This can happen if the application is using net_if_ipv6_maddr_add()
directly.

Tested on the existing bluetooth/ipsp sample:

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

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-01-14 16:57:07 +02:00
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
Jukka Rissanen 5eef2c5f24 tests: net: iface: Modify tests to verify userspace access
Modify the tests so that they verify that only allowed thread
is able to modify network interface data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-07-29 08:13:22 -04:00
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
Jukka Rissanen 63a7b92fd8 net: if: Refactor because of timeout overhaul
Convert to use k_timeout_t

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
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
Marc Herbert c429051380 tests/net/: samples/net/: add a few 'userspace' tags
See commit message 4afcc0f8af for the long story.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-07-15 09:05:10 -04:00
Jukka Rissanen 7063921e87 net: if: Add userspace support to IPv4 gateway set function
Allow application to call net_if_ipv4_set_gw_by_index()
and set the gateway if enabled by configuration.

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

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

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
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 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
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
Tedd Ho-Jeong An 401a598503 tests: net: iface: Handle pkt allocation failure
This patch handles null pointer when packet allocation fails.

Fixes: #14390
Coverity-CID: 195903

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-03-14 12:06:21 +01:00
Tomasz Bursztyka 32dfb13b03 tests/net: Switch iface test to new net_pkt API
No need to play with net_buf by ourselves.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
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 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
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
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