All of the time_units conversion routines are now macros which means the
test cannot reference them as functions. Instead, create local static
functions which call each one of them and use those instead.
Signed-off-by: Keith Packard <keithp@keithp.com>
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>
This patch shows an example of how to use the timer behavior external
tool testing, using the Saleae Logic 2 application.
Also, some board overlays were added as examples.
Finally, testcase.yaml updated with parameters for the Saleae sample.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
This patch adds a way to simplify using an external tool to measure
timer behaviour on Zephyr. It modifies the timer behaviour
jitter_drift.c tests to toggle a GPIO pin (defined via a new DTS
compatible, "test-kernel-timer-behavior-external") that can be connected
to an external tool, such as a logic analyzer, to measure timer
behaviour.
This GPIO pin toggle is behind a new CONFIG_TIMER_EXTERNAL_TEST Kconfig.
A new pytest test is added so that it can collect the statistics from
the external tool and assert some measurements. To collect statistics
from the external tool, one needs to provide a Python module which
provides a `run(seconds, config)` method, that will perform the test and
return the statistics. Check the README file for more information about
this interface.
Finally, this on twister, this new test is behind a new fixture,
"gpio-timerout".
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
This board seems to have issue with data alignemnt after 843f66f and is
failing in CI. Exclude it while the problem is investigated.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Let's make this official: we use the suffix `_MASK` for the define
carrying the GENMASK for the attributes, and the suffix `_GET(x)` for
the actual macro extracting the attributes.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
The test_sem_take_timeout_isr depends on the thread's priority. But for
SMP platforms, the priority is different with no-SMP. High-priority
threads and low-priority threads might run simultaneously at different
cores. Set the test case run at 1cpu to fix such an issue.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
The heap size is not enough so that it will cause the testcase fail.
Increase to 32k to make sure it works for a long time in the future.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
The test assumed that interrupt line 5 was up for grabs, but it
is not in general. (For ex., on an nrf53_bsim this is the clock
interrupt, which cannot be hijacked).
Instead, for boards that define it, let's use the int line
used for offloading SW interrupts (which is defined for all posix
arch boards in tree)
And if this is not defined, let's skip the test.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The mr_canhubk3 board enables by default an off-chip watchdog that must
be serviced to avoid triggering a reset and cannot be disabled on a
per-test basis.
test_all_stats_usage assumes the CPU was never idle before the test
starts but this is not the case for mr_canhubk3 because the off-chip
watchdog driver has a thread kicked off during device init that will
conflict with the expected usage stats on this test. So skip this test
for this board.
Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
The _EXPIRED macro is no longer necessary. It is a relic of an older
timeout processing algorithm from several years ago.
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This is the final step in making the `zephyr,memory-attr` property
actually useful.
The problem with the current implementation is that `zephyr,memory-attr`
is an enum type, this is making very difficult to use that to actually
describe the memory capabilities. The solution proposed in this PR is to
use the `zephyr,memory-attr` property as an OR-ed bitmask of memory
attributes.
With the change proposed in this PR it is possible in the DeviceTree to
mark the memory regions with a bitmask of attributes by using the
`zephyr,memory-attr` property. This property and the related memory
region can then be retrieved at run-time by leveraging a provided helper
library or the usual DT helpers.
The set of general attributes that can be specified in the property are
defined and explained in
`include/zephyr/dt-bindings/memory-attr/memory-attr.h` (the list can be
extended when needed).
For example, to mark a memory region in the DeviceTree as volatile,
non-cacheable, out-of-order:
mem: memory@10000000 {
compatible = "mmio-sram";
reg = <0x10000000 0x1000>;
zephyr,memory-attr = <( DT_MEM_VOLATILE |
DT_MEM_NON_CACHEABLE |
DT_MEM_OOO )>;
};
The `zephyr,memory-attr` property can also be used to set
architecture-specific custom attributes that can be interpreted at run
time. This is leveraged, among other things, to create MPU regions out
of DeviceTree defined memory regions on ARM, for example:
mem: memory@10000000 {
compatible = "mmio-sram";
reg = <0x10000000 0x1000>;
zephyr,memory-region = "NOCACHE_REGION";
zephyr,memory-attr = <( DT_ARM_MPU(ATTR_MPU_RAM_NOCACHE) )>;
};
See `include/zephyr/dt-bindings/memory-attr/memory-attr-mpu.h` to see
how an architecture can define its own special memory attributes (in
this case ARM MPU).
The property can also be used to set custom software-specific
attributes. For example we can think of marking a memory region as
available to be used for memory allocation (not yet implemented):
mem: memory@10000000 {
compatible = "mmio-sram";
reg = <0x10000000 0x1000>;
zephyr,memory-attr = <( DT_MEM_NON_CACHEABLE |
DT_MEM_SW_ALLOCATABLE )>;
};
Or maybe we can leverage the property to specify some alignment
requirements for the region:
mem: memory@10000000 {
compatible = "mmio-sram";
reg = <0x10000000 0x1000>;
zephyr,memory-attr = <( DT_MEM_CACHEABLE |
DT_MEM_SW_ALIGN(32) )>;
};
The conventional and recommended way to deal and manage with memory
regions marked with attributes is by using the provided `mem-attr`
helper library by enabling `CONFIG_MEM_ATTR` (or by using the usual DT
helpers).
When this option is enabled the list of memory regions and their
attributes are compiled in a user-accessible array and a set of
functions is made available that can be used to query, probe and act on
regions and attributes, see `include/zephyr/mem_mgmt/mem_attr.h`
Note that the `zephyr,memory-attr` property is only a descriptive
property of the capabilities of the associated memory region, but it
does not result in any actual setting for the memory to be set. The
user, code or subsystem willing to use this information to do some work
(for example creating an MPU region out of the property) must use either
the provided `mem-attr` library or the usual DeviceTree helpers to
perform the required work / setting.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Zephyr device and device.pm tests uses device tree fragments applied
to main board device trees. For xenvm they have conflicting
address/size cells definition with board DT. It leads to CI and test
issues during build (xenvm has 0x2 cells, tests have 0x1).
Signed-off-by: Dmytro Firsov <dmytro_firsov@epam.com>
In test_kobject_perm_error, there are 13 kobjects to test but
the loop only do 12. So amend the code to test all 13 kobjects.
Also remove the parameter of tid to child thread as the child
thread is not using it.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This header does not expose any public APIs, so move it under
kernel/include and change files including it.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
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>
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>
Modify the signature of the k_mem_slab_free() function with a new one,
replacing the old void **mem with void *mem as a parameter.
The following function:
void k_mem_slab_free(struct k_mem_slab *slab, void **mem);
has the wrong signature. mem is only used as a regular pointer, so there
is no need to use a double-pointer. The correct signature should be:
void k_mem_slab_free(struct k_mem_slab *slab, void *mem);
The issue with the current signature, although functional, is that it is
extremely confusing. I myself, a veteran Zephyr developer, was confused
by this parameter when looking at it recently.
All in-tree uses of the function have been adapted.
Fixes#61888.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix few mismatched CONTAINER_OF, going from struct k_work to struct
triggered_test_item should pass by struct k_work_poll.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fix few instances of delayable work handlers using the k_work pointer
directly in a CONTAINER_OF pointing to a k_work_delayable.
This is harmless since the k_work is the first element in
k_work_delayable, but using k_work_delayable_from_work is the right way
of handling it.
Change a couple of explicit CONTAINER_OF doing the same work as the
macro in the process.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
CONFIG_COVERAGE has been incorrectly used to
change other kconfig options (stack sizes, etc)
code defaults, as well as some samples behaviour,
which should not have dependend on it.
Instead those should have depended on COVERAGE_GCOV,
which, being the one which adds special code and
temporary RAM storage for embedded targets,
require changes to many features.
When building for the native targets, all this was
unnecessary.
=> Fix the dependency.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The CMSIS module glue code was part of arch/ directory. Move it to
modules/cmsis, and provide a single entry point for it: cmsis_core.h.
This entry header will include the right CMSIS header (M or A/R).
To make this change possible, CMSIS module Kconfig/CMake are declared as
external, allowing us to add a new Zephyr include directory.
All files including CMSIS have been updated.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This test fails when icount is disabled, so enable it
See 7bdc621ba9 which disabled icount by
default for this platform.
Signed-off-by: Keith Packard <keithp@keithp.com>
Some 64 bit platforms do not have MMU, however the 64 bit platfoms need
a larger stack. This testcase fails with non-MMU 64 bit platform e.g.
v8r64 platform due to the stack overflow. To fix this issue, set 2k
stack for all 64 bit platforms (CONFIG_64BIT) as this is likely a common
issue for all non-MMU 64 bit platforms.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
The heap size is set to 20000 which is just not enough for v8r platform.
Fix testcases failure in tests/kernel/threads/ by increasing the heap
size to 21504.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
This follows the same convention that has already been adopted by Intel
Alder Lake and Raptor Lake boards.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The original issue is fixed some time ago, so re-enable the
test.
This reverts commit 52992b0658
("tests: skip the cpu_idle test for nsim_hs_smp")
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Some architectures such as RISC-v support more than 255 interrupts
per aggrigator. This diff adds the ability to forgo the aggrigator
pattern and use a configurable number of bits for multilevel
interruts.
Signed-off-by: Joshua Lilly <jgl@meta.com>
Adding a new simple test that checks that canaries values
are different between threads when CONFIG_STACK_CANARIES_TLS
is enabled.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Introduce new API to compare two timepoint values to
find the one that is going to expire sooner, or is already
expired.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
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>
With SMP, the private_mutex may not be locked fast enough by
thread_12 after the thread creation as it might take longer
for a thread to start running the entry function, resulting
in test failure when the main test thread goes into locking
it again. So give it a bit more delay after thread creation
so thread_12 has a chance to lock the private_mutex.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If CONFIG_SMP_TEST_RUN_FACTOR is zero, the switch torture test
is effectively not doing anything as the k_sleep() below is not
going to sleep at all, and all created threads are being
terminated (almost) immediately after creation. So if run
factor is zero, mark the test as skipped.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Commit a1d21ca69b ("tests: timer_behavior: don't fail the test with
timer wrap-arounds") simply ignored the total time validation whenever
any rollover was detected. Let's adjust the end timestamp according
to the number of rollovers instead.
Documentation for sys_clock_cycle_get_32() says it should count up
monotonically through the full 32 bit space, wrapping at 0xffffffff.
Therefore we just need to add 2^32 times the number of rollovers to
the end timestamp.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Add support for dynamic thread stack objects. A new container
for this kernel object was added to avoid its alignment constraint
to all dynamic objects.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Removes duplicate code and inconsistencies in the naming of the
cc13xx_cc26xx devicetree and RTC driver hierarchy and alignes it with
the actual TI product series naming hierarchy.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Add tests for the return value of `k_event_post`, `k_event_clear`,
`k_event_set` and ``k_event_set_masked`.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
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>
Add TEST_WORK_ITEM_WAIT_MS and TEST_SUBMIT_WAIT_MS config parameters
instead of hardcoded timeouts at kernel.workqueue test to allow its
customization on slow simulated platforms.
Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
This moves CONFIG_KERNEL_COHERENCE from prj.conf to Kconfig.
This gets rid of the cmake warning where CONFIG_KERNEL_COHERENCE
is assigned the value 'y' but gets the value ''. This is simply
done to avoid confusion when running the test manually.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
- Remove raising compilation error in `float_regs_arm_gcc.h`
These macros are checked in 'load_store.c', so no need to check them
again in 'float_regs_arm_gcc.h'
- Enable this test on the VFP platform of aarch32
Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
Increase RAM requirements for some test, we have many exotic platforms
failing to link due to the size of the test.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
- 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>
The default tick rate for the nRF RTC timer is 32768 Hz, so one tick
is ~30 us. This turns out to be too little for the following loop
executed in user mode on the Network core in nRF5340:
```
do {
t0 = k_uptime_ticks();
rem_ticks = k_timer_remaining_ticks(&remain_timer);
t1 = k_uptime_ticks();
} while (t0 != t1);
```
The time between the two calls to `k_uptime_tick()` is there always
above 30 us, so the loop never ends.
This patch decreases the tick rate for all nRF platforms because on
other nRf SoCs the time mentioned above is also close to 30 us and
apparently changes in code completely unrelated to this test affect
execution time of system calls in the above loop - the test started
to fail after commit 0014dd05f0 that
changes fdtable was merged and if `fdtable.c` is for example just
temporarily excluded from the build, the test passes.
The root cause of the problem seems to be related to user space
handling and this should to be investigated further. This patch
is applied only to allow this test to pass for the time being.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Use 13% instead of the default 10% when the nRF RTC timer is used
so that the allowed drift is at least one tick long (~122 us in
this case).
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
The kernel/context test_timer_interrupts() test has a loop calibration
phase to estimate the number of loops needed for 1 system tick.
By initializing this calibration to 1 instead of 0, we can avoid an
edge condition where the calibration phase indicates 0 loops are
required (a case that could happen when running on a slow simulator).
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Kernel is being built the same way for all those tests and there is not
much related to the linker generator in any of those tests. Just keep a
small set of tests to have needed coverage in the kernel.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
RT685 and RT494 ran out of mpu regions to do this test,
so add board overlays to disable the USB SRAM MPU
region definition because it is not needed for this test.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
mem_protect and sprintf stacks both need to be slightly larger than
currently defined in order to avoid stack overflow when using picolibc.
Signed-off-by: Keith Packard <keithp@keithp.com>
The test case will show an unexpected exception in the idle thread after
all test cases pass. The issue is caused by the main thread
stackoverflow.
Increase the main stack configured in this test case to fix the issue.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Test was previously relaxed for RISCV machine timer. I have a
platform where it fails on RISCV requiring further relaxation.
Relaxing precision for RISCV architecture.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
When the default C library is switched to picolibc, we need some tests to
make sure things still build with the minimal C library.
Signed-off-by: Keith Packard <keithp@keithp.com>
Test case for threads abort issue.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
We are currently reporting the wrong mismatching bits in in-between
bundles. Fix this and extend the test to cover the wrong case.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This adds a test to make sure kernel only threads cannot go
into user mode: doing so would result in kernel panic.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
1. Enable os_timer as a wakeup-source in the board
dts file.
2. Enable PM_DEVICE when PM is enabled.
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Add qemu_riscv32, qemu_riscv32e, and qemu_riscv64 targets
to the tests that list below. These set CONFIG_MULTITHREADING=n.
- tests/kernel/fatal/no-multithreading
- tests/kernel/mem_heap/mheap_api_concept
- tests/kernel/mem_slab/mslab_api
- tests/kernel/threads/no-multithreading
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
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>
With picolibc moving to using the common malloc implementation, samples and
tests with picolibc-specific settings need to switch to using the common
malloc settings instead.
Signed-off-by: Keith Packard <keithp@keithp.com>
This test was excluding and including only
the native_posix board, while it should have instead
excluded/allowed anything in the architecture.
=> Change the filtering accordingly.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Some devices do not need to perform any initialization, so allow the
init function to be NULL. In this case, the initialization code will
just mark the device as initialized, i.e. ready.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
If the timer driver only implements sys_clock_cycle_get_32() (meaning
CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER=n) and the hardware clock is high
enough then the reported cycle count may wrap an uint32_t during the
test. This makes validating the total test duration pointless as it
cannot be measured. Just print a warning instead of failing the test
in that case.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Looks like switching the main return value to int means that stack
frame persists and increases stack usage by a few bytes. Increase the
main stack size to avoid overflows.
Signed-off-by: Keith Packard <keithp@keithp.com>
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.
Most of these changes were automated using coccinelle with the following
script:
@@
@@
- void
+ int
main(...) {
...
- return;
+ return 0;
...
}
Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.
Signed-off-by: Keith Packard <keithp@keithp.com>
The init infrastructure, found in `init.h`, is currently used by:
- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices
They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:
```c
struct init_entry {
int (*init)(const struct device *dev);
/* only set by DEVICE_*, otherwise NULL */
const struct device *dev;
}
```
As a result, we end up with such weird/ugly pattern:
```c
static int my_init(const struct device *dev)
{
/* always NULL! add ARG_UNUSED to avoid compiler warning */
ARG_UNUSED(dev);
...
}
```
This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:
```c
static int my_init(void)
{
...
}
```
This is achieved using a union:
```c
union init_function {
/* for SYS_INIT, used when init_entry.dev == NULL */
int (*sys)(void);
/* for DEVICE*, used when init_entry.dev != NULL */
int (*dev)(const struct device *dev);
};
struct init_entry {
/* stores init function (either for SYS_INIT or DEVICE*)
union init_function init_fn;
/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
* to know which union entry to call.
*/
const struct device *dev;
}
```
This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.
**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
init: convert SYS_INIT functions to the new signature
Conversion scripted using scripts/utils/migrate_sys_init.py.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
manifest: update projects for SYS_INIT changes
Update modules with updated SYS_INIT calls:
- hal_ti
- lvgl
- sof
- TraceRecorderSource
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
tests: devicetree: devices: adjust test
Adjust test according to the recently introduced SYS_INIT
infrastructure.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
tests: kernel: threads: adjust SYS_INIT call
Adjust to the new signature: int (*init_fn)(void);
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
HiFive Unmatched is using size and address cells of length 2. It has to
use different overlays (with reg properties of correct length).
Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
When building this test with the armclang compiler we get the following
warning:
tests/kernel/interrupt/src/dynamic_isr.c
tests/kernel/interrupt/src/dynamic_isr.c:23:32: error: 'used' attribute
ignored on a non-definition declaration [-Werror,-Wignored-attributes]
extern struct _isr_table_entry __sw_isr_table _sw_isr_table[];
^
There is no need to add the __sw_isr_table on the extern, so remove it
to address the warning.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Clang complains when an unsigned value is passed to abs, even though there
is an implicit cast to a signed type. Insert an explicit cast to make clang
happy.
Signed-off-by: Keith Packard <keithp@keithp.com>
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Nordic targets use 24-bit RTC peripheral for system clock. Nordic system
clock timeout implementation relies on RTC CC (capture compare) when
the timeout is in future. Nordic system clock driver allows setting
alarm only to 3 or more counts from current counter value due to silicon
limitation (to ensure that CC event triggers before counter overflow).
RTC CC limitation does not have much impact on normal applications where
there is no need to schedule such short timeouts, but is problematic in
a timer test that expects being able to repeatedly schedule timeouts on
subsequent ticks.
Reduce system tick rate to 8192 on nRF targets to allow setting CC to
the very next tick. With system tick rate being 4 times less than the
hardware tick rate, it is always possible to schedule timeout to happen
in the next tick because ticks are 4 counts apart, i.e. current timer
value + 3 never runs past the next tick.
Fixes: #54211
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
This commit marks testcases that require working Power Managament with
the appropriate `pm` tag to allow proper testcase filtering in the board
YAML file.
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
SMP tests `inc_concurrency` and `smp_switch_torture` use a 'stressing'
approach to verify their results: run something for some time (or some
number of repetitions). However, in some environments, current 'stress'
levels can be quite high, making tests take a long time - environments
like emulators/simulators.
This patch adds a Kconfig that allows one to define a percentage factor
to the 'stress' (time or repetitions) used by these tests.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
If there are any CPU exceptions, printing a failed message
would allow twister to stop early instead of waiting for
timeout.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If there are any CPU exceptions, printing a failed message
would allow twister to stop early instead of waiting for
timeout.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The variable need_recover_spinlock is always set to false so
the spinlock recovery code is effectively no-op. So remove
everything related to the variable.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
A new Z_SPIN_DELAY() macro has been added which
can be used to reduce a bit the amount of noise
due to the POSIX arch need to break busy loops with
k_busy_wait().
Use it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Don't sample the first entry outside the timer as this is a different
code path which produces a different offset from the clock tick.
Use sys_clock_hw_cycles_per_sec() to be compatible with systems that
read their hardware clock frequency at run time.
Perform cycle difference computations with uint64_t. If ever the
magnitude of the absolute clock cycle values is greater than 52 bits
then the cast to a double will actually lose accuracy.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Adds REQUIRED to samples and tests for finding the zephyr package
to align all samples and tests with the same call and parameters.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
An assertion statement was a bit too strict. Period drift may come about
not only from kernel ticks being large but also from time conversion being
inexact due to division truncation.
Fixes: #55136
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
For some kernel tests, faults and exceptions are expected.
They are caught and the test would continue if the reasons
for faults are as expected. However, when the unexpected
reasons are encountered, the code simply prints a message
and calls k_fatal_halt(). When running under twister,
these messages are not the expected failed messages so
twister will spin till timeout although the execution
has already been halted. This adds another printk() before
halt to signal twister that the test has failed and bails
early.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
...test_inherit_resource_pool. This waits for the newly created
threads to finish before moving on to the next test. This fixes
an issue on qemu_x86_tiny where there would be a double fault
after all tests have run.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
qemu_x86 seems to take an extra instruction after the sti instruction
(irq_unlock) happens before it posts the interrupts. This can issues
if the instruction after the sti ends up reading the state that is
suppose to be updated by the ISR handler.
We see this behavior when building with LLVM. To workaround this issue
we add an arch_nop() to provide an extra instruction to allow the
interrupts to post.
Opened zephyrproject-rtos/sdk-ng#629 to track qemu issue.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
LLVM doesn't support SSE + 387 math. As such if SSE is enabled we
have to utilize SSE floating point. To utilize 387 math, SSE has
to be disabled.
Update the floating point related tests to introduce 387 only variants
that will build on both GCC & LLVM based tools. Than we exclude llvm
based (llvm, oneApi) toolchains from the CONFIG_X86_SSE_FP_MATH=n and
CONFIG_X86_SSE=y test variants.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Looks like some implementors decided not to implement the full set of
PMP range matching modes. Let's rearrange the code so that any of those
modes can be disabled.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This test relies on one thread interrupting another to exercize the FPU
sharing. On SMP those threads get one CPU each with no sharing of their
FPU making the test rather pointless.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Fix comments in board DTS files referring to AN521 tables defining
memory areas, and choose node label names that more accurately reflect
the entries of interest in those tables.
Adjust the one in-tree user of the affected node labels.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
When building with LLVM on qemu_x86 we see the compiler ends up
inlining the check_input function. This breaks the stack overflow
that the test is trying to generate, so mark the check_input()
function as noinline to fix the issue.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Provide an estimate of the test duration.
Make the output nicer than a few overloaded and wrapped lines.
Provide more context in the presence of period time drift.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Print the "perfect" reference period for easier evaluation.
Suggest a remedy to the missed ticks problem.
Still, that wasn't satisfactory. Implemented a count of missed ticks
to get to the bottom of this issue. Found that missed ticks always came
to a perfect count of 40.
Incidentally, the busy loop prints a line every 250 ms and the test spans
10 seconds. There are no such coincidences.
Turns out that CONFIG_PRINTK_SYNC was set by default. This disables IRQs
for the serial output duration, which can be quite long at 115200 bauds.
Given a 60-ish character line length, this represents more than 5 ms of
no IRQ servicing during a timer latency measurement test which is bad.
So make sure CONFIG_PRINTK_SYNC=n for proper statistics.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Disable tests/kernel/mem_protect/syscalls for qemu_arc_em where
we trigger ARC QEMU bug which cause illegal instruction exception
on perfectly valid ARC code.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Change expected reason code for cpu exception to be generic and
in compliance with a3774fd51aFixes#54335
Signed-off-by: Aastha Grover <aastha.grover@intel.com>
This test has trouble on qemu_x86_tiny and randomly generates a Double
Fault error. I couldn't get it to reliably run with picolibc as a Double
Fault usually occured before the test completed.
I spent a couple of hours attempting to track this down and found that it
happens when code pages for the main thread get unmapped because the
qemu_x86_tiny intentionally offers very few available PTEs.
Work around this by just using the minimal libc for this test.
Signed-off-by: Keith Packard <keithp@keithp.com>
Tune quantum parameter for selected kernel tests
targetting the HiFive Unleashed platform.
Those tests require higher fidelity of the virtual
time flow which is achievable on multi-core platforms
in Renode by reducing the quantum.
Signed-off-by: Jan Malek <jmalek@internships.antmicro.com>
Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
With lazy FPU context switching, k_float_disable() is merely triggering
a synchronous FPU context save and k_float_enable() is a no-op.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
After the dbe3874079 - (tests: kernel/smp: wait for threads to exits
between tests) I've started seeing sporadic kernel.multiprocessing.smp
test failures on our platforms.
------------------------------->8---------------------------------
[*snip*]
===================================================================
START - test_fatal_on_smp
E: r0: 0x3 r1: 0x0 r2: 0x0 r3: 0x0
E: r4: 0x80000194 r5: 0x0 r6: 0x0 r7: 0x0
E: r8: 0x800079c4 r9: 0x82802 r10: 0x80008d8c r11: 0x8000dad8
E: r0: 0x3 r1: 0x2712 r2: 0x114 r3: 0x0
E: r4: 0xf4240000 r5: 0x0 r6: 0xf424 r7: 0xbe40
E: r8: 0x2540 r9: 0x0 r10: 0x80008d8c r11: 0x8000db8c
E: r12: 0x8000ddf0 r13: 0x0 pc: 0x80000aec
E: blink: 0x80000ae6 status32: 0x80082002
E: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
E: Current thread: 0x8000db8c (test_fatal_on_smp)
E: r12: 0x8000ddf0 r13: 0x0 pc: 0x8000019a
PASS - test_fatal_on_smp in 0.014 seconds
===================================================================
START - test_get_cpu
E: blink: 0x80001490 status32: 0x80082002
E: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 1
E: Current thread: 0x8000dad8 (unknown)
------------------------------->8---------------------------------
The rootcause if that we doesn't proper cleanup resources after
test_fatal_on_smp test case. So child thread we start test_fatal_on_smp
may continue running for some time after the test_fatal_on_smp
test case is finished.
As in the next test case (test_get_cpu) we use same thead structures
again to create new child thread we may actually rewrite some data of
thread which is still running (or vise versa).
As we trigger the crash in test_fatal_on_smp we can't simply join
child thread in the end of test case (as we never get here). We can't
simply use join child thread before we initiate crash in test_fatal_on_smp
either as we don't want to introduce reschedule point here which may break
the test logic.
So, to fix that, we'll just do k_busy_wait in test_fatal_on_smp
thread after we start child thread to wait for thread trigger
exception and being terminated.
To verify that we also assert that child thread is dead by the
time when we stop busy waiting.
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Use namespacing with extra_configs in some tests and remove duplicated
scenarios the were made arch or platform specifc.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Adds a check for `K_ERR_ARM_USAGE_ILLEGAL_EPSR` as the reason code
when running this test for `CONFIG_ARMV7_M_ARMV8_M_MAINLINE`.
Signed-off-by: Kevin Townsend <kevin.townsend@linaro.org>
Fix all line-length errors detected by yamllint:
yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
grep '(line-length)'
Using a limit is set to 100 columns, not touching the commandlines in
GitHub workflows (at least for now).
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fix all comments-indentation errors detected by yamllint:
yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
grep '(comments-indentation)'
This checks that the comment is aligned with the content.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fix all thruthy errors detected by yamllint:
yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
grep '(truthy)'
This only accepts true/false for boolean properties. Seems like python
takes all sort of formats:
https://github.com/yaml/pyyaml/blob/master/lib/yaml/constructor.py#L224-L235
But the current specs only mention "true" or "false"
https://yaml.org/spec/1.2.2/#10212-boolean
Which is the standard yamllint config.
Excluding codeconv and workflow files, as some are using yes/no instead
in the respective documentation.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The test in its default configuration needs 3600 seconds to complete,
adjust timeout for twister to meet that.
Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
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>
Re-enable several mem_protect tests which were disabled due to
issues in ARC QEMU (which are fixed and fixes were propagated to
Zephyr SDK)
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
... to avoid undesirable delays in waking up of the threads on
scheduled timeouts. In specific configurations such additional load
of the CPU can be even harmful to the test. This was observed for
nRF platforms where the UART_NRF_DK_SERIAL_WORKAROUND Kconfig option
was enabled.
All calls to TC_PRINT() in this test suite are replaced with calls to
LOG_DBG(), so the status messages are not printed by default, but they
can be enabled if needed by changing CONFIG_LOG_DEFAULT_LEVEL.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
In the message reporting the wrong order of woken up threads
(e.g. "thread 3 woke up, expected 2"), provide indexes of
the threads in the timeout order array, not their timeout
order values.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
integration_platforms help us control what get built/executed in CI and
for each PR submitted. They do not filter out platforms, instead they
just minimize the amount of builds/testing for a particular
tests/sample.
Tests still run on all supported platforms when not in integration mode.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This adds a test to see if z_phys_unmap() can reclaim memory
correctly, so that the next z_phys_map() re-uses the same
address (with identical input arguments).
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The requirement of being able to spend only 10% of processing time
on execution of timer handlers that are scheduled on every tick is
not really possible to fulfill on platforms like the nRF ones where
the tick period is quite short (~30 us in this case). Relax this
requirement and accept if at least one-third of the processing time
is available for other work while handling the timer tick train.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
The test in its default configuration needs 3600 seconds to complete,
so use such timeout value in testcase.yaml so that twister called with
--enable-slow option can successfully execute it.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Test assumes that system clock is slow enough so 1 tick timeout
will not expire before k_timer_start function exists. That is
not the case when system clock is fast (relatively to the cpu
clock). Increase the timeout and add synchronization point.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The mem_map test was skipped on all the phsical x86 boards when
running twister to test them. This error happens when migrating
the new ztest. Remove the incorrect platform allow to fix this
error.
Signed-off-by: Enjia Mai <enjia.mai@intel.com>
Use the picolibc definition of _WANT_IO_LONG_LONG as that can only be set
when building the library, and not selected by the consumer.
Signed-off-by: Keith Packard <keithp@keithp.com>
This avoids problems when using timers for random numbers; run too fast and
all the values are the same.
Signed-off-by: Keith Packard <keithp@keithp.com>
After writing to mapped_rw, we should also check if the backing
buffer has the correct data. Or we could have a situation where
on systems that need explicit cache controls, the newly updated
mapped_rw is cached but the backing buffer still contain old
data. Comparing the backing buffer to mapped_ro does not really
matter in this case as the content would certain match.
Also, this moves the mapping of mapped_ro earlier so that we
map both mapped_rw and mapped_ro because data manipulation.
And that we also need to verify the values of the backing and
mapped buffers.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
There is an assumption on test_page buffer that the MMU page
size is 4kb so that there is a 8kb buffer for read/write.
However, page size may not be 4kb on all architectures.
We need to make sure the test buffer is large enough for
the read/write test.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The sys_sem.nouser test does not enable userspace which makes
k_thread_access_grant() no-op. However, XCC would still emit
LOOP instructions for the for-loop. Since there is nothing
to do, the XCC assembler complains about it being an empty
loop and errors out. So guard the k_thread_access_grant()
calls so they are only compiled if userspace is enabled.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Previously, this change was added to `mutex_error_case`.
That worked fine in `main`, but once the change was backported to
`v2.7-branch`, the test would fail because it *did not* cause a
failure. The reason for that, was that the `mutex_error_case`
suite has `CONFIG_ZTEST_FATAL_HOOK=y`.
With the newer ztest API, it allowed a separate suite to be used,
allowing the test to pass (although it did not really fit in with
the rest of the testsuite).
The solution is to simply merge it with the `mutex_api` suite
which uses non-inverted success logic.
This change will also have to be cherry-picked for the backport
in #49031.
Fixes#48056.
tests: kernel: mutex: move race timeout test to mutex_api
Previously, this change was added to `mutex_error_case`.
That worked fine in `main`, but once the change was backported to
`v2.7-branch`, the test would fail because it *did not* cause a
failure. The reason for that, was that the `mutex_error_case`
suite has `CONFIG_ZTEST_FATAL_HOOK=y`.
With the newer ztest API, it allowed a separate suite to be used,
allowing the test to pass (although it did not really fit in with
the rest of the testsuite).
The solution is to simply merge it with the `mutex_api` suite
which uses non-inverted success logic.
This change will also have to be cherry-picked for the backport
in #49031.
Fixes#48056.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
Move runtime checks to use arch_num_cpus() and build checks
to use CONFIG_MP_MAX_NUM_CPUS. This is to allow runtime
determination of the number of CPUs in the future.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Move runtime checks to use arch_num_cpus() to use
CONFIG_MP_MAX_NUM_CPUS. This is to allow runtime
determination of the number of CPUs in the future.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Move runtime checks to use arch_num_cpus() and build checks
to use CONFIG_MP_MAX_NUM_CPUS. This is to allow runtime
determination of the number of CPUs in the future.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Pick a platform that actual supports SMP - qemu_x86_64. Remove setting
CONFIG_TIMESLICING as that is already set.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Enable all cbprintf / logging related tests which were previously
disabled for qemu_arc_hs6x.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
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>
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>
Change for loops of the form:
for (i = 0; i < CONFIG_MP_NUM_CPUS; i++)
...
to
unsigned int num_cpus = arch_num_cpus();
for (i = 0; i < num_cpus; i++)
...
We do the call outside of the for loop so that it only happens once,
rather than on every iteration.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
For tests that set CONFIG_MP_NUM_CPUS, switch to using
CONFIG_MP_MAX_NUM_CPUS instead as we work to phase out
CONFIG_MP_NUM_CPUS.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
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>
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This test case will call k_sem_give() twice and expect both to be
received by k_sem_take(), yet the semaphore is initialized with a
maximum count of one!
The reason this worked was an undocumented misfeature of k_sem: if
k_sem_take() was called on a semaphore with a pended thread, it would
wake up that thread synchronously instead of incrementing the count.
So you could call it once to wake up the thread and again to queue the
count and not overflow. The problem is that this is a priority bug (a
high priority runnable thread should have the chance to run and call
k_sem_take() before a low priority thread that got woken).
Zync corrects that, and so needs to have two slots if you want two
semaphore events.
Signed-off-by: Andy Ross <andyross@google.com>
Test timers with a train of one tick timers to test that
a configured SYS_CLOCK_TICKS_PER_SEC is sensible. If the TICKS_PER_SEC
is too high the timer train will take longer than expected to reach
the station. Worse, if the timer driver has too short of a minimum
delay for its processing power and the tick rate is too high its
possible the device will get caught in an interrupt loop
preventing any threads from running while processing timers.
This test validates that the tick rate configured is actually able to be
processed without delays while also having work done in threads ensuring
that no thread scheduling delays occur either from delayed timers or an
interrupt loop from preventing threads from running.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Adds a custom test_main and renames the test suite for jitter_drift.
Runs the jitter_drift test suite.
The order of these tests matter on hardware as the counter is often
reset on loading the test program. This is useful as its far less likely
to encounter a clock counter rollover. On arm this is especially useful.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Move the main.c timer behavior test code to jitter_drift.c
so that other tests may be added to the suite.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
The _SYS_INIT_LEVEL* definitions were used to indicate the index entry
into the levels array defined in init.c (z_sys_init_run_level). init.c
uses this information internally, so there is no point in exposing this
in a public header. It has been replaced with an enum inside init.c. The
device shell was re-using the same defines to index its own array. This
is a fragile design, the shell needs to be responsible of its own data
indexing. A similar situation happened with some unit tests.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
We have cases where some devices needs to be initialized very early and
before c_start is call, i.e. to setup very early console or to setup
memory. Traditionally this would be hardcoded as part of the soc layer
and not using device model or the init levels.
This patch adds a new level ARCH, which will be called in early
architecture code and before we jump to the kernel code.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
In test_busy_wait and test_k_sleep test cases of
tests/kernel/context test we measure not only execution time of the
primitives itself (k_busy_wait and k_msleep respectively) but also
the overall test thread execution time.
The issue here is that we do printing in test threads which
means that we do printing in time-critical sections. That breaks
test if we do printing via some device which isn't fast enough.
Fix that by removing print from time-critical section
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
This changes to compile the IRQ offload test only if
CONFIG_IRQ_OFFLOAD=y. For architectures that do not support
IRQ offload (or that developers with to disable IRQ offload
during bring-up), compiling the code would result in linking
errors.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Say threadA holds a mutex and threadB tries
to lock it with a timeout, a race would occur
if threadA unlock that mutex after threadB
got unpended by sys_clock and before it gets
scheduled and calls k_spin_lock.
This patch supplies the test that can be used
to reproduce the problem and the fix that was
provided in #48056Fixes#48056
Signed-off-by: Christopher Friedt <cfriedt@fb.com>
In the default configuration of the test, with 10000 timer samples,
the `periodic_data` array is too big to fit in SRAM on many targets.
Use lower counts of samples for those, depending on their SRAM size,
leaving at least 8 kB for other variables, buffers, stacks etc.
Exclude the test for targets with less than 16 kB.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
The SMP config for RISC-V on QEMU triggers this:
|START - test_sem_queue_mutual_exclusion
|
|Assertion failed at
| WEST_TOPDIR/zephyr/subsys/testsuite/ztest/src/ztest_new.c:155:
| cpu_hold: (dt < 3000 is false)
|1cpu test took too long (4090 ms)
|ERROR: cannot fail in test 'after()', bailing
Looping 10000 times is maybe a bit excessive.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This reverts the commit 7d8a119213
because GCC is now configured to not emit ldp/stp Qn instructions for
consecutive 32-byte loads and stores, and the nested interrupt handling
failure due to the missing emulation of these instructions no longer
occurs.
For more details, refer to the GitHub issue #49491 and #49806.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Zephyr timer is based on system ticks, there usually exists some time drift
due to round up/down errors between cycles, ticks and time delay, we
need to add those expected time drift into the bound calculation for
running this test.
Add a new config TIMER_TEST_PERIOD_MAX_DRIFT_PERCENT for users to set
expected maximum drift percentage for the timer period.
Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
Tickless test enables PM which implies use of LPTIM as ticker on STM32
platforms.
Specifically on nucleo_l073rz, this configuration is fragile as only
LSI(37KHz) could be used as LPTIM tick source, whith a huge accuracy
tolerance (20%).
This works on most cases, when a specific tick freq (4000 ticks/sec),
but this tests explicitly requires tick frequency set to 100.
Excludes nucleo_l073rz for this test.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
The test case was originally designed for the coverage of
nop()/arch_nop() function. It is not very meaningful for
testing something but causing lots of false alarms on the
kernel/common test so far. Suggest removing this test case.
Signed-off-by: Enjia Mai <enjia.mai@intel.com>
Make sure msg is initialized before being used, fixes compiler warning:
main.c:735:9: error: 'msg' may be used uninitialized
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The k_sys_fatal_error_handler() function is declared in zephyr/fatal.h
with a name of "esf" for the second parameter, not "pEsf". For
unknown reasons, this is showing up in CI as a documentation
generation failure pointing at the (correct) header.
Still, no reason not to synchronize.
Signed-off-by: Andy Ross <andyross@google.com>
Obviously the test of the feature won't work if we don't have an IPI.
And there were two threads that spawned threads that enter busy loops,
expecting to be able to abort them from another CPU. That doesn't
work[1] without an IPI. Just skip these cases rather than trying to
kludge up some kind of abort signal.
[1] Rather, it does work, it just takes infinite time for these
particular test cases. Eventually the CPU would be expected to
receive some other interrupt like a timeout, which would work to
abort the running thread. But no such timer was registered.
Signed-off-by: Andy Ross <andyross@google.com>
This commit changes some tests from using zassert_equal to validate
the pointers to using the zassert_is_null and zassert_not_null.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
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>
This commit disables the RISC-V direct ISR test due to the broken
`vectors` section placement with the IRQ vector table enabled,
introduced by the commit d2f8ec70235208f4a70e371ccb1ed8dfe0f573c5.
For more details, refer to the GitHub issue #49903 tracking this bug.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
SYS_CLOCK_TICKS_PER_SEC of it8xxx2 is 4096 (244us).
Running test_sleep_abs item on it8xxx2 and we get
k_us_to_ticks_ceil32(250) = 2 and late = 2, so it failed.
After we enable the CONFIG_PM, it needs more time to resume
from low power mode, so I modify the logic to <= for passing
the test.
fixes#49605
Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
The test will always fail on emulated/simulated environments. Exclude
this one which was failing.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
NSEC_PER_MSEC should be defined along with the rest of the
per-sec macros in sys_clock.h. Currently, it's defined
multiply in a few separate locations.
Signed-off-by: Christopher Friedt <cfriedt@fb.com>
Inside test_get_cpu, the current CPU ID is stored in the test
thread's stack. Another thread is spawned with a pointer to
the variable holding this CPU ID, where this thread is supposed
to run on another CPU. On a cache incoherent platform, this
value of this variable may not have been updated on other CPU's
internal cache. Therefore when checking CPU IDs inside the newly
spawned thread, it is not checking the passed in CPU ID, but
actually whatever is on the another CPU's cache. This results in
random failure on the test_get_cpu test. Since for cache
incoherence architectures, CONFIG_KERNEL_COHERENCE is enabled by
default on SMP where shared data is placed in multiprocessor
coherent (generally "uncached") memory. The fix to this is to
simply make this variable as a global variable, as global
variable are consided shared data and will be placed in
multiprocessor coherent memory, and thus the correct value will
be referenced inside the newly spawned thread.
Fixes#49442
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds a bunch of k_thread_join() to make sure threads spawned
for a test are no longer running between exiting that test. This
prevents interference between tests if some threads are still
running when assumed not.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit disables the `kernel.poll` test on `qemu_arc_hs6x` because
it fails at run-time when compiled with GCC 12.
Revert this commit when the GitHub issue #49492, which tracks this bug,
is fixed.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit disables the `arch.interrupt` test on the ARM64 QEMU
targets (`qemu_cortex_a53` and `qemu_cortex_a53_smp`) because the
nested interrupt test fails when compiled with GCC 12.
Revert this commit when the GitHub issue #49491, which tracks this bug,
is fixed.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Test and validate the behavior of a timer driver.
Takes a number of absolute timer cycle samples of a periodic timer then
calculates statistical mean, variance, stddev along with total drift over
the entire test time. Ensures standard deviation and drift are within
a given configurable bound.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
The kernel.scheduler.dumb_no_timeslicing is duplicated.
Should be kernel.scheduler.dumb_timeslicing.
Otherwise, there'll be only 7 test configurations while
actually there should be 8.
Signed-off-by: Ming Shao <ming.shao@intel.com>