Commit graph

192 commits

Author SHA1 Message Date
Gaetan Perrot d9e9f75bfc kernel: api: implement test for sys_slist_find
implement test for sys_slist_find

signed-off-by: Gaetan Perrot <gaetanperrotpro@gmail.com>
2024-03-12 13:46:29 -04:00
Fabio Baltieri 9e1eec9ced test: add a test for sign extend
Add tests for the sign extend functions.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-02-26 11:41:20 +00:00
Krzysztof Chruściński fdafbdb1c9 tests: unit: util: Extend FOR_EACH test
Extend test to check also no arguments.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-29 11:32:54 +01:00
Krzysztof Chruściński 04edca7a9f tests: unit: util: Add test for CONCAT macro
Add test for CONCAT.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-12 09:57:57 +01:00
Emil Gydesen 87c8b897b3 include: util: Add mem_xor functions
Add functions to do XOR on arrays of memory, with one that
takes arbitrary sizes and one for 32 bits and 128 bits as
those are common sizes for this functionality.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-05 09:06:36 +01:00
Christopher Friedt 1695b5a0b2 tests: unit: util: add array for-each tests
Add tests for the following two macros

* ARRAY_FOR_EACH(array, idx_var)
* ARRAY_FOR_EACH_PTR(array, ptr_var)

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-04 08:27:29 +09:00
Krzysztof Chruściński c0bb064d4e tests: unit: util: Fix compliance check warnings
As code is moved from test.inc to main.c a compliance check is
run for the first time on that code. Fixing warnings.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-02 16:01:11 +00:00
Krzysztof Chruściński 7b872d11ba tests: unit: util: Rework test structure for C++ testing
Rework test structure to handle C++ test in a better way. Similar
approach already applied in other tests which are executed for C
and C++. Getting rid of test.inc which due to non-standard extension
was not covered by complience check.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-02 16:01:11 +00:00
Pieter De Gendt cc920696ed tests: unit: util: Add tests for IF_DISABLED
Add a testcase for the IF_DISABLED macro.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-28 12:06:28 +00:00
Anas Nashif 0b999c0943 lib: move utilities into own folder
Move various utilities out of lib into own folder for better assignement
and management in the maintainer file. lib/os has become another dumping
ground for everything and it the Kconfig and contents in that folder
became difficult to manage, configure and test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-12-22 09:54:12 +01:00
Dmitrii Golovanov fbe95e4a73 tests: unit: Fix Power-of-Two test build issue
Fix linker error for the PoT test build with code coverage.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-12-19 10:03:47 -05:00
Anas Nashif 589d36adcf tests: crc: remove unrelated tag
Remove net tag from tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-30 11:23:11 -05:00
Krzysztof Chruściński aa2e315ab0 tests: unit: cbprintf: Add tests for string validation
Add tests for Z_CBPRINTF_NONE_CHAR_PTR_COUNT, Z_CBPRINTF_P_COUNT
and Z_CBPRINTF_POINTERS_VALIDATE.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-11-24 09:23:18 +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
J M 9cf437728e sys: lists: Add tests for newly-added list len functions
This commit adds tests for the newly added list len APIs to the
corresponding test cases. It is noted that the test functions calculate
equivalent values manually using several different internal list
functions. This has been left unmodified to ensure that the manual ways
using each of the various for_each functions results in the same value
as the new list_len() functions.

Signed-off-by: J M <montytyper@msn.com>
2023-09-13 16:19:33 +02:00
Fabio Baltieri 5c901052ec tests: crc: fix crc library location
These files have been moved in:

e6885a4515 lib: crc: move from lib/os to lib/crc

Adjust the path to the new location.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-20 19:08:24 +01:00
Daniel Leung cc87f7757b tests: unit: rename shadowing variables
Renames	shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Kornel Dulęba 8fc913374f include: util: Add DIV_ROUND_CLOSEST helper
It's similar to DIV_ROUND_UP, but rounds to the nearest integer.
Some basic unit tests were introduced to check that it works as
intended.

