Commit graph

51 commits

Author SHA1 Message Date
Daniel Leung 6ea749de52 arch: rename arch_start_cpu() to arch_cpu_start()
Rename arch_start_cpu() to arch_cpu_start() so it belongs to
the "cpu" namespace.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-03-25 09:58:35 +00:00
Evgeniy Paltsev c5cd886518 test: spinlock: cleanup assertion
Don't double check on assertion condition.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-11-06 15:44:34 -06:00
Alexander Razinkov 8fe8f34169 tests: kernel: spinlock: acquisition fairness test
Added test to verify the spinlock acquisition fairness
in relation to the CPUs contending for the spinlock.
This test is only enabled for Ticket Spinlocks which
required to provide such kind of fairness.

Signed-off-by: Alexander Razinkov <alexander.razinkov@syntacore.com>
2023-11-04 07:38:39 -04:00
Andrei Emeltchenko daa739a410 tests: spinlock: Clear test globals before each test
Clear test global variables before each test execution.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-10-26 10:30:24 -04:00
Anas Nashif 996c8457d7 ztest: remove old ztest api
Remove old Ztest API entirely. New API is the now the default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +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
Andrei Emeltchenko bf4dc31015 tests: spinlock: Make local functions static
Make local functions static.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-09-28 15:46:07 +02:00
Andrei Emeltchenko a3959af4f5 tests: spinlock: Increase thread execution to prevent quick exit
On Intel boards (like intel_ehl_crb and intel_rpl_s_crb) for the
trylock_test some part is executed very fast and since there is no
synchronization, there might be situation when there is no
trylock_failures. Increasing time spend in this part fixes the issue.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-09-28 15:46:07 +02:00
Gerard Marull-Paretas 691facc20f include: always use <> for Zephyr includes
Double quotes "" should only be used for local headers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-14 13:49:58 +02:00
Alexander Razinkov 9ae9df8b6f kernel: spinlock: k_spin_is_locked introduction
Currently spinlock internals are directly accessed from the tests.
This way the test becomes bound to the particular spinlock implementation.
To remove this unnecessary dependency the distinct API to check if spinlock
is locked is introduced.

k_spin_is_locked should be used for the spinlock testing only,
so the scope of this API is intentionally restricted.

Signed-off-by: Alexander Razinkov <alexander.razinkov@syntacore.com>
2023-09-07 14:26:55 +02:00
Keith Packard 844c78cf3a tests/kernel: Also run tests using minimallibc
With picolibc being the default C library, we need to explicitly include
testing against the minimal C library for kernel components.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-09-04 15:29:13 -04:00
Jaxson Han 81ca50900d tests: kernel: spinlock: Fix test_trylock thread reusable issue
The test_trylock reuses the cpu1_thread, but there is no way for it to
exit. This will cause the thread created twice, as a result, two cpu
running the same thread simultaneously cause an unexpected crash.

Fix this by adding initialization of resources and also the exit for the
cpu1_thread.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-08-02 16:34:04 +02:00
Christopher Friedt 28a8b151cf tests: kernel: spinlock: add test for k_spin_trylock()
Add a testcase to exercise two cases:
* when `k_spin_trylock()` fails (lock is busy)
* when `k_spin_trylock()` succeeds (lock is acquired)

We use the same machinery for checking for a recursive mutex
as `k_spin_lock()`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-07-05 21:06:55 -04:00
Anas Nashif b835b02136 tests: cleanup metadata and filtering
- Add integration_platforms to avoid excessive filtering
- Make sure integration platforms are actually part of the filter
- Fix some tags and test meta data

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-13 09:38:27 -04: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
Tom Burdick 392a753ac2 tests: spin lock timeout test spin time
The spin loop to ensure time goes past the timeout is done in terms
of the core clock, while the spin lock is timed on the system clock.

This difference is exasperated on systems where the core clock is much
faster than the system clock and the test failed. Add a significant
multiplier so the test works even when the system clock is much slower.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-12-14 13:44:36 -06:00
Kumar Gala f7522cb71e tests: kernel: spinlock: Convert CONFIG_MP_NUM_CPUS handling
Move build and build system checks to use CONFIG_MP_MAX_NUM_CPUS
as we phase out CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-31 17:09:06 +01:00
Tom Burdick 6cef9ca595 tests: Fix coherence of timeout spin lock
Spin locks must be in coherent memory for cavs. Initially this variable
was at the compilation unit scope but warnings about it being unused
from a twister run lead me to move it to be in the ifdef scope in the
function.

Move it back into the compilation units scope and wrap it in an
ifdef to ensure its not labeled as unused.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-26 15:33:43 -07:00
Tom Burdick 1644cc69d7 tests: Fix spinlock time limit test
Set the time limit to be long enough not to trigger too early. Do
not unlock after assert when doing the time limit test.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-22 14:37:03 +09:00
Tom Burdick 872e3553f9 kernel: Option to assert on spin lock time
Spin locks held for any lengthy duration prevent interrupts and
in a real time system where interrupts drive tasks this can be
problematic. Add an option to assert if a spin lock is held for
a duration longer than the configurable number of microseconds.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-18 14:14:12 +02:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +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
Guo Lixin 213eaeee79 tests: kernel: spinlock: move to new ztest API
Move test to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-04 06:54:31 -04:00
Gerard Marull-Paretas 74ed64139c tests: remove redundant <zephyr/zephyr.h> includes
Files including <zephyr/kernel.h> do not have to include
<zephyr/zephyr.h>, a shim to <zephyr/kernel.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-15 09:13:11 +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
Anas Nashif 0ec3774bde userspace: rename _is_user_context -> k_is_user_context
This functions is being called across the tree, no reason why it should
not be a public API.

