Commit graph

99 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 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
Jukka Rissanen 1899c0c5c7 tests: net: ip-addr: Check IPv6 private addresses
Add a test that checks that the private address checker works
as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-02-26 11:41:55 +00:00
Jukka Rissanen 5723676770 tests: net: ip-addr: Check IPv4 private addresses
Add a test that checks that the private address checker works
as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-02-26 11:41:55 +00:00
Robert Lubos c6f2f2cf53 tests: net: ip-addr: Fix compiler warning
Building with Zephyr SDK 0.16.5 revealed a minor bug with the buffer
size provided to snprintk():
  specified bound 38 exceeds destination size 20 [-Wstringop-overflow=]

As we provide the buffer to snprintk() with an offset, the actual
buffer size should be reduced by that offset value.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-02-02 19:54:52 +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
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 1f414faf58 tests: net: ip-addr: move to new ztest API
Move tests/net/ip-addr to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
2022-07-14 10:40:19 +02:00
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
Oliver Hitz 0c70877ceb net: IPv4 bcast address recognized as multicast
Modified net_ipv4_is_addr_mcast() to not wrongly classify an IPv4
broadcast address as a multicast address.

Signed-off-by: Oliver Hitz <oliver@net-track.ch>
2020-10-09 10:26:38 +03:00
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
Lukasz Maciejonczyk 8acebb5cd0 tests: net: Add tests for IPv6 mesh addresses
This tests make sure that the right source address is chosen during
the mesh multicasting.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-16 19:14:52 +02:00
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
Jukka Rissanen efd99e6634 tests: net: ip-addr: Avoid possible null pointer dereference
Check return value of net_if_ipv6_get_ll() before accessing it.

Coverity-CID: 199437
Fixes #17201

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-02 11:37:05 +03:00
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
Jukka Rissanen 299832738e tests: net: ip-addr: Fix interface index values
The test needs to use interface index starting from 1.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-18 15:10:54 -05:00
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
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
Jukka Rissanen cf063fe85b net: Rename net_is_xxx...() functions to net_xxx_is...()
Unify the function naming for various network checking functions.

For example:
     net_is_ipv6_addr_loopback() -> net_ipv6_is_addr_loopback()
     net_is_my_ipv6_maddr() -> net_ipv6_is_my_maddr()
etc.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-02 14:52:33 -04: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 a85a123477 tests: net: ip-addr: Add checks for IPv4 broadcast addresses
Make sure that IPv4 broadcast address checks work as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-26 15:37:21 +03: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
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
Punit Vara 7a3ace35dd tests: Remove newline character
Remove new line character from all zassert_*
messages. Following script has been used to do this.

https://github.com/punitvara/scripts/blob/master/remove_newlinech.py

zassert test framework adds newlines character implicitly.

issue: #7170

Signed-off-by: Punit Vara <punit.vara@intel.com>
2018-05-23 12:59:12 -04:00
Jukka Rissanen 542f10de78 tests: net: ip: Refactor and add IPv4 tests
Add new test for testing IPv4 source address selection functions.
Refactor the tests:
- split tests to smaller pieces
- use proper zassert() statements
- print debugging information only when needed

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-05-03 12:47:52 +03: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
Anas Nashif 848c105485 tests: classify net tests and cleanup
More tagging and filterting cleanup.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 22:55:20 -04: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
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
Leandro Pereira da9b0ddf5b drivers: Rename random to entropy
This should clear up some of the confusion with random number
generators and drivers that obtain entropy from the hardware.  Also,
many hardware number generators have limited bandwidth, so it's natural
for their output to be only used for seeding a random number generator.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-11-01 08:26:29 -04: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
Jukka Rissanen 80bfd25a6c tests: net: Add IPv4 multicast address tests
These tests test the IPv4 multicast address add, lookup and
removal functions found for network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-29 11:34:06 +03:00
Niranjhana N fbb6cb4fdd tests: ip-addr: convert to ztest
- replaced test points with ztest APIs wherever possible
- replaced CONFIG_MAIN_STACK_SIZE with CONFIG_ZTEST_STACKSIZE
  in config file, reduced the size by half

JIRA: ZEP-2249

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-09 21:41:30 -04:00
Johan Hedberg 2975ca0754 Bluetooth: Kconfig: Rename CONFIG_BLUETOOTH_* to CONFIG_BT_*
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.

Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 11:14:19 +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 dd6d34e7dc tests: net: second pass at cleanup tests to build on all platforms
The majority of these fixes adjust the memory limit needed to build the
various tests on systems with and without BLE support.  We also fixup
one test case that was able to run on platforms with 16k of memory.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-26 11:47:14 +03: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