Signed-off-by: Kornel Dulęba <mindal@semihalf.com>
2023-07-21 10:49:41 +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
Gerard Marull-Paretas 3df3aab9d2 tests: unit: util: test DIV_ROUND_UP
Add a unit test for the DIV_ROUND_UP helper macro.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-11 12:00:37 +02:00
Keith Packard 688e255e6e tests/cbprintf: Add explicit casts when testing short/char printf
Clang detects a value of the wrong size passed to printf with %h or %hh
modifiers. Insert explicit casts to the expected type.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-05 10:38:34 +02:00
Chris Friedt edb5ee1575 tests: unit: test for Power-of-Two utilities
Tests for Power-of-Two (PoT) utilities.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-22 19:14:05 +01:00
Anas Nashif 0bc4fd4cb9 tests: fix various test identifiers
lib -> libraries to be consistent with everything else.
And fix identifier for a few stray tests that were wrongly
labeled/tagged.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-06 10:06:10 +01:00
TOKITA Hiroshi 148d205c12 test: unit: util: add BIT_MASK macros tests
Adding tests for BIT_MASK, BIT_MASK64, IS_BIT_MASK, and IS_BIT_MASK_SHIFTED

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-01-10 09:23:14 +01:00
Chris Friedt 74c9c0e7a3 tests: time_units: check for overflow in z_tmcvt intermediate
Prior to #41602, due to the ordering of operations (first mul,
then div), an intermediate value would overflow, resulting in
a time non-linearity.

This test ensures that time rolls-over properly.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-12-19 09:36:38 +00:00
Anas Nashif cffe98d9de crc: Make the build of crc function dependent on a Kconfig
Add CONFIG_CRC for building CRC related routines.
CRC routines are now being built for each application, whether used or
not and are add in the build system unconditionally.

Keep CONFIG_CRC enabled by default for now and until all users have
converted to use the new option.

Partial fix for #50654

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-23 13:30:00 +01:00
Yuval Peress fae9923ff2 unittest: update coverage library non gcc toolchains
When building with clang, the unittests were giving us an error:
```
error: undefined symbol: llvm_gcda_start_file
```

This seems to be from linking in `gcov` regardless of the toolchain.
It appears that clang doesn't need any special library for coverage.
With this change the following now produce identical coverage reports:

```
$ ZEPHYR_TOOLCHAIN_VARIANT=zephyr ./scripts/twister -p unit_testing \
  --coverage -i -T tests/unit/intmath/
$ ZEPHYR_TOOLCHAIN_VARIANT=host ./scripts/twister -p unit_testing \
  --coverage -i -T tests/unit/intmath/
$ ZEPHYR_TOOLCHAIN_VARIANT=llvm ./scripts/twister -p unit_testing \
  --coverage -i --coverage-tool lcov                              \
  --gcov-tool $(pwd)/scripts/utils/llvm-gcov.sh                   \
  -T tests/unit/intmath/
```

