Commit graph

91 commits

Author SHA1 Message Date
Anas Nashif 8ff5417dfc Revert "tests: dlist to add a testcase and add some tags"
This reverts commit 2c92af5a80.

See #26619

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-02 14:40:20 -05:00
Anas Nashif 9d0c633f88 Revert "tests: rbtree to add and modify some tastcases"
This reverts commit 09310462fd.

See #26619

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-02 14:40:20 -05:00
Ningx Zhao 2c92af5a80 tests: dlist to add a testcase and add some tags
Add a testcase to verify some operations running
in constant time.
Add new informative Doxygen tags

Signed-off-by: Ningx Zhao <ningx.zhao@intel.com>
2020-06-23 18:55:47 -04:00
Krzysztof Chruscinski 4baf24203d tests: unit: util: Add tests for new macros
Added tests for GET_ARG_N and GET_ARGS_LESS_N

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-22 15:18:07 +02:00
Torsten Rasmussen e1c1d1daca cmake: make find_package(ZephyrUnittest...) REQUIRED
This commit is a followup to PR #25808 which updates the tests to
ensure the REQUIRED keyword is also used for the ZephyrUnitest package.

This provides a better error message when building with CMake and
forgetting ZEPHYR_BASE or not registering Zephyr in the CMake package
registry.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-06-12 11:10:23 +02:00
Krzysztof Chruscinski 727f8e0889 tests: unit: util: Add test for nested FOR_EACH call
Added test for case were FOR_EACH call is nested.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-10 11:58:13 +02:00
Krzysztof Chruscinski 1b4b9386e5 sys: util: Added separator to FOR_EACH_ macros
Added separator (e.g. comma or semicolon) parameter to FOR_EACH_ family.
Separator is added between macro execution for each argument and not at
the end.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-10 11:58:13 +02:00
Ningx Zhao 09310462fd tests: rbtree to add and modify some tastcases
Add two testcases,one of them verify rbtree node can be embedded
in any user struct.
And another verify some operations in logarithmic time.

Signed-off-by: Ningx Zhao <ningx.zhao@intel.com>
2020-06-09 10:21:33 -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
Dominik Ermel 6ba69f19d4 sys/util.h: Add IS_EMPTY and LIST_DROP_EMPTY macros
IS_EMPTY macro allows to check if defined name is empty, i.e.
does not contain replacement list.
LIST_DROP_EMPTY macro may be used to process __VA_ARGS__ type lists,
e.g. a,b,,c , and remove empty elements.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-05-08 17:50:25 +02:00
Krzysztof Chruscinski 8fcabf6032 tests: unit: util: Add test for FOR_EACH_FIXED_ARG macro
Added test for FOR_EACH_FIXED_ARG macro.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-05-06 14:30:18 +02:00
Krzysztof Chruscinski 8ab4a60471 tests: unit: util: Add tests for FOR_EACH and FOR_EACH_IDX macros
Extended suite to test macros.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-05-06 14:30:18 +02:00
Torsten Rasmussen 9095c9ef1b Revert "cmake: Get unit tests passing CI again"
This reverts commit 1bf839809c.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-31 10:00:15 -04:00
Kumar Gala 1bf839809c cmake: Get unit tests passing CI again
The following commit:

commit 407b49b35c (refs/bisect/bad)
Author: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Date:   Wed Feb 12 15:00:46 2020 +0100

    cmake: use find_package to locate Zephyr

breaks as we don't find the ZephyrUnittest package.  For now revert to
the old means until a proper fix can be made.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-27 14:16:37 -05: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
Martí Bolívar 1edc84f526 sys/util.h: add UTIL_OR and UTIL_AND
These are short-circuiting utility helpers that can save typing
in situations where avoiding evaluation of the not-taken branch
skips invalid expressions.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-25 13:21:28 +01:00
Martí Bolívar 3c7a939743 tests: add util.h MACRO_MAP_CAT test
This wasn't tested when it was first added.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-25 13:21:28 +01:00
Kumar Gala 28a88fc638 sys/util.h: allow UTIL_LISTIFY to pass args to repeat macro
Change UTIL_LISTIFY to support passing arguments to the F macro.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-13 07:33:57 -06:00
Jukka Rissanen 9d4fbb2912 crc: Add crc8 implementation and tests
Add crc8 implementation and unit tests for it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-03-10 12:53:53 +02:00
Krzysztof Chruscinski 79519c4dbe tests: unit: util: Add test for IF_ENABLED()
Added test for new macro.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-12-18 08:14:52 -05:00
Ulf Magnusson 984bfae831 global: Remove leading/trailing blank lines in files
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.

Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.

Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-11 19:17:27 +01:00
Anas Nashif 70758c4374 tests: fix test identifiers
The seasonal overhaul of test identifiers aligning the terms being used
and creating a structure. This is hopefully the last time we do this,
plan is to document the identifiers and enforce syntax.

The end-goal is to be able to generate a testsuite description from the
existing tests and sync it frequently with the testsuite in Testrail.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-09 15:53:44 -05:00
Maksim Masalski 813ef68554 tests: updated names for the tests
Some test cases have the same test case name.
To get rid of it, I decided to change test cases names
contained same names.
Please check my logic, how I give them names.
Usually trying to give name same as a directory folder.
There are still more test cases which necessary to change,
but I will make changes by small steps.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2019-10-23 23:15:41 -04:00
Steven Wang 3cb03efd9c tests: move test timeutil into "unit" directory.
We don't have to build an image for running test timeutil. We
can just build a native app to test it. So move it into "unit"
directory.

Also, add 64-bit support for unit testing framework.

