Commit Graph

1543 Commits

Author SHA1 Message Date
Maksim Masalski 555408d4e7 tests: access kernel object with private data using system call
When defining system calls, it is very important to ensure that
access to the API’s private data is done exclusively through system
call interfaces. Private kernel data should never be made available
to user mode threads directly. For example, the k_queue APIs were
intentionally not made available as they store bookkeeping
information about the queue directly in the queue buffers which are
visible from user mode.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2020-12-01 10:14:35 -06:00
Anas Nashif 98981ec05e tests: kernel: do not build on all platforms
build_on_all here was supposed to be a smoke test to test building on
all platforms, it should not be used for more than 1 just test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-11-30 13:10:32 -08:00
Trond Einar Snekvik 7986f94275 kernel: Add K_DELAYED_WORK_DEFINE
Adds a K_DELAYED_WORK_DEFINE, matching the K_WORK_DEFINE macro, with
accompanying Z_DELAYED_WORK_INITIALIZER macro.

Makes k_delayed_work_init a static inline function, like its K_WORK
counterpart.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-27 20:08:30 -05:00
Maksim Masalski 80123899c1 tests: add test to verify assertion cathes overlapped partitions
When adding the new partition to a memory domain the system must
assert that it does not overlap with any other existing partitions
in the domain.
Test to add new partition which has same start address as an
existing one, after that must happen an assertion error indicating
that new partition overlaps existing one.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2020-11-26 14:18:09 +01:00
Peter Bigot fbb7eb81b8 tests: kernel: work_queue: avoid improper access to internal structures
Nothing in the API description the delayed work structure sanctions
direct reference to internal fields.  Do not assume that a delayed
work item can be initialized in any way other than by invoking the
delayed work item init function.  Do not assume that a delayed work
item can be submitted without delay by invoking k_work_submit() with a
reference to the contained work item.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-24 13:04:48 +02:00
Steven Wang fcbbd32445 Test: correct an error in test_pipe_user_thread2thread().
In test_pipe_user_thread2thread(), what should be tested is
the pipe, which allocated with k_object_alloc(), rather than
"pipe" and "kpipe". That two pipes are already teseted in
test_pipe_thread2thread().

Signed-off-by: Steven Wang <steven.l.wang@linux.intel.com>
2020-11-20 10:57:05 +01:00
Andrew Boie 5a58ad508c arch: mem protect Kconfig cleanups
Adds a new CONFIG_MPU which is set if an MPU is enabled. This
is a menuconfig will some MPU-specific options moved
under it.

MEMORY_PROTECTION and SRAM_REGION_PERMISSIONS have been merged.
This configuration depends on an MMU or MPU. The protection
test is updated accordingly.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-11-18 08:02:08 -05:00
Meng xianglin e696c65de1 test: context: Refine descriptions for some test cases
Add or refine comments for some test cases for readability

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2020-11-17 22:11:45 -05:00
Enjia Mai a9bacf552c tests: improve test case descriptions of some interrupt APIs
To add some test case descriptions for testing irq_lock(), irq_unlock()
, irq_enable(), irq_disable().

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2020-11-17 19:25:59 -05:00
Peter Bigot 057a173e33 tests: fpu_sharing: avoid stack overflow due to unnecessary feature
CONFIG_FPU selects support for formatting floating point numbers,
which increases the stack requirements for cbprintf, causing this test
to overrun its stack.

Since this test doesn't format floating point numbers, use
CBPRINTF_NANO to revert to using the small-footprint formatter.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-17 17:49:22 -05:00
Peter Bigot 1d048df553 tests: add FP formatting to all tests that require it
Tests that include floating-point format specifications may need
cbprintf FP support.  Make sure it's available.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-17 14:44:59 -06:00
Martin Åberg b5bab421b7 tests: Avoid out-of-bounds array access on SPARC
The test reads and writes outside the bounds of an array allocated on
the stack in check_input(). This commit disables the test on SPARC.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-13 14:53:55 -08:00
Martin Åberg 645b411448 tests: kernel: context: SPARC support
This test requires explicit architecture support, which this commit adds
for SPARC.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-13 14:53:55 -08:00
Martin Åberg d2409ec0f7 tests: Big endian support in bitfield test
The BIT_INDEX() macro assumed little-endian. This commit adds
big-endian support, conditioned on the preprocessor define
CONFIG_BIG_ENDIAN.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-13 14:53:55 -08:00
Peter Bigot bb99422c8a lib/os: replace z_vprintk with cbprintf
Using the same implementation as the rest of Zephyr reduces code size.