The current usage violates a few MISRA rules.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-01 05:34:17 -04:00
Andy Ross 589c781506 tests: No thread-shared/synchronized data on stack (coherence)
CONFIG_KERNEL_COHERENCE forbids synchronized data on the stack: no
spinlocks, IPC primitives, or things that contain them.  Application
code obviously doesn't have to follow these inconvenient rules, but
our test code needs to run on platforms with incoherent stack memory.

Make these things static.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 19:25:25 -05:00
Kumar Gala 53b104d461 tests: kernel: Add missing kernel tag to tests
Add kernel to any testcase.yaml files that happen to be missing for
tests under tests/kernel/

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-05 14:52:55 -05:00
Watson Zeng f71cd2aaf5 spinlock: validate: fix the dependency with MP_NUM_CPUS
the implementation of spinlock validation uses two LSB bits in the
bottom of a pointer union to store a CPU index, which only has space
for 4 CPUS. the MP_NUM_CPUS should be <= 4.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2021-01-26 08:43:45 -05:00
Enjia Mai 3026df2a24 tests: spinlock: add some error test cases
Add some error test cases for spinlock, include:
1.Validate indentical spinlock cannot be used recursively.
2.Validate unlocking incorrect spinlock will trigger assertion.
3.Validate releasing incorrect spinlock will trigger assertion.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2020-12-27 18:19:42 +01:00
Andrew Boie 860e965a4f tests: spinlock: fix occasional crash
lock_runtime is a stack variable whose contents could be completely
garbage, but only the 'locked' member was zeroed. zero the whole
thing to prevent spurious "recursive spinlock" errors from occasionally
popping up as the validation framework gets confused from garbage
data in the other memebers of this data structure.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-09-03 21:55:05 +02:00
Anas Nashif 1fbbfc819a tests/samples: add tags to some tests
Some tests/samples had no tags, fill those..

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-20 17:44:16 -04:00
Enjia Mai ce31b89e50 tests: adding test cases of spinlock
Add test case for testing achieve mutual exclusion using interrupt
masking, and initialize at runtime.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2020-06-23 16:14:55 -04: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
Andrew Boie 4f77c2ad53 kernel: rename z_arch_ to arch_
Promote the private z_arch_* namespace, which specifies
the interface between the core kernel and the
architecture code, to a new top-level namespace named
arch_*.

This allows our documentation generation to create
online documentation for this set of interfaces,
and this set of interfaces is worth treating in a
more formal way anyway.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-11-07 15:21:46 -08:00
Maksim Masalski 6882d97531 tests: new updated names for the kernel tests
After run Sanitycheck script I found out that some test cases
have the same test case name in the test result .xml file.
To get rid of it, I decided to change test cases names
for the kernel tests.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2019-10-24 06:25:53 -04:00
Peter Bigot e28f330a8e coccinelle: standardize k_thread create/define calls with integer timeouts
Re-run with updated script to convert integer literal delay arguments
to k_thread_create and K_THREAD_DEFINE to use the standard timeout
macros.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-09 08:38:10 -04:00
Andy Ross 6214f81fed tests/kernel/spinlock: No need to use MP API anymore
This test was written very early.  Spinlocks are required for SMP
implementation.  They couldn't be tested in terms of it, so the test
used the low level MP API instead.  But of course that breaks if SMP
is actually working and the CPU is already started.

No need for that now.  Just spawn a thread like any other, and filter
the test to run only on SMP systems.

Fixes #19319

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-10-06 12:53:28 -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 4344e27c26 all: Update reserved function names
Update reserved function names starting with one underscore, replacing
them as follows:
   '_k_' with 'z_'
   '_K_' with 'Z_'
   '_handler_' with 'z_handl_'
   '_Cstart' with 'z_cstart'
   '_Swap' with 'z_swap'

This renaming is done on both global and those static function names
in kernel/include and include/. Other static function names in kernel/
are renamed by removing the leading underscore. Other function names
not starting with any prefix listed above are renamed starting with
a 'z_' or 'Z_' prefix.

Function names starting with two or three leading underscores are not
automatcally renamed since these names will collide with the variants
with two or three leading underscores.

Various generator scripts have also been updated as well as perf,
linker and usb files. These are
   drivers/serial/uart_handlers.c
   include/linker/kobject-text.ld
   kernel/include/syscall_handler.h
   scripts/gen_kobject_list.py
   scripts/gen_syscall_header.py

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-11 13:48:42 -04: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
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
Spoorthi K 934c8eae45 tests: spinlock: Add description and doxygen groups
Add test description, RTM links and doxygen groups
for spinlock tests

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-18 11:28:03 -04: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
Anas Nashif 1609f251ee tests: kernel: 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 e73a95bd64 tests: kernel: use a consistent test suite name
Lots of tests use different ways for naming tests, make this consistent
across all tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 22:55:20 -04:00
Anas Nashif 841835554d tests: kernel: stop relying on path for naming
Use proper test names instead of relying on path name where the test is
located.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-18 09:16:40 -05:00