Signed-off-by: Steven Wang <steven.l.wang@linux.intel.com>
2019-10-22 23:05:34 -04:00
Anas Nashif 2051ad1846 tests: convert util test to a unit test
Merge tests/misc/util with existing util unit test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-30 07:09:42 -04:00
Anas Nashif 96ad532b58 tests: move Bluetooth at tests under tests/bluetooth
this is not a unit test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-27 15:23:26 -04:00
Anas Nashif 50d5e37b8a tests: move util test to be unit tests
Move to a unit test, no need to build this for every platform we have.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-27 15:23:26 -04:00
Anas Nashif 1caab558a1 tests: move intmath test to be unit tests
Move to a unit test, no need to build this for every platform we have.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-27 15:23:26 -04:00
Anas Nashif e9156e04b4 tests: move list test to be unit tests
Move to a unit test, no need to build this for every platform we have.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-27 15:23:26 -04:00
Anas Nashif 9004eb68dc tests: make rbtree tests unit tests
Move to a unit test, no need to build this for every platform we have.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-27 15:23:26 -04:00
Anas Nashif abf1d36ed9 tests: move crc to a unit test
Move to a unit test, no need to build this for every platform we have.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-27 15:23:26 -04:00
Anas Nashif 48c335486f tests: move base64 to a unit test
Move to a unit test, no need to build this for every platform we have.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-27 15:23:26 -04:00
Andrew Boie eb07943b2d tests: crc: convert to regular test case
The special 'unittest' target has largely been supersesed by
native_posix, and converting this to a regular test will allow
us to see code coverage for the CRC functions in our coverage
reports.

Fixes: #16943

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-06 00:31:04 +02:00
Anas Nashif 6ecadb03ab cleanup: include/: move misc/math_extras.h to sys/math_extras.h
move misc/math_extras.h to sys/math_extras.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
Jakob Olesen 0e65aab703 misc: Always test the portable version of the math_extras.h functions.
The implementation of the <misc/math_extras.h> functions will use the
portable C code when PORTABLE_MISC_MATH_EXTRAS is defined before
including the header.

Use this feature macro to make sure that the unit test always tests the
portable functions in addition to the ones using builtins for the
current compiler.

Signed-off-by: Jakob Olesen <jolesen@fb.com>
2019-05-14 19:53:30 -05:00
Jakob Olesen e66c0da0c1 misc: Portable math_extras.h implementations.
Add a <misc/math_extras.h> header file with portable implementations of
a number of commonly used math and bit counting operations that are not
available in the C programming language.

The math_extras functions fall into two groups:

1. Unsigned integer arithmetic with overflow detection. Addition and
   multiplication are provides for the u32_t, u64_t, and size_t types.
   This commit doesn't include subtraction and division, and there are
   no signed operations. These could be added later if there is a need.

2. Bit-counting operations like clz, ctz, and ffs. These are provided
   for u32_t and u64_t only. I don't see a need for size_t operations,
   but they could be added if needed.

A follow-on commit will add more efficient implementations using
compiler builtins for those compilers that support it.

Another commit will replace other uses of "naked" compiler builtins with
calls to these functions.

Signed-off-by: Jakob Olesen <jolesen@fb.com>
2019-05-14 19:53:30 -05: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
Anas Nashif 15cdeb9352 tests: fix various test identifiers
Fix various test identifiers.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-03-29 17:44:11 -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
Anas Nashif ccad9d0d09 tests: move testsuite and configs into subsys/
Move test related code and the testsuite away from tests/ and make it a
proper subsystem.
The way tests were integrate in the tree was not obvious and actual
tests were intermixed with the testsuite code.

This will allow us to have trees with the testcode and without the
samples by just remove the folders tests/ and samples, needed for
isolating actual code from test/sample code.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-22 08:58:40 -05:00
Anas Nashif db92e5c66e lib: flatten all loose components into one lib
lib/ was starting to get messy and inconsitent. Files being either
dumped in the root or in sub-directories without a clear plan.
Move all library components into one single folder and call it 'os'.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-22 07:45:22 -05:00
Sebastian Bøe 1b86fb9da3 cmake: Use variables for target names
There is an effort underway to make most of the Zephyr build script's
reentrant. Meaning, the build scripts can be executed multiple times
during the same CMake invocation.

Reentrancy enables several use-cases, the motivating one is the
ability to build several Zephyr executables, or images, for instance a
bootloader and an application.

For build scripts to be reentrant they cannot be directly referencing
global variables, like target names, but must instead reference
variables, which can vary from entry to entry.

Therefore, in this patch, we replace global targets with variables.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-01-19 07:21:55 -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
Michael Hope bbafc36b1c lib: add crc7.
Used as a checksum on command messages when talking with MMC cards.

Implemented using the unwound bytewise implementation from
https://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checks
which is a good mix of size and speed.

The API and naming matches lib/crc7.c in Linux.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-12-30 16:24:10 -05:00
Jakub Rzeszutko 200da3acaa test: unittest: run for 32bit architecture
Running tests compiled for 64bit architecture were causing errors
in logger module. Updated unittest.cmake to build tests only
for 32bit architecture.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-11-22 11:32:29 +01: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
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
Olivier Martin e7ae7334db lib/crc: Add CRC32 support
It only adds CRC32 IEEE support at the moment.

Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
2018-07-18 10:00:12 -04:00
Leandro Pereira 39dc7d03f7 scripts: gen_kobject_list: Generate enums and case statements
Adding a new kernel object type or driver subsystem requires changes
in various different places.  This patch makes it easier to create
those devices by generating as much as possible in compile time.

No behavior change.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-26 02:57:12 +05:30
Anas Nashif d7e7b08cdc tests: cleanup meta-data of various tests
Use sensible test name and cleanup filtering.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 22:55:20 -04:00