Update options and expected results for formatting test.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-13 06:38:01 -05:00
Wentong Wu 6221439fbd tests: kernel: syscalls: add more than 6 arguments syscall test case
Add more than 6 arguments syscall test case.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-11-12 17:12:38 -05:00
iva kik 10fdf95b94 tests: k_heap api: add tests for k_heap_api
Add test cases to test k_heap_alloc() and k_heap_free() APIs

Fixes #29654

Signed-off-by: iva kik <megatheriumiva@gmail.com>
2020-11-12 15:51:45 -05:00
Andy Ross f3fe8af985 tests: Remove filtering on KERNEL_COHERENCE
These tests were suppressed when KERNEL_COHERENCE=y because of a
feature collision with CONFIG_POLL that has since been fixed.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-11-11 10:59:52 -05:00
Andy Ross 9487a1d0ca tests/queue: Remove fifo/queue "poll" variant tests
These test variants were there to test an older backend to the kernel
queue utility that used k_poll() as the blocking mechanism.  That code
got removed a while back, so these tests were just dupicates of the
main cases now.  Remove.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-11-11 10:59:52 -05:00
Ying ming 5829fd88a5 test: workqueue: add code description
Add testcase descriptions for test_work_item_supplied_with_func(),
test_sched_delayed_work_item(), test_workqueue_max_number(),
test_workq_start_before_submit(), test_work_submit_handler()

Signed-off-by: Ying ming <mingx.ying@intel.com>
2020-11-10 21:47:03 -05:00
Ying ming 255c4df04b test: workqueue: modify testcase
The thread name is used to judge whether the thread of
user-defined workqueue is created successfully.

Signed-off-by: Ying ming <mingx.ying@intel.com>
2020-11-10 21:47:03 -05:00
Andrew Boie ea6e4ad098 kernel: support non-identity RAM mapping
Some platforms may have multiple RAM regions which are
dis-continuous in the physical memory map. We really want
these to be in a continuous virtual region, and we need to
stop assuming that there is just one SRAM region that is
identity-mapped.

We no longer use CONFIG_SRAM_BASE_ADDRESS and CONFIG_SRAM_SIZE
as the bounds of kernel RAM, and no longer assume in the core
kernel that these are identity mapped at boot.

Two new Kconfigs, CONFIG_KERNEL_VM_BASE and
CONFIG_KERNEL_RAM_SIZE now indicate the bounds of this region
in virtual memory.

We are currently only memory-mapping physical device driver
MMIO regions so we do not need virtual-to-physical calculations
to re-map RAM yet. When the time comes an architecture interface
will be defined for this.

Platforms which just have one RAM region may continue to
identity-map it.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-11-09 20:19:13 -05:00
Alexandre Mergnat 0a5b25916c tests: protection: add riscv support
Execute tests are disabled for RISC-V because is isn't able
to set an execution restriction. From RISC-V documentation:
  "Instruction address-translation and protection are unaffected
  by the setting of MPRV"
MPRV is used to apply memory protection restriction when CPU is
running in machine mode (kernel).

Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
2020-11-09 15:37:11 -05:00
Alexandre Mergnat 39208c2700 tests: mem_protect: add riscv support
Add a memory region allocation for RISCV architecture.
Also fix an arbitraty value which can't work with
RISC-V granularity.

Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
2020-11-09 15:37:11 -05:00
Alexandre Mergnat 52e6b7fe6b tests: userspace: add riscv support
Add support for the following tests:
- test_write_control
- test_disable_mmu_mpu
- test_read_priv_stack
- test_write_priv_stack

Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
2020-11-09 15:37:11 -05:00
Steven Wang 788dd6356c Test: add doxygen comment for test_pipe_thread2thread().
Add doxygen comments for details of test_pipe_thread2thread().