Signed-off-by: Yuval Peress <peress@google.com>
2022-11-21 16:09:46 -05:00
Keith Packard 6bfa0f17e8 tests/cbprintf: Use minimal libc to test cbprintf code
These tests all assume that the same underlying cbprintf function will be
used for all operations, which is not true when using picolibc. Force the
use of the minimal C library as that will check the right code paths.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-11-08 10:44:36 +01:00
Yuval Peress f460c21578 test: update how unit tests set sources
Replaces cases of setting SOURCES before calling find_package with
proper target_sources.

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-31 17:01:59 +01:00
Krzysztof Chruscinski b7b748b06d tests: unit: cbprintf: Disable logging
Force logging disable in the test.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-19 10:14:23 +00:00
Christopher Friedt 2e6e09acac tests: util: PART_OF_ARRAY, IS_ARRAY_ELEMENT, ARRAY_INDEX, ..
Add tests for `PART_OF_ARRAY()`, `IS_ARRAY_ELEMENT()`,
`ARRAY_INDEX()`, and `ARRAY_INDEX_FLOOR()`.

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-09-09 13:20:12 -05:00
Enjia Mai dc15c03b96 tests: unit: move the util test to new ztest API
Migrate the testsuite tests/unit/util to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-09 08:33:00 -04:00
Michał Barnaś dae8efa692 ztest: remove the obsolete NULL appended to zassert macros
This commit removes the usage of NULL parameter as message in
zassert_* macros after making it optional

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-09-09 07:05:38 -04:00
NingX Zhao e57ac68efe tests: unit: rbtree: move testcases to new ZTEST API
Move testcases to the new ZTEST API.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-09-07 10:31:06 +02:00
NingX Zhao 3f4906a7a6 tests: unit: list: move testcases to new ZTEST API
Move testcases to new ZTEST API.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-31 21:51:37 +00:00
Enjia Mai 513cd6989a tests: unit: move the math_extra test to new ztest API
Migrate the testsuite tests/unit/math_extra to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-23 16:22:59 +02:00
Enjia Mai 7133f34c1b tests: unit: move the timeutil test to new ztest API
Migrate the testsuite tests/unit/timeutil to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-23 16:22:59 +02:00
Enjia Mai 8f87885965 tests: unit: move the winstream test to new ztest API
Migrate the testsuite tests/unit/winstream to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-23 16:22:59 +02:00
Enjia Mai 81bb2a026b tests: unit: move the cbprintf test to new ztest API
Migrate the testsuite tests/unit/cbprintf to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-23 16:22:59 +02:00
Enjia Mai 811e691cf6 tests: unit: move the base64 test to new ztest API
Migrate the testsuite tests/unit/base64 to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-23 16:22:59 +02:00
Enjia Mai 2dcaf08c8b tests: unit: move the net timeout test to new ztest API
Migrate the testsuite tests/unit/net_timeout to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-23 16:22:59 +02:00
Enjia Mai a729f4d065 tests: unit: move the intmath test to new ztest API
Migrate the testsuite tests/unit/intmath to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-23 16:22:59 +02:00
Enjia Mai 679dc0fe3d tests: unit: move the crc test to new ztest API
Migrate the testsuite tests/unit/crc to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-23 16:22:59 +02:00
Torsten Rasmussen 3217d97375 tests: update unit/cbprintf test to use Kconfig
This commit removes CONFIG defines from main.c and instead uses the
proper Kconfig handling of specifying extra Kconfig options in
testcase.yaml.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-18 14:29:14 +02:00
Aurelien Jarno 72a1362eaf tests: unit: util: Add test for IS_EQ
Add a basic test for the just introduced IS_EQ macro.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2022-08-04 17:35:39 +01: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
Fabio Baltieri 55b243e124 test,arch: fix few odd suffix include paths
Fix some more legacy include paths found in files with unusual suffixes.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-07-18 14:44:47 -04:00
Yuval Peress a7ceba3710 testing: add zephyr/ prefix to testing include path
Continuation of issue #41543 to add prefix scope for Zephyr's include
files.

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-29 06:04:32 -04:00
Yuval Peress ffc0983547 test: unittest: Fix deprecated ZephyrUnittest
Fix the deprecated calls to loading ZephyrUnittest by replacing them
with `Zephyr COMPONENTS unittest`.

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-29 06:04:32 -04:00
Daniel Leung aff6e8b2f7 lib: os: cbprint: enable tagged arguments for packaging
This adds some bits to support tagged arguments to be used for
packaging. If enabled, the packaging function no longer looks at
the format strings to determine the types of arguments, but
instead, each argument is tagged with a type by preceding it
with another argument as type (integer). This allows the format
strings to be removed from the final binary to conserve space.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00