By the way, plan to do the same thing to all test cases
in test_pipe_contexts.c.

Signed-off-by: Steven Wang <steven.l.wang@linux.intel.com>
2020-11-06 13:14:36 -05:00
Ying ming d40fad4dcd test: atomic operation : add test case
Add tests with negative parameters to supplement black box tests.

Signed-off-by: Ying ming <mingx.ying@intel.com>
2020-11-05 11:56:52 -08:00
Andrew Boie 4303d35380 tests: mem_protect: add migration test case
We need to make sure that if we migrate a thread to another
memory domain, the migration process doesn't cause the target
thread to explode. This is mostly a concern on SMP systems;
the thread could be running on another CPU at the same time.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-11-05 09:33:40 -05:00
Andrew Boie eeab568a27 tests: userspace: fix tests that don't hold on MMU
MMU threads within the same memory domain have access to
each other's stacks.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-11-05 09:33:40 -05:00
Enjia Mai 5b2f00779b Tests: Minor change in description and group of SMP test cases
Do minor change of the descriptions and doxygen group name in order to
pave the way for generation the test specification.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2020-11-03 11:04:50 +01:00
Peter Bigot 758c8b34b1 tests: kernel: work_queue_api: relax test to eliminate racy checks
We can't control ticks accurately enough to detect the transition
between on a queue and being handled, so relax the checks to make
things pass.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-02 14:25:21 -05:00
Enjia Mai 90e6f21d20 tests: modify the test case gen_isr_table using ztest
Modify the gen_isr_table test case to using ztest. Although it was
split up to three test cases, the test logic and the tested platform
are totally the same as previous one.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2020-10-30 15:57:03 +01:00
Enjia Mai 761eafa57b tests: improve test case descriptions of arch layer interface
To add more test case descriptions for architecture layer interface
arch_start_cpu().

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2020-10-30 15:55:42 +01:00
Andy Ross 0875740a34 tests/kernel/schedule_api: Fix slop in timeslice test
This test is a little subtle: it wants to spawn three threads to run
and be switched out by a timeslice interrupt.  And it wants to consume
half a time slice itself before it starts running.  And, because
timeslicing runs out of the same tick framework in the timer driver,
it needs to align to the start of a tick before the process starts.
And further: it does its own time math not in ticks but in timer
cycles, so it's quite sensitive to slop.

But it's "synchronize to tick boundary" code was actually
synchronizing to a CYCLE boundary, which is just wrong.  And it was
doing this in the wrong order.  It was resetting the timeslice first
and then synchronizing to a tick by spinning, which means that the
test was always going to begin as much as a tick late.  Do the tick
synchronization (via a sleep) first.

Finally, the manager thread that was spawning the new threads lives at
the same priority as the highest priority child threads, which means
it can potentitially wake up on the semaphores that they are giving in
the middle of the test and consume CPU unexpectedly.  Make sure it's
sleeping for the duration.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-10-29 07:39:39 -04:00
Andrew Boie f4a4583e13 tests: sys_sem: add k_thread_join() calls
There is a race condition between the child threads
exiting, and the child threads getting re-used in the
next scenario. This reproduces more often on SMP systems.

Close the race by joining on the child threads before
exiting any test scenario.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-28 10:29:49 -07:00
Ying ming 783155ad99 test: atomic operation : add code description
The existing testcase's doxygen describes are the general
implementation idea of a function.On this basis, adding
more descriptive statements to describe which conditions need
to be preset when running the testcase, which test techniques
are applied, and describe the testcase Design steps in detail.
Make it more readable.

Signed-off-by: Ying ming <mingx.ying@intel.com>
2020-10-27 09:14:08 -04:00
YouhuaX Zhu f83041f2e8 Test: Refine annotaion and testcase for poll.
1. Add more detail info to make the purpose and process
of the test cases more clear which include test goal,
test step, input, judging criteria, constraints, etc.,
and these can be seen in our Zephyr documentations.
2. Add some negative test code.

Signed-off-by: YouhuaX Zhu <youhuax.zhu@intel.com>
2020-10-27 09:06:35 -04:00
YouhuaX Zhu 4772d40d5f Test: Refine annotaion and testcase for pipe.
1. Add more detail info to make the purpose and process
of the test cases more clear which include test goal,
test step, input, judging criteria, constraints, etc.,
and these can be seen in our Zephyr documentations.
2. Add more negative testcase.

Signed-off-by: YouhuaX Zhu <youhuax.zhu@intel.com>
2020-10-27 09:05:47 -04:00
Andrew Boie 5e18b5512b tests: mem_protect: rewrite memory domain tests
This suite now uses far less memory and is much simpler.
We still maintain coverage of all the memory domain APIs
and ensure that the maximum number of partitions can be
applied.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-26 08:58:00 -04:00
Andrew Boie e26f21c96c tests: mem_protect: merge two duplicate tests
The tests test_mem_part_auto_determ_size and
test_mem_part_auto_determ_size_per_mpu are supposed to
just be checking the construction of automatic memory
partitions.

test_mem_part_auto_determ_size had a bunch of extraneous
stuff covered by other test cases and reserved three
different thread stacks.

These two tests have been drastically simplified and
combined.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-26 08:58:00 -04:00
Andrew Boie 54aa0f0c81 tests: mem_protect: delete duplicate test
test_mem_part_inherity_by_child_thr duplicates logic already
present in test_permission_inheritance. That test puts a
buffer called 'inherit_buf' in 'inherit_memory_partition'
and shows that it is accessible by a child thread by
writing to it.

Delete this unnecessary test.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-26 08:58:00 -04:00
Andrew Boie ae69f87fac tests: mem_protect: improve main.c organization
Tests are now grouped in the C file they occur in.

test_mark_thread_exit_uninitialized no longer occurs twice.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-26 08:58:00 -04:00
Andrew Boie 4ae0f9b867 tests: mem_protect: update bss vars test
ztest_mem_partition is fine for this test. We can also run it
in user mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-26 08:58:00 -04:00
Andrew Boie 8022aabbe8 tests: mem_protect: move partition tests
Some tests only evaluate characteristics of k_mem_partitions.
Move these to a separate C file.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-26 08:58:00 -04:00
Andrew Boie 44ca58181a tests: mem_protect: static scope globals
put all globals only used in this C file in static scope, which
revealed that a few of them were not used at all.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-26 08:58:00 -04:00
Andrew Boie 5c5e3597c8 tests: userspace: reduce memory domains to one
We now just use two memory domains; the default domain and an
'alternate_domain' used for tests that need to handle a memory
domain switch.

Along the way the test code was simplified.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-26 13:01:29 +01:00
Daniel Leung d963bda4c2 tests: kernel/common: enable testing TLS
This enables testing of thread local storage as this tests
errno.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-10-24 10:52:00 -07:00
Daniel Leung 55c3fb3ff1 tests: add a simple test for thread local storage
This adds a simple test to make sure TLS works.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-10-24 10:52:00 -07:00
Andrew Boie 933b420235 kernel: add context pointer to thread->fn_abort
For compatibility layers like CMSIS where thread objects
are drawn from a pool, provide a context pointer to the
exited thread object so it may be freed.

This is somewhat obscure and has no supporting APIs or
overview documentation and should be considered a private
kernel feature. Applications should really be using
k_thread_join() instead.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-22 23:32:37 -04:00
Andrew Boie ba7e89b1d6 tests: sys_mutex: don't add to default domain
This is unnecessary; static threads start in the default
memory domain.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-22 16:47:07 -07:00