Commit graph

1385 commits

Author SHA1 Message Date
Andrew Boie 06d7746cd2 kernel: cover k_array_index_sanitize()
Needed an explicit test for this function for code
coverage purposes; we were relying indirectly on
other code using it.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-30 09:22:09 -04:00
Andrew Boie e8092894a1 tests: futex: improve coverage
Error cases weren't being tested; bring up coverage for
kernel/futex.c up to 100% file/function/branch.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-30 09:18:47 -04:00
Andrew Boie 0b0294d682 kernel: cover k_usleep() from user mode
No test was exercising the k_usleep() system call, run
the test case as a user thread to fix code coverage.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-29 20:55:07 -07:00
Andrew Boie ca3549d9f5 tests: sys_mutex: improve code coverage
Test error cases and alternative implementation to bring code
coverage up to 100% file / 100% line.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-29 13:31:14 -07:00
Anas Nashif 5b0aa794b2 cleanup: include/: move misc/reboot.h to power/reboot.h
move misc/reboot.h to power/reboot.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif efb8df5366 cleanup: include/: move misc/stack.h to debug/stack.h
move misc/stack.h to debug/stack.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 536dd5a71f cleanup: include/: move misc/slist.h to sys/slist.h
move misc/slist.h to sys/slist.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 0c9e280547 cleanup: include/: move misc/mutex.h to sys/mutex.h
move misc/mutex.h to sys/mutex.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 08ee8b09ba cleanup: include/: move misc/mempool.h to sys/mempool.h
move misc/mempool.h to sys/mempool.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif ee9dd1a54a cleanup: include/: move misc/dlist.h to sys/dlist.h
move misc/dlist.h to sys/dlist.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5d001f3e41 cleanup: include/: move misc/byteorder.h to sys/byteorder.h
move misc/byteorder.h to sys/byteorder.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5eb90ec169 cleanup: include/: move misc/__assert.h to sys/__assert.h
move misc/__assert.h to sys/__assert.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 190e368275 cleanup: include/: move power.h to power/power.h
move power.h to power/power.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif e1e05a2eac cleanup: include/: move atomic.h to sys/atomic.h
move atomic.h to sys/atomic.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Ioannis Glaropoulos bceca79804 tests: kernel: fatal: check stack overflow of FP capable threads
Test the HW stack protection feature for threads that are
pre-tagged as FPU users, when building with support for FP
shared registers mode (CONFIG_FP_SHARING=y).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-27 18:07:03 -07:00
Ioannis Glaropoulos 1dd2796b6f tests: kernel: add simple test for the ramfunc feature
This commit contributes a simple test for
the ARM RAMFUNC feature.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-27 12:44:20 -07:00
Charles E. Youse ad409f4bce tests/kernel/context: add case for CONFIG_APIC_TIMER
Test needs trivial modification to account for new APIC timer code.
Eventually CONFIG_APIC_TIMER_IRQ, CONFIG_LOAPIC_TIMER_IRQ, etc. will
be consolidated into one CONFIG_TIMER_IRQ to reduce the noise a bit.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-06-27 07:20:54 -04:00
Ioannis Glaropoulos 1e29d40e87 tests: kernel: arm runtime nmi: add arm tag
Add the arm tag to tests/kernel/arm_runtime_nmi test.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-26 09:55:13 -04:00
Ioannis Glaropoulos e5c0e3caa1 tests: kernel: submit a simple test for zero-latency irqs
The commit contributes a simple test for the Zero-Latency
IRQ feature (CONFIG_ZERO_LATENCY_IRQS=y) for ARM platforms.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-26 09:55:13 -04:00
Nicolas Pitre 659fa0d57d lifo/fifo: first word is not always first 4 bytes
The first word is used as a pointer, meaning it is 64 bits on 64-bit
systems. To reserve it, it has to be either a pointer, a long, or an
intptr_t. Not an int nor an u32_t.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-26 09:08:42 -04:00
Andy Ross c0630346c8 Revert "tests: tickless_concept: Fix slicing time measurement"
Unfortunately this seems to have introduced spurious failures on (at
least) qemu_x86 and qemu_xtensa.

The change limits the timeslice tolerance to +/- 1ms, which isn't
necessarily correct when the tick rate is less than 1ms (though it
will probably work on deterministic hardware as long as the system is
hitting the target at exactly the right tick), and isn't even
theoretically achievable on emulation environments where timing
granularity is limited by the host scheduling quantum.

What this needs to do is check the deadline is off by at most one
tick, and trust the platform integration to have set the tick rate
appropriately.

(I do worry that the earlier version of the test was trying to set the
limit at half the TICKLESS_IDLE_THRESHOLD, though -- that seems weird,
and hints that maybe the test is trying to do something more
elaborate?)

Fixes #17063.

This reverts commit 62c71dc4d8.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-06-26 09:59:47 +02:00
Andrew Boie 643f86f1f2 tests: thread_apis: exercise some system calls
We had no system call coverage for k_thread_suspend
and k_thread_resume.

Some unnecessary cleanup tasks in the test case have
been removed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-25 22:45:09 -04:00
Andrew Boie ffd182a04b tests: device: cover device_get_binding()
We had no coverage for invoking this from a system call.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-25 22:44:14 -04:00
Andrew Boie 848221812f tests: userspace: cover z_object_recycle()
We didn't have code coverage for this function anywhere
except indirectly through some network tests; exercise it
in the suite of userspace tests.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-25 17:28:19 -07:00
Andrew Boie d053ba59ac tests: dynamic_thread: cover thread_idx_free()
Address a coverage gap in kernel/userspace.
Unfortunately, in the process of fixing this, a bug was
discovered, see #17023.

This test is user mode specific, filter the testcase
on whether userspace is available instead of ifdefing
the code.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-25 17:28:19 -07:00
Andrew Boie 777336ef38 tests: userspace: cover missing/bad syscalls
We were missing code coverage for bad or unimplemented
system call IDs.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-25 17:28:19 -07:00
Andrew Boie 31c4cc54fa tests: common: cover k_cycle_get_32() syscall
We had plenty of coverage for k_cycle_get(), but not its
32-bit variant. Run a case in user mode so that the system
call handler gets covered.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-25 17:22:52 -07:00
Charles E. Youse 3dc7c7a6ea drivers/interrupt_controller/mvic.c: remove MVIC interrupt controller
The Quark D2000 is the only x86 with an MVIC, and since support for
it has been dropped, the interrupt controller is orphaned. Removed.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-06-25 08:06:43 -04:00
Wentong Wu a30162be35 tests: add futex test cases
add futex test cases.

Fixes: #14493.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-06-24 15:38:21 -07:00
Ioannis Glaropoulos 0180b94afd tests: kernel: fatal: add explicit test case for ARM and FP Sharing mode
For the ARM architecture we would like to test the HW
Stack Protection feature when building with support for
FP shared registers mode (CONFIG_FP_SHARING=y), as a
means of increasing coverage.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-24 13:26:47 -07:00
Ioannis Glaropoulos 723aae9503 tests: kernel: mem_protect: use correct define for MEM_REGION_ALLOC
For ARM architecture, use Z_THREAD_MIN_STACK_ALIGN to define
MEM_REGION_ALLOC in tests/kernel/mem_protect/mem_protect/.
STACK_ALIGN takes into account MPU stack guard alignment
requirements. However, application memory partitions do not
require MPU stack guards, therefore, the alignment requirements
are not applicable here.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-24 10:16:57 -07:00
Kumar Gala 2910b5eac1 tests/kernel/context: Fix TICK_IRQ define for RV32M1 lptmr_timer
We missed converting DT_OPENISA_RV32M1_LPTMR_SYSTEM_LPTMR_IRQ to
DT_OPENISA_RV32M1_LPTMR_SYSTEM_LPTMR_IRQ_0.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-21 16:17:05 -05:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Ioannis Glaropoulos 8004082389 tests: kernel: fatal: add explicit no user-mode test case
We would like to test the HW stack protection feature in ARM
builds with no user-mode support, i.e. CONFIG_USERSPACE=n. For
that we add a new test-case in tests/kernel/fatal test suite.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-19 09:07:57 -07:00
Andrew Boie 6020a50092 tests: schedule_api: skip test assert if COVERAGE
This test case is so timing sensitive that gathering code
coverage data screws up the results.

Since this is an abnormal execution environment anyway,
just skip the assertions if CONFIG_COVERAGE=y.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-19 08:42:50 -04:00
Andrew Boie 03f22773c5 tests: schedule_api: test syscalls from usermode
We didn't have any coverage of the system call handlers for
k_wakeup() and k_is_preempt().

Increase RAM requirements due to stack alignment constraints
on MPU platforms when user mode is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-19 08:42:50 -04:00
Andrew Boie b5d3ba4634 tests: schedule_api: exercise SCHED_MULTIQ
This option should work on any arch, don't reserve
this just for native_posix.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-19 08:42:50 -04:00
Andrew Boie a3eb8c4ade tests: schedule_api: fix extern tstacks
Fix how the tstacks array was declared extern so this
actually compiles on all platforms with user mode enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-19 08:42:50 -04:00
Ulf Magnusson eba81c6e54 yaml: Remove redundant document separators
YAML document separators are needed e.g. when doing

  $ cat doc1.yaml doc2.yaml | <parser>

For the bindings, we never parse concatenated documents. Assume we don't
for any other .yaml files either.

Having document separators in e.g. base.yaml makes !include a bit
confusing, since the !included files are merged and not separate
documents (the merging is done in Python code though, so it makes no
difference for behavior).

The replacement was done with

    $ git ls-files '*.yaml' | \
        xargs sed -i -e '${/\s*\.\.\.\s*/d;}' -e 's/^\s*---\s*$//'

First pattern removes ... at the end of files, second pattern clears a
line with a lone --- on it.

Some redundant blank lines at the end of files were cleared with

    $ git ls-files '*.yaml' | xargs sed -i '${/^\s*$/d}'

This is more about making sure people can understand why every part of a
binding is there than about removing some text.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-19 10:40:10 +02:00
Andrew Boie 94b9640a9c tests: poll: expand userspace coverage
The syscall handler for k_poll() returns error values
instead of killing the caller for various bad arguments,
cover these cases.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 09:08:01 -04:00
Andrew Boie 682a53db28 tests: queue: test k_queue_alloc_*pend()
These were never getting called anywhere from user mode,
except for k_queue_alloc_append(), but only by virtue of
some workqueue tests.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 09:08:01 -04:00
Andrew Boie d87a90e4b9 tests: mutex_api: run in user mode
Addresses coverage gaps. Some changes were made so that exited
threads do not have k_thread_abort() called on them.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-18 09:08:01 -04:00
Nicolas Pitre 2b32059a61 printk: make it 64-bit compatible
On 64-bit systems the most notable difference is due to longs and
pointers being 64-bit wide. Therefore there must be a distinction
between ints and longs. Similar to the prf.c case, this patch properly
implements the h, hh, l, ll and z length modifiers as well as some small
cleanups.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-17 10:28:44 -07:00
Ioannis Glaropoulos f4f2b13126 tests: kernel: fatal: add HW stack check for priv stack
This commit adds a test in tests/kernel/fatal test-suite, which checks
that the HW stack overflow detection works as expected during a user
thread system call.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-17 10:27:52 -07:00
Ioannis Glaropoulos 02a3c52084 tests: kernel: userspace: correct address of thread priv stack start
In ARM architecture z_priv_stack_find() returns the start of a
thread's privilege stack; we do not need to subtract the length
of a (possible) stack guard. This commit corrects the assigning
of the start address of a thread privilege stack in
test/kerne/mem_protect/mem_protect/userspace.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-17 09:47:21 -07:00
Charles E. Youse c2c85a2a48 arch/x86/Kconfig: remove CONFIG_ISA_IA32
This option is set iff CONFIG_X86 is set, thus it provides no useful
information. Remove the option and replace references with CONFIG_X86.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-06-14 05:49:13 -04:00
Nicolas Pitre 3d51f7c266 k_stack: make it 64-bit compatible
The k_stack data type cannot be u32_t on a 64-bit system as it is
often used to store pointers. Let's define a dedicated type for stack
data values, namely stack_data_t, which can be adjusted accordingly.
For now it is defined to uintptr_t which is the integer type large
enough to hold a pointer, meaning it is equivalent to u32_t on 32-bit
systems and u64_t on 64-bit systems.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-14 05:46:29 -04:00
Ioannis Glaropoulos 9f8044e6b5 tests: kernel: fp_sharing: call k_float_disable() for ARM
We can now invoke k_float_disable(.) for ARM platforms,
too, since we introduced the function as a cross-arch
system call.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-12 09:17:45 -07:00
Nicolas Pitre 6311766d9a pointer-type args: cast appropriately to be 64-bit compatible
Using void pointers as universal arguments is widely used. However, when
compiling a 64-bit target, the compiler doesn't like when an int is
converted to a pointer and vice versa despite the presence of a cast.
This is due to a width mismatch between ints (32 bits) and pointers
(64 bits). The trick is to cast to a widening integer type such as
intptr_t and then cast to
void*.

When appropriate, the INT_TO_POINTER macro is used instead of this
double cast to make things clearer. The converse with POINTER_TO_INT
is also done which also serves as good code annotations.

While at it, remove unneeded casts to specific pointer types from void*
in the vicinity, and move to typed variable upon function entry to make
the code cleaner.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-12 08:20:52 -07:00
Nicolas Pitre 1f35774407 memslab/mempool: make tests 64-bit compatible
Minimum block size is 2x larger on 64-bit systems, so let's simply
double all size params. This won't change the validity of those tests
on 32-bit systems. Alignment tests are also adjusted for wider pointers.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-11 09:38:06 -07:00
Andrew Boie 324ae6fd56 tests: tickless_concept: disable for coverage
This test is already flaky, but becomes even flakier when
coverage is enabled.

Disable until we put a stake through the QEMU timing issues
being worked on in #14173.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-06 09:29:12 -07:00
Piotr Zięcik a45ce52253 tests: timer_api: Fix timer synchronization
The test_timer_periodicity waits for first timer expiration
in order to extract timer firing time. The wait is performed
using k_timer_status_sync() API call, which blocks thread
until timer expiration. However if the timer expired before
call the this function, it will return immediately, triggering
test failure.

This commit adds the second call to the k_timer_status_sync()
to ensure that the following part of the test will be executed
as soon as possible after timer expiration.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-06-06 09:31:26 -04:00
Anas Nashif 2fb19fcbdd style: samples/tests: add braces around if/while statements
Per guidelines, all statements should have braces around them. We do not
have a CI check for this, so a few went in unnoticed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-06 15:20:21 +02:00
Andy Ross ed5185ba12 tests/kernel/fatal: Fix wait-for-interrupt delay in stack check test
Contrary to the comment in code, this test is NOT, in fact, compiled
with a traditional ticked kernel.  Spinning won't work reliably
because interrupts won't necessarily be delivered when you expect.
This test case would fail spuriously as I moved things around when
debugging.

Doing it right (using a k_timer in this case) is actually less code
anyway.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-06-03 12:03:48 -07:00
Andy Ross e6af0f8caa arch/*: Add z_arch_irq_unlocked() predicate and test
It's useful to be able to inspect the key returned from
z_arch_irq_unlock() to see if interrupts were enabled at the point
where z_arch_irq_lock() was called.  Architectures tend to represent
this is a simple way that doesn't require platform assembly to
inspect.

Adds a simple test to kernel/common that validates this predicate with
a nested lock.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-06-03 12:03:48 -07:00
Ioannis Glaropoulos 13a587756c tests: kernel: userspace: explicitly declare function for the test
In the wake of moving the internal API header arm_core_mpu_dev.h
into arch/arm/cortex_m/mpu, we need to explicitly declare the
arm_core_mpu_disable() function in the userspace test. Note that
arm_core_mpu_disable() (as any other function in this internal
API) is not supposed to be called directly by kernel/application
functions; an exception is allowed in this test suite, so we are
able to test the MPU disabling functionality.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-05-30 09:00:05 -05:00
Marc Herbert 4afcc0f8af sanitycheck: CONFIG_TEST_USERSPACE / userspace tag cleanup
- Delete CONFIG_TEST_USERSPACE=n no-ops because it's the default
since commit 7b1ee5cf13

- Some tests have a "userspace" tag pretending to TEST_USERSPACE but
don't and vice versa: fix missing or spurious "userspace" tags in
testcase.yaml files.

Tests have a _spurious_ "userspace" tag when they PASS this command
cause none should pass:

  ./scripts/sanitycheck --tag=userspace -p qemu_x86 \
      --extra-args=CONFIG_TEST_USERSPACE=n  \
      --extra-args=CONFIG_USERSPACE=n | tee userspace.log

All tests run by this command must either fail to build or fail to run
with some userspace related error. Shortcut to look at all test
failures:

 zephyr_failure_logs() {
     awk '/see.*log/ {print $2}' "$@"
 }

Tests _missing_ "userspace" tag FAIL to either build or to run with some
userspace related error when running this:

  ./scripts/sanitycheck --exclude=userspace -p qemu_x86 \
      --extra-args=CONFIG_TEST_USERSPACE=n  \
      --extra-args=CONFIG_USERSPACE=n | tee excludeuserspace.log

Note the detection methods above are not 100% perfect because some
flexible tests like tests/kernel/queue/src/main.c evade them with #ifdef
CONFIG_USERSPACE smarts. Considering they never break, it is purely the
test author's decision to include or not such flexible tests in the
"userspace" subset.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-05-30 08:45:39 -04:00
Henrik Brix Andersen c3ccbbbdc3 tests: kernel: common: add missing userspace tag
Add missing userspace tag to the kernel/common test suite.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2019-05-26 08:56:08 -04:00
Piotr Zięcik ba4eae14dd tests: test_sched_timeslice_reset: Fix slice time measurement
The time measurement based on k_uptime_delta() might be not accurate
for some values of CONFIG_SYS_CLOCK_TICKS_PER_SEC. This commit
introduces measurement based on k_cycle_get_32(), which is more
precise.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-05-23 09:28:58 -04:00
Piotr Zięcik 62c71dc4d8 tests: tickless_concept: Fix slicing time measurement
The time measurement based on k_uptime_delta() might be not accurate
for some values of CONFIG_SYS_CLOCK_TICKS_PER_SEC. This commit
introduces measurement based on k_cycle_get_32(), which is more
precise.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-05-23 09:28:58 -04:00
Piotr Zięcik 86f012d27c tests: timer_api: Fix test for SYS_CLOCK_TICKS_PER_SEC != 100
This commit changes the timer_api test in order to take under account
fact that timeouts used in the test might not be aligned to tick
boundary.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-05-23 09:28:58 -04:00
Charles E. Youse 9ab293b919 tests/kernel/sleep: add tests for k_usleep() API
Test that k_usleep() allows sleep durations near the limit of what
the platform's tick rate will allow.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-05-21 23:09:16 -04:00
Wentong Wu fc3270d09c tests: kernel: increase stack buffer when code coverage enabled
increase stack buffer when code coverage enabled.

Fixes: #15794.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-05-16 09:29:55 -07:00
Filip Kokosinski c0c3cdfc57 drivers: timer: add LiteX timer driver
Add LiteX timer driver with bindings for this device.

Signed-off-by: Filip Kokosinski <fkokosinski@internships.antmicro.com>
Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
2019-05-15 12:52:16 -05:00
Ryan QIAN 46289bed0c tests: change the min_ram for mbedtls and mem_protect
- Change the min_ram to 36K, since they can't be built on RT1015 which
has 32K ram.

Signed-off-by: Ryan QIAN <jianghao.qian@nxp.com>
2019-05-14 12:23:42 -05:00
Andrew Boie 9485172677 tests: stackprot: don't set main stack size
This test uses ztest anyway, the default should be fine
just like any other test running under ztest.

k_thread_create() uses a lot of stack, and the main
stack size is very small if ztest is enabled. Do it in
another ztest task instead.

We don't need to mess with the main thread's priority,
just have the alt thread run cooperatively.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-03 13:30:16 -07:00
Andrew Boie 5f0ee9d350 tests: timer_api: run in user mode
We didn't have any coverage of the timer APIs in user
mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-02 18:01:06 -07:00
Andrew Boie 1d4cc154b0 tests: pipe: fix error with optimization disabled
The various struct pipe_sequence were not located in memory
accessible to user mode. With optimization turned on, they
weren't in memory at all, but with code coverage enabled
the arrays were actually being read, resulting in memory
access failures from user mode.

Fix them by placing in ROM, they never get modified.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-02 07:22:37 -04:00
Daniel Leung a404bb76ee tests/kernel/device: extends test for code coverage
device_get_binding() compares pointers first before doing strcmp().
However, enabling coverage forces -O0 to disable any compiler
optimizations. There would be multiple copies of the same string,
and the code pathing doing pointer comparsion would not be tested
at all. So add this flag to merge string constants such that
the pointer comparison would be exercised.

This also adds a bad driver which fails initialization. This is
to make sure that execution path is covered.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-05-01 10:38:03 -04:00
Siddharth Chandrasekaran b070bbd888 tests: kernel: Exclude platforms stm32_min_dev_*
Exclude the two variants of smt32_min_dev (stm32_min_dev_black and
stm32_min_dev_blue) from kernel tests.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2019-04-26 03:34:45 -07:00
Ioannis Glaropoulos 01a2bebc83 tests: kernel: mem_protect: protection: fix test-case filter
The test is to run for boards that have memory protection
enabled; having MPU capabilities on the SoC level is not
sufficient (the user, or the board itself, might not enable
memory protection support). This commit applies that policy
to the mem_protect/protection test suite.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-04-23 13:04:22 -07:00
Daniel Leung 3fa90938fe tests/kernel/schedule_api: also test without time slicing
This extends the schedule_api test to cover situations when
time slicing is disabled.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-04-18 12:26:52 -04:00
Wentong Wu 8646a8e4f5 tests/kernel/mem_protect/stackprot: stack size adjust
revert commit 3e255e968 which is to adjust stack size
on qemu_x86 platform for coverage test, but break other
platform's CI test.

Fixes: #15379.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-04-12 10:06:43 -04:00
Wentong Wu 22c9646b97 tests: adjust stack size for mps2_an385's coverage test
for SDK 0.10.0, it consumes more stack size when coverage
enabled, so adjust stack size to fix stack overflow issue.

Fixes: #15206.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-04-11 17:59:39 -04:00
Wentong Wu 3e255e968a tests: adjust stack size for qemu_x86's coverage test
for SDK 0.10.0, it consumes more stack size when coverage
enabled, so adjust stack size to fix stack overflow issue.

Fixes: #15206.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-04-11 17:59:39 -04:00
Ioannis Glaropoulos e2969e5de0 tests: kernel: fp_sharing: minor fix in #ifdef expression
We need to use the ARMV7_M_ARMV8_M_FP Kconfig symbol,
which denotes the Floating-Point capabilities, instead
of the option that signifies the Cortex-M variant. Fix
is of minor importance, as long as the #ifdef block
remains empty.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-04-10 10:59:46 -04:00
Andrew Boie 7387b56c61 tests: add nsim special cases for two tests
The NSIM emulator has severe performance issues when
the MPU registers are reprogrammed on context switch.
Disable runtime reprogramming of the MPU for these
platforms on these two tests, which have a lot of context
switch thrashing. This is done by ensuring userspace
and hardware stack overflow detection via guard areas
is disabled.

I have assurances from the ARC team that the tests run fine
on real hardware and this is an emulation issue.

For 1.15, this will be completely resolved by optimizing
MPU region gap-filling to not take place during context
switch time, which will drastically reduce the number of
MPU registers poked during context switch on nsim_sem.

Meanwhile, for 1.14 we ensure that no runtime reprogramming
of the MPU is done for these tests.

Fixes: #14642

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-09 19:38:32 -04:00
Anas Nashif a520266e44 tests: remove unused defaults.tc
This file is not used and was originally added to support TCF hardware
testing. We use harness now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 10:26:27 -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
Andrew Boie 7b1ee5cf13 tests: CONFIG_TEST_USERSPACE now off by default
Unlike CONFIG_HW_STACK_PROTECTION, which greatly helps
expose stack overflows in test code, activating
userspace without putting threads in user mode is of
very limited value.

Now CONFIG_TEST_USERSPACE is off by default. Any test
which puts threads in user mode will need to set
CONFIG_TEST_USERSPACE.

This should greatly increase sanitycheck build times
as there is non-trivial build time overhead to
enabling this feature. This also allows some tests
which failed the build on RAM-constrained platforms
to compile properly.

tests/drivers/build_all is a special case; it doesn't
put threads in user mode, but we want to ensure all
the syscall handlers compile properly.

Fixes: #15103 (and probably others)

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie 027b6aaf89 tests: set userspace tag for all tests that use it
This lets us quickly filter tests that exercise userspace
when developing it.

Some tests had a whitelist with qemu_cortex_m3; change
this to mps2_an385, which is the QEMU target with an
MPU enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie ad71c2fc44 tests: poll: reduce memory usage
We can re-use thread/stack objects between cases, no
need to have separate ones.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Anas Nashif ed139948a5 license: add missing licences to source code
Add missing license to source code files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-05 23:45:51 -04:00
Andrew Boie 4e5c093e66 kernel: demote K_THREAD_STACK_BUFFER() to private
This macro is slated for complete removal, as it's not possible
on arches with an MPU stack guard to know the true buffer bounds
without also knowing the runtime state of its associated thread.

As removing this completely would be invasive to where we are
in the 1.14 release, demote to a private kernel Z_ API instead.
The current way that the macro is being used internally will
not cause any undue harm, we just don't want any external code
depending on it.

The final work to remove this (and overhaul stack specification in
general) will take place in 1.15 in the context of #14269

Fixes: #14766

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-05 16:10:02 -04:00
Wentong Wu b991962a2e tests: adjust stack size for qemu_x86 and mps2_an385's coverage test
for SDK 0.10.0, it consumes more stack size when coverage enabled
on qemu_x86 and mps2_an385 platform, adjust stack size for most of
the test cases, otherwise there will be stack overflow.

Fixes: #14500.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-04-04 08:23:13 -04:00
Wentong Wu 1214736be5 tests: disable kernel.sched.preempt and kernel.poll on nrf52810_pca10040
on platform nrf52810_pca10040, the remaining sram space is not enough
to build test cases kernel.sched.preempt and kernel.poll, temporary
exclude nrf52810_pca10040 on that two cases, will open them when issue
is fixed.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-04-04 08:23:13 -04:00
Patrik Flykt 7c0a245d32 arch: Rename reserved function names
Rename reserved function names in arch/ subdirectory. The Python
script gen_priv_stacks.py was updated to follow the 'z_' prefix
naming.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-03 17:31:00 -04:00
Patrik Flykt 97b3bd11a7 drivers: Rename reserved function names
Rename reserved function names in drivers/ subdirectory. Update
function macros concatenatenating function names with '##'. As
there is a conflict between the existing gpio_sch_manage_callback()
and _gpio_sch_manage_callback() names, leave the latter unmodified.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-03 17:31:00 -04:00
Andrew Boie 14db4eedff tests: userspace: check stack buffer access
The stack information stored in the thread->stack_info
fields need to represent the actual writable area for
its associated thread. Perform various tests to ensure
that the various reported and specified values are in
agreement.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-03 13:48:20 -04:00
Andrew Boie c8aee7b413 sys_mem_pool: use sys_mutex
Permission management no longer necessary, the former
parameter for the mutex is now simply ignored.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-03 13:47:45 -04:00
Andrew Boie f8b6276780 tests: repurpose one of the mutex tests
We have two redundant mutex tests. Repurpose one
of them to excerise sys_mutex instead.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-03 13:47:45 -04:00
Andrew Boie 468c47bb83 tests: thread_apis: fix failure on ARC
This test is only trying to prove that k_thread_foreach() works,
it has nothing to do with stacks. Remove the stack checks
completely.

Fixes: #15044

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-02 20:11:19 -04:00
Flavio Ceolin 96659ac83b tests: fp_sharing: Fix build error
k_disable_float is only available in X86 when LAZY_FP_SHARING is
set. Adding this condition before using this function.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-04-02 11:31:22 -04:00
Andrew Boie dea4394ef4 tests: fatal: fix sentinel timer IRQ checking
Tickless kernel is now always disabled, ensuring that when
the kernel's tick count changes, we really did get a timer
interrupt.

The test now awaits a change in tick count instead of busy
waiting for an arbitrary time period.

Fixes: #15013

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-03-29 22:13:40 -04:00
Patrik Flykt 21358baa72 all: Update unsigend 'U' suffix due to multiplication
As the multiplication rule is updated, new unsigned suffixes
are added in the code.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Anas Nashif 006b97de13 tests: no-multithreading: do not report success twice
We are reporting success twice, once by calling macro directly, and once
by using ztest test_main().

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-03-26 20:09:07 -04:00
Wayne Ren 6b5bed6aa9 arch: arc: fix the handling of stack check exception
stack check exception may come out with other protection
vilation, e.g. MPU read/write. So the possible paramter
will be 0x02 | [0x4 | 0x8].

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2019-03-26 14:34:39 -04:00
Piotr Mienkowski a3082e49a1 power: modify HAS_STATE_SLEEP_ Kconfig options
Add SYS_POWER_ prefix to HAS_STATE_SLEEP_, HAS_STATE_DEEP_SLEEP_
options to align them with names of power states they control.
Following is a detailed list of string replacements used:
s/HAS_STATE_SLEEP_(\d)/HAS_SYS_POWER_STATE_SLEEP_$1/
s/HAS_STATE_DEEP_SLEEP_(\d)/HAS_SYS_POWER_STATE_DEEP_SLEEP_$1/

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-03-26 13:27:55 -04:00
Piotr Mienkowski 17b08ceca5 power: clean up system power managment function names
This commit cleans up names of system power management functions by
assuring that:
- all functions start with 'sys_pm_' prefix
- API functions which should not be exposed to the user start with '_'
- name of the function hints at its purpose

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-03-26 13:27:55 -04:00
Piotr Mienkowski 204311d004 power: rename Low Power States to Sleep States
There exists SoCs, e.g. STM32L4, where one of the low power modes
reduces CPU frequency and supply voltage but does not stop the CPU. Such
power modes are currently not supported by Zephyr.

To facilitate adding support for such class of power modes in the future
and to ensure the naming convention makes it clear that the currently
supported power modes stop the CPU this commit renames Low Power States
to Slep States and updates the documentation.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-03-26 13:27:55 -04:00
Flavio Ceolin f1741dab6c tests: mbox: Check k_mbox_get return
Coverity was complaining that this function was not being checked only
in a specific case.

Coverity CID: 183066

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-03-23 20:13:12 -04:00
Andy Ross 61065b3235 tests: samples: Re-enable SMP on a few tests
The 14 individual cases that use these four config files are now
passing reliably when SMP is enabled, after the "Mark sleeping threads
suspended" scheduler fix.  Turn it back on.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-23 19:28:15 -04:00
Andy Ross 09fdd814df tests/kernel/smp: Give time for a wakeup to take effect
For obvious performance reasons, scheduler state changes (other than
aborting a thread) do not cause synchronous interrupts on the other
CPU.  Doing a k_thread_wakeup() means that the current CPU will run it
synchronously if it's high priority, but if you want to see it run on
the other cores you need to wait for them to reach a scheduling point
on their own.

The test was written to assume that k_thread_wakeup() is synchronous,
but that's not right, and it needs to spin a bit.  This bug was always
present in the test, but masked by a bug in the way that k_sleep() was
handled on SMP.  See #9506.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-23 19:28:15 -04:00
Andy Ross 4f04f6486d tests: More SMP disablement
A few more test cases that are measurably unreliable when run in SMP.
For the most part these work most of the time (though the semaphore
one was pretty borderline -- I measured about 25% failures), but are
measurably unstable against the backdrop of known qemu instability.
Something is clearly going on and we need to come back to these to fix
threadsafety issues.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-20 11:33:29 -05:00
Daniel Leung 91eb147452 tests: kernel/smp: whitelist qemu_x86_64 for testing
Add qemu_x86_64 to the platform whitelist so that this will actually
be built and tested with sanitycheck.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-03-18 17:57:54 -04:00
Daniel Leung 96ccb913e4 tests: kernel/smp: fixed missing 'z_' renaming
There was a missing 'z_' renaming to
z_is_thread_prevented_from_running which would have caused
sanitycheck to fail but it is not being built at the moment.
Fix this first.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-03-18 17:57:54 -04:00
Andrew Boie b3eb510f5c kernel: fix atomic ops in user mode on some arches
Most CPUs have instructions like LOCK, LDREX/STREX, etc which
allows for atomic operations without locking interrupts that
can be invoked from user mode without complication. They typically
use compiler builtin atomic operations, or custom assembly
to implement them.

However, some CPUs may lack these kinds of instructions, such
as Cortex-M0 or some ARC. They use these C-based atomic
operation implementations instead. Unfortunately these require
grabbing a spinlock to ensure proper concurrency with other
threads and ISRs. Hence, they will trigger an exception when
called from user mode.

For these platforms, which support user mode but not atomic
operation instructions, the atomic API has been exposed as
system calls.

Some of the implementations in atomic_c.c which can be instead
expressed in terms of other atomic operations have been removed.

The kernel test of atomic operations now runs in user mode to
prove that this works.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-03-18 09:18:00 -04:00
Andy Ross 5a56ee5605 tests/kernel/fifo/fifo_usage: Disable SMP
This test isn't SMP-safe and won't pass reliably on x86_64 by default
(though it does pass often enough to get CI passes on most things, it
fails spuriously in ways that aren't timing related).  Turn off the
second CPU.  Fixes #14501

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-15 19:42:59 +01:00
Andy Ross c4e2f1b217 tests/kernel/mem_pool/mem_pool_threadsafe: Reduce tick rate
Qemu just can't handle 1000 Hz ticks.  On our CI machines, CONFIG_HZ
on the host (which is the limit of timing precision for things like
idle wakeups and signal delivery, both of which qemu seems to use for
timing) is 250.  When the mismatch gets this large, we start seeing
artifacts like interrupts being delivered "in the past" (i.e. code
sees a z_clock_elapsed() value of "2" ticks before getting a
z_clock_announce() call for "1").

As it happens, this test doesn't actually require timing with that
precision, it just wants "lots of context switching" to exercise the
threadsafety of the mem_pool APIs.  So decrease the tick rate to the
100Hz default, but put a loop counter in the worker threads to force
them to do 10x more work, keeping the number of preemptions constant.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-15 05:50:43 +01:00
Ramakrishna Pallala e1639b5345 device: Extend device_set_power_state API to support async requests
The existing device_set_power_state() API works only in synchronous
mode and this is not desirable for devices(ex: Gyro) which take
longer time (few 100 mSec) to suspend/resume.

To support async mode, a new callback argument is added to the API.
The device drivers can asynchronously suspend/resume and call the
callback function upon completion of the async request.

This commit adds the missing callback parameter to all the drivers
to make it compliant with the new API.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2019-03-14 14:26:15 +01:00
Kumar Gala 6ef55b0942 tests: kernel: context: Fix build issue with RV32M1_LPTMR_TIMER
We needed to add support for the RV32M1_LPTMR_TIMER to the test so its
knows what the IRQ of the timer is.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-03-13 17:02:05 -05:00
Andy Ross 05c1263ebd tests/kernel/smp: Clean up "guess waiting" on SMP thread exit
The various tests would all do a "wait for threads to exit" step
before checking the results, but this was implemented with a simple
busy wait that turns out to need careful tuning (because there was
busy waiting in the threads).

Rather than try to synchronize this, white box the issue (it's a low
level SMP test, after all) by spinning on the thread states directly
watching for the kernel to flag them dead.  The downside here is that
if the process fails for some reason we'll get a hang and a timeout
reported from sanitycheck and not a synchronous ztest assertion.  But
in return, successful tests run much faster and I don't need to worry
about how to tune them for IPI latency on different platforms.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross 829f6639da tests/kernel/smp: Remove test_wakeup_pending_threads case
This case was predicated on a mistake.  The behavior of k_wakeup() has
always been NOT to wake up threads that are "pending" on a wait queue,
only ones blocked on a timeout in k_sleep().  As written, this test
case could never pass.

(Really there's no good reason for that.  It seems reasonable to me to
expect wakeup to work symmetrically, and the docs are sort of
ambiguous on the subject.  But the code in k_wakeup() is clear:
threads flagged pending get an early exit and the call becomes a
noop.)

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Andy Ross 5697dd7980 tests/kernel/smp: Honor TEST_EXTRA_STACKSIZE
There was a test-created thread that wasn't including this.  It's a
huge stack and doesn't overflow (though I thought briefly that it
was), but it's a rule that we need to have that buffer and I'm trying
to fix these as I find them.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01: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
Charles E. Youse 78b98ae895 tests/xip: exclude Minnowboard from test (does not do XIP)
Minnowboard should not run the XIP test as it doesn't execute-in-place.
Updated the test specification to exclude Minnowboard.

Fixes #14099.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-03-07 20:31:31 -05:00
Arnaud Pouliquen 97f4265c12 tests: fix compilation error for printk
Fix multiple definitions of `ram_console'. The ram_console
array is already defined in drivers/console/ram_console.c.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2019-03-06 18:15:06 -05:00
Maksim Masalski b324f35e61 macros: deleted macros SECONDS(), MSEC(), USEC()
Changed everywhere these macros to the K_MSEC(), K_SECONDS()

Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
2019-03-04 19:04:21 -05:00
Piotr Zierhoffer 8642be070c m2gl025_miv: Ignore lifo_usage tests
These tests fail on hardware. An appropriate issue will be filed on
GitHub, but it doesn't make sense to hold the CI from going green.

Fixes #13960.

Signed-off-by: Piotr Zierhoffer <pzierhoffer@antmicro.com>
2019-03-04 12:39:09 -05:00
Andrew Boie 8207801c9b tests: userspace: remove unused partition
No data was ever being put in part2.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-03-04 08:05:16 -08:00
Andrew Boie 92da519d45 tests: userspace: add some more scenarios
We want to show that performing various memory domain
operations, and then either dropping to user mode, or
swapping to a user thread in the same domain, has the
correct memory policy for the user context.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-03-03 23:44:13 -05:00
Charles E. Youse d51ee67cbe tests/timer_api: revert testcase configuration
My test tag 'flarp' got through in the last commit.  Removed.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-03-01 14:53:33 -08:00
Charles E. Youse fbf4c7eea0 tests/timer_api: revert testcase configuration
Removing the build_only option for tickless broke CI (for reasons
unrelated to the new tests I added in the prior commit).

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-03-01 14:53:33 -08:00
Charles E. Youse 0ad4022e51 kernel/timeout: fix k_timer_remaining_get() when tickless
In some circumstances (e.g., a tickless kernel), k_timer_remaining_get()
would not account for time passed that didn't involve clock interrupts.
This adds a simple fix for that, and adds a test case.  In addition, the
return value of k_timer_remaining_get() is clamped at 0 in the case of
overdue timers and the API description is adjusted to reflect this.

Fixes: #13353

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-03-01 14:53:33 -08:00
Andy Ross f085928ab0 tests/kernel/fifo/fifo_timeout: Tick alignment for oversensitive timing
This test was written to wait on a fifo with a timeout, return, and
check the timing between the start and end using k_cycle_get_32() to
see that it didn't run long.  But timeouts expire on tick boundaries,
and so if tick expires between the start of the test and the entry to
k_fifo_get(), the timeout will take one full tick longer than expected
due to aliasing.

As it happened this passed everywhere except nRF (whose cycle timer is
32 kHz and thus more susceptible to coarser aliasing like this), and
even there it passed for a while until the spinlock validation layer
went in and added just enough time to the userspace code paths
(i.e. the code between the start time fetch and the point where the
fifo blocks takes longer) to open the window and push us over the
limit.

The workaround here is just to add a k_sleep(1) call, which is
guaranteed to block and wake up synchronously at the next tick.

Fixes #13289

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-01 19:45:39 +01:00
Andy Ross fc3ca95ba7 tests: Mass SMP disablement on non-SMP-safe tests
(Chunk 2 of 3 - this patch was split across pull requests to address
CI build time limitations)

Zephyr has always been a uniprocessor system, and its kernel tests are
rife with assumptions and outright dependence on single-CPU operation
(for example: "low priority threads will never run until this high
priority thread blocks" -- not true if there's another processor to
run it!)

About 1/3 of our tests fail right now on x86_64 when dual processor
operation is made default.  Most of those can probably be recovered on
a case-by-case basis with simple changes (and a few of them might
represent real bugs in SMP!), but for now let's make sure the full
test suite passes by turning the second CPU off.  There's still plenty
of SMP coverage in the remaining cases.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-28 12:47:12 -08:00
Ioannis Glaropoulos ca3b6c680f tests: kernel: fatal: remove #ifdefs for ARM platforms
This commit removes the #ifdefs for ARM platforms in
tests/kernel/fatal/main.c, as all the tests suite can be
executed for platforms supporting the ARM and the NXP MPU.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-02-28 11:57:25 -08:00
Andy Ross 3f4aa6316c tests/kernel/sched/schedule_api: Restore spinning for timer alignment
Commit 0cc362f873 ("tests/kernel: Simplify timer spinning") was
added to work around a qemu bug with dropped interrupts on x86_64.
But it turns out that the tick alignment that the original
implementation provided (fundamentally, it spins waiting on the timer
driver to report tick changes) was needed for correct operation on
nRF52.

The effectively revert that commit (and refactors all the spinning
into a single utility) and replaces it with a workaround targeted to
qemu on x86_64 only.  Fixes #11721

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-28 13:06:48 -06:00
Andy Ross a334ac2045 tests: Mass SMP disablement on non-SMP-safe tests
(Chunk 1 of 3 - this patch was split across pull requests to address
CI build time limitations)

Zephyr has always been a uniprocessor system, and its kernel tests are
rife with assumptions and outright dependence on single-CPU operation
(for example: "low priority threads will never run until this high
priority thread blocks" -- not true if there's another processor to
run it!)

About 1/3 of our tests fail right now on x86_64 when dual processor
operation is made default.  Most of those can probably be recovered on
a case-by-case basis with simple changes (and a few of them might
represent real bugs in SMP!), but for now let's make sure the full
test suite passes by turning the second CPU off.  There's still plenty
of SMP coverage in the remaining cases.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-28 13:02:20 -06:00
Andy Ross fe04adf99b lib/os: Conditionally eliminate alloca/VLA usage
MISRA rules (see #9892) forbid alloca() and family, even though those
features can be valuable performance and memory size optimizations
useful to Zephyr.

Introduce a MISRA_SANE kconfig, which when true enables a gcc error
condition whenever a variable length array is used.

When enabled, the mempool code will use a theoretical-maximum array
size on the stack instead of one tailored to the current pool
configuration.

The rbtree code will do similarly, but because the theoretical maximum
is quite a bit larger (236 bytes on 32 bit platforms) the array is
placed into struct rbtree instead so it can live in static data (and
also so I don't have to go and retune all the test stack sizes!).
Current code only uses at most two of these (one in the scheduler when
SCHED_SCALABLE is selected, and one for dynamic kernel objects when
USERSPACE and DYNAMIC_OBJECTS are set).

This tunable is false by default, but is selected in a single test (a
subcase of tests/kernel/common) for coverage.  Note that the I2C and
SPI subsystems contain uncorrected VLAs, so a few platforms need to be
blacklisted with a filter.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-28 10:06:35 -08:00
Ioannis Glaropoulos 7926cf24b6 tests: kernel: arm_irq_vector_table: extend the test for nRF9160
This commit extends the arm_irq_vector_table test,
so it can run successfully in nRF9160-based platforms.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-02-28 18:17:03 +01:00
Ioannis Glaropoulos 1e74007606 tests: kernel: arm_irq_vector_table: add clock ISR in the IRQ vector
This commit adds the Clock Control Interrupt Service
Routine into the customized vector table, when building
for nRF52X-based platforms. As a result, the interrupts
generated by the clock control will not interfere with
the test.

Fixes #13823.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-02-28 18:17:03 +01:00
Ioannis Glaropoulos 3dc81a40bc tests: kernel: arm_irq_vector_table: minor typo and style fixes
Minor typo and style fixes in the test logging, stressing
that the test is applicable for Cortex-M MCUs, in general.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-02-28 18:17:03 +01:00
Ioannis Glaropoulos bc902954e4 tests: kernel: arm_irq_vector_table: refactor custom IRQ settings
In order to make this test easy to extend for additional
Cortex-M-based platforms, we apply the following minor
refactoring to the test:
- we introduce the _ISR_OFFSET macro to denote the offset
  inside the interrupts' vector table (starting from IRQ
  line 0) of the first manually installed ISR.
- we move the asserts that ensure the validity of the custom
  vector table to build-time and place them in the beginning
  of the text, outside source code.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-02-28 18:17:03 +01:00
Andy Ross a4614372f9 tests: Mass SMP disablement on non-SMP-safe tests
(Chunk 3 of 3 - this patch was split across pull requests to address
CI build time limitations)

Zephyr has always been a uniprocessor system, and its kernel tests are
rife with assumptions and outright dependence on single-CPU operation
(for example: "low priority threads will never run until this high
priority thread blocks" -- not true if there's another processor to
run it!)

About 1/3 of our tests fail right now on x86_64 when dual processor
operation is made default.  Most of those can probably be recovered on
a case-by-case basis with simple changes (and a few of them might
represent real bugs in SMP!), but for now let's make sure the full
test suite passes by turning the second CPU off.  There's still plenty
of SMP coverage in the remaining cases.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-27 14:22:06 -08:00
Cinly Ooi 2810b88971 tests: Enable kernel.device tests for qemu_x86_64
Reworked platform_whitelist to enable the "test kernel.device" for
qemu_x86_64

kernel.device.pm is not yet enabled for qemu_x86_64 because
there is a link error

   undefined symbol `_DEVICE_STRUCT_SIZEOF'
   referenced in expression

Signed-off-by: Cinly Ooi <cinly.ooi@intel.com>
2019-02-26 22:55:40 -08:00
Andrew Boie feab37096b libc: fix CONFIG_STDOUT_CONSOLE semantics
The intent of this Kconfig is to allow libc stdout
functions like printf() to send their output to the
active console driver instead of discarding it.

This somehow evolved into preferring to use
printf() instead of printk() for all test case output
if enabled. Libc printf() implementation for both
minimal libc and newlib use considerably more stack
space than printk(), with nothing gained by using
them.

Remove all instances where we are conditionally
sending test case output based on this config, enable
it by default, and adjust a few tests that disabled
this because they were blowing stack.

printk() and vprintk() now work as expected for
unit_testing targets, they are just wrappers for
host printf().

Fixes: #13701

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-26 08:00:33 -06:00
Piotr Mienkowski f04a4c9deb power: rename CPU_LPS_n power states
CPU_LPS_n name used to indicate a low power state is cryptic and
incorrect. The low power states act on the whole SoC and not exclusively
on the CPU. This patch renames CPU_LPS_n states to LOW_POWER_n. Also
HAS_ pattern for Kconfig options is used in favor of a non standard
_SUPPORTED. Naming of deep sleep states was adjusted accordingly.

Following is a detailed list of string replacements used:
s/SYS_POWER_STATE_CPU_LPS_(\d)_SUPPORTED/HAS_STATE_LOW_POWER_$1/
s/SYS_POWER_STATE_CPU_LPS_(\d)/SYS_POWER_STATE_LOW_POWER_$1/
s/SYS_POWER_STATE_DEEP_SLEEP_(\d)_SUPPORTED/HAS_STATE_DEEP_SLEEP_$1/

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-02-26 02:30:13 +01:00
Piotr Mienkowski c75187587b power: simplify SYS_POWER_*_SUPPORTED Kconfig options
This commit removes dependency on SYS_POWER_LOW_POWER_STATES_SUPPORTED,
SYS_POWER_DEEP_SLEEP_STATES_SUPPORTED Kconfig options. Power management
SYS_POWER_LOW_POWER_STATES, SYS_POWER_DEEP_SLEEP_STATES options depend
now directly on specific power states supported by the given SoC. This
simplifies maintenance of SoC Kconfig files.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-02-26 02:30:13 +01:00
Andrew Boie 4ce652e4b2 userspace: remove APP_SHARED_MEM Kconfig
This is an integral part of userspace and cannot be used
on its own. Fold into the main userspace configuration.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-23 07:43:55 -05:00
Anas Nashif e88752f5fe tests: stacks: increase STACK_LEN to 4
Test was failing on nios2 with:

../app/libapp.a(test_stack_contexts.c.obj): in function `tstack_pop':
/home/galak/git/zephyr/tests/kernel/stack/stack_api/src/test_stack_contexts.c:31:
warning: unable to reach (null) (at 0x004002f4) from the global pointer
(at 0x004082fc) because the offset (-32776) is out of the allowed range,
-32678 to 32767

Fixes #13595

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-22 23:10:22 -05:00
Andrew Boie 45631c30ca tests: stackprot: run in user mode
Ensure that stack canaries work properly in user mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-22 18:50:43 -05:00
Ioannis Glaropoulos 67aee1f1f6 tests: kernel: userspace: fix test for non-secure builds
This commit fixes a test in kernel/mem_protect/userspace,
which was attempting to read from an address that was not
necessarily within the image memory range, causing faults
in ARM TrustZone-enabled builds.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-02-22 12:32:26 -06:00
Piotr Zięcik 81c1d37c89 test: kernel: device.pm: Do not enable system-level PM. It is not used.
This commit disables system-level power management in the device power
management test as it is not used.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-19 13:25:36 -05:00
Piotr Zięcik 63b0df645e power: Clean up power state names
Some of power states used numerical suffix while otthers not.
This commit adds proper suffix to all power state names.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>

f
2019-02-19 13:25:36 -05:00
Piotr Zięcik c45961daae power: Rework OS <-> Application interface
This commit simplifies OS <-> Application interface controlling power
management. In the previous approach application-based PM required
overriding sys_suspend() and sys_resume() functions. As these functions
actually implemented power state change, in such case application
basically had to provide own implementation of all PM-related stuff,
which was not portable and hard to maintain.

This commit changes this scheme: The sys_suspend() and sys_resume()
are now system functions while the application could either use
built-in power management policies or provide its own. All details
of power mode switching are now handled by the OS.

Also, this commit cleans up the Kconfig options related to system-level
power management grouping them under common CONFIG_SYS_PM_ prefix.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-19 13:25:36 -05:00
Andrew Boie 4ae33f0b55 tests: fatal: refactor and add user mode tests
We weren't testing whether stack overflows in user mode
were correctly reported.

A more aggressive stack overflow logic is enabled if
HW-based stack overflow detection is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-15 09:48:37 -05:00
Andrew Boie 2cfeba8507 x86: implement interrupt stack trampoline
Upon hard/soft irq or exception entry/exit, handle transitions
off or onto the trampoline stack, which is the only stack that
can be used on the kernel side when the shadow page table
is active. We swap page tables when on this stack.

Adjustments to page tables are now as follows:

- Any adjustments for stack memory access now are always done
  to the user page tables

- Any adjustments for memory domains are now always done to
  the user page tables

- With KPTI, resetting a page now clears the present bit

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-14 12:46:36 -05:00
Andrew Boie f093285345 x86: modify MMU APIs for multiple page tables
Current set of APIs and macros assumed that only one set
of page tables would ever be in use.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-14 12:46:36 -05:00
Kumar Gala 1f59e9e825 tests: kernel: gen_isr_table: Exclude platforms test isnt valid on
The test assumes that the last to IRQ number will be free, this isn't a
valid assumption and now that we detect multiple ISRs registering for
the some IRQ line, we see failures because of this assumption on some
platforms.  Exclude those platforms from this test for the time being.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-12 15:35:29 -05:00
Piotr Zięcik 7a49356c77 power: Fix naming of Kconfig options controlling low power states
The SYS_POWER_LOW_POWER_STATE_SUPPORTED and SYS_POWER_LOW_POWER_STATE
suggests one low power state but these options control multiple
low power state. This commit uses plural in the names to indicate
that.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-12 07:46:32 -05:00
Andy Ross d653e6868e tests/kernel/schedule_api: Bump stack size and unify stacks
The new spinlock validation features combined with spinlockification
have increased stack usage a bit in CONFIG_ASSERT builds, but this is
a good feature we want to keep.  This test was bumping into limits, so
increase the size from 512 to 640 bytes.

Unfortunately, this is also a huge test that creates a LOT of those
stacks across different test cases, so that minor bump blows us past
the 64k SRAM limit on a bunch of boards.  So unify all those stacks
that are only ever used in one case at a time so the memory can be
shared.  Now there's one fixed stack, named "tstack", and one array
"tstacks".  Much smaller.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-08 14:49:39 -05:00
Andy Ross 1bf9bd04b1 kernel: Add _unlocked() variant to context switch primitives
These functions, for good design reason, take a locking key to
atomically release along with the context swtich.  But there's still a
common pattern in code to do a switch unconditionally by passing
irq_lock() directly.  On SMP that's a little hurtful as it spams the
global lock.  Provide an _unlocked() variant for
_Swap/_reschedule/_pend_curr for simplicity and efficiency.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-08 14:49:39 -05:00
Andy Ross aa6e21c24c kernel: Split _Swap() API into irqlock and spinlock variants
We want a _Swap() variant that can atomically release/restore a
spinlock state in addition to the legacy irqlock.  The function as it
was is now named "_Swap_irqlock()", while _Swap() now refers to a
spinlock and takes two arguments.  The former will be going away once
existing users (not that many!  Swap() is an internal API, and the
long port away from legacy irqlocking is going to be happening mostly
in drivers) are ported to spinlocks.

Obviously on uniprocessor setups, these produce identical code.  But
SMP requires that the correct API be used to maintain the global lock.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-08 14:49:39 -05:00
Piotr Zięcik d02e3ebd4c power: Eliminate SYS_PM_* power states.
The power management framework used two different abstractions
to describe power states. The SYS_PM_* given coarse information
what kind of power state (low power or deep sleep) was used,
while the SYS_POWER_STATE_* abstraction provided information
about particular power mode.

This commit removes the SYS_PM_* abstraction as the same
information is already carried in SYS_POWER_STATE_*.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-08 09:07:00 -05:00
Andrew Boie 41f6011c36 userspace: remove APPLICATION_MEMORY feature
This was never a long-term solution, more of a gross hack
to get test cases working until we could figure out a good
end-to-end solution for memory domains that generated
appropriate linker sections. Now that we have this with
the app shared memory feature, and have converted all tests
to remove it, delete this feature.

To date all userspace APIs have been tagged as 'experimental'
which sidesteps deprecation policies.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-08 07:04:30 -05:00
Andrew Boie 525065dd8b tests: convert to use app shared memory
CONFIG_APPLICATION_MEMORY was a stopgap feature that is
being removed from the kernel. Convert tests and samples
to use the application shared memory feature instead,
in most cases using the domain set up by ztest.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-08 07:04:30 -05:00
Andrew Boie 84c808918b tests: set CONFIG_MAX_THREAD_BYTES for a few tests
Some tests instantiate a lot of thread objects. These
were not tagged with __kernel, and
CONFIG_APPLICATION_MEMORY was enabled, so the kernel was
not adding them to the kernel object database.

However, with CONFIG_APPLICATION_MEMORY disabled, this
overflowed the default max number of thread objects (16).
Increase the max to 32 for these particular tests.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-08 07:04:30 -05:00
Andrew Boie 62a6f87139 tests: remove app_memory test
CONFIG_APPLICATION_MEMORY is being removed from
Zephyr.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-08 07:04:30 -05:00
Andrew Boie 889b2377ef tests: userspace: remove extra_sections
This is unnecessary.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-08 07:04:30 -05:00
Andrew Boie 8bfd8457ea tests: mem_protect: fix Kconfig
We want CONFIG_APPLICATION_MEMORY specifically disabled
for this test, but it was being transitively selected by
CONFIG_TEST_USERSPACE which defaults to on for CONFIG_TEST.

Turn it off so that disabling application memory in the
config actually has an effect.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-08 07:04:30 -05:00
Kumar Gala 5ef93aa639 tests: kernel: interrupt: Exclude platforms test isnt valid on
The test assumes that the last to IRQ numbers will be free, this isn't a
valid assumption and now that we detect multiple ISRs registering for
the some IRQ line, we see failures because of this assumption on some
platforms.  Exclude those platforms from this test for the time being.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-07 15:58:43 -05:00
Anas Nashif 177df596d3 tests: irq_offload: remove irq_offload test
This is now part of kernel/common.
Forgot to remove it in d0bcf27eab

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-06 10:10:42 -05:00
Andrew Boie 2d9bbdf5f3 x86: remove support for non-PAE page tables
PAE tables introduce the NX bit which is very desirable
from a security perspetive, back in 1995.

PAE tables are larger, but we are not targeting x86 memory
protection for RAM constrained devices.

Remove the old style 32-bit tables to make the x86 port
easier to maintain.

Renamed some verbosely named data structures, and fixed
incorrect number of entries for the page directory
pointer table.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-05 20:51:21 -08:00
Anas Nashif d0bcf27eab tests: common: move irq_offload test to common
This is a small test that can be easily integrated into the common set
of tests we have already.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-05 20:40:07 -05:00
Anas Nashif d35f1150f3 tests: common: move boot_delay test to common
This is a small test that can be easily integrated into the common set
of tests we have already.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-05 20:40:07 -05:00
Anas Nashif 3f27247617 tests: common: move errno test to common
This is a small test that can be easily integrated into the common set
of tests we have already.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-05 20:40:07 -05:00
Ioannis Glaropoulos 2782a00a00 tests: kernel: interrupt: group IRQ line number selection together
This commit moves the definition of IRQ_LINE(..) macro from
interrupt.h into nested_irq.c, and adds some inline comments
documenting the use of it.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-02-04 20:50:59 -05:00
Andy Ross 54dd1a3cf1 tests/threads/thread_apis: Add test for CPU mask API
Very simple test for thread CPU masks.  While this is a SMP feature,
the implementation doesn't actually depend on SMP so we can test it
right here in the thread_apis test.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-01 21:37:24 -05:00
Andy Ross eda4c027da misc/dlist: Swap insertion API for a faster one
The sys_dlist_insert_*() functions had a behavior where a NULL
argument for the insertion position to sys_dlist_insert_after/before()
was interpreted as "the end of the list".  We never used that
convention (except in one spot internal to dlist.h which was not
itself used anywhere), and of course already have an API for appending
and prepending to a list.

In practice this was a performance disaster.  The NULL check is
virtually never provable statically by the compiler, so that test and
branch is present always.  And worse, the check and call to another
function was pushing this beyond the complexity limit for gcc to
inline a function (at -Os optimization anyway), forcing us to use
function calls for what should be a ~8 instruction sequence.  The
upshot is that dlist insertions were 2-3x slower than they needed to
be.

Deprecate these older APIs and introduce a new sys_dlist_insert() call
which can be much better optimized.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-01 15:57:21 -05:00
Anas Nashif a93651085e boards: remove pulpino board
This board is unmaintained and unsupported. It is not known to work and
has lots of conditional code across the tree that makes code
unmaintainable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-31 22:47:18 -05:00
Andrew Boie c253a686bf app_shmem: auto-initialize partitions
There are no longer per-partition initialization functions.
Instead, we iterate over all of them at boot to set up the
derived k_mem_partitions properly.

Some ARC-specific hacks that should never have been applied
have been removed from the userspace test.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-01-30 23:15:51 -05:00
Andrew Boie 85e1fcb02a app_shmem: renamespace and document
The public APIs for application shared memory are now
properly documented and conform to zephyr naming
conventions.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-01-30 15:43:58 -08:00
Andrew Boie f278f31da1 app_shmem: delete parallel API for domains
The app shared memory macros for declaring domains provide
no value, despite the stated intentions.

Just declare memory domains using the standard APIs for it.

To support this, symbols declared for app shared memory
partitions now are struct k_mem_partition, which can be
passed to the k_mem_domain APIs as normal, instead of the
app_region structs which are of no interest to the end
user.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-01-29 11:11:49 -08:00
Johan Hedberg e405fc41f2 atomic: Add atomic_set_bit_to() API
Several places in the code have constructions like this:

	if (bool_variable) {
		atomic_set_bit(flags, FLAG);
	} else {
		atomic_clear_bit(flags, FLAG);
	}

To reduce the amount of code for such situations, introduce a new
atomic_set_bit_to() helper which lets you condense the above five
lines to a single one:

	atomic_set_bit_to(flags, FLAG, bool_variable);

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-01-25 17:35:44 -05:00
Peter A. Bigot d40b8ce1fb sys: dlist: Add sys_dnode_is_linked
The original implementation allows a list to be corrupted by list
operations on the removed node.  Existing code attempts to avoid this by
using external state to determine whether a node is in a list, but this
is fragile and fails when the state that holds the flag value is changed
after the node is removed, e.g. in preparation for re-using the node.

Follow Linux in invalidating the link pointers in a removed node.  Add
API so that detection of particpation in a list is available at the node
abstraction.

This solution relies on the following steady-state invariants:
* A node (as opposed to a list) will never be adjacent to itself in a
  list;
* The next and prev pointers of a node are always either both null or
  both non-null.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-01-23 20:46:49 +01:00
Andrzej Głąbek 37fbff6179 drivers: nrf: Adjust clock_control and timer drivers for nRF9160
Minor adjustments are done to the nRF clock_control and rtc_timer
drivers to make them usable on nRF9160 as well.
The arm_irq_vector_table test code is modified only because it uses
the function that has been renamed in the nrf_rtc_timer driver.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-01-21 10:13:34 +01:00
Andrew Boie 970758408b printk: don't print incorrect 64-bit integers
printk is supposed to be very lean, but should at least not
print garbage values. Now when a 64-bit integral value is
passed in to be printed, 'ERR' will be reported if it doesn't
fit in 32-bits instead of truncating it.

The printk documentation was slightly out of date, this has been
updated.

Fixes: #7179

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-01-18 08:23:15 -08:00
Andrew Boie dfeed647f5 printk: fix printing 64-bit hex values
These were being truncated to 32-bits, and only 8
hex digits were supported.

An extraneous printk() at the beginning of the test
which was not being tested in any way has been removed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-01-17 14:59:03 -06:00
Peter A. Bigot bfad9721d2 kernel: remove k_alert API
This API was used in only one place in non-test code.  See whether we
can remove it.

Closes #12232

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-01-16 21:34:07 -05:00
Adithya Baglody 25572f3b85 tests: Dont run coverage for select test cases.
Disabled the CONFIG_COVERAGE for benchmarks and other tests.
This is needed because it interferes with normal behavior of the
test case.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-16 06:12:33 -05:00
Adithya Baglody 516bf34df5 tests: Increase the stack size by CONFIG_TEST_EXTRA_STACKSIZE.
These tests need to use stack size as a function of
CONFIG_TEST_EXTRA_STACKSIZE. These test will fail when
CONFIG_COVERAGE is enabled.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2019-01-16 06:12:33 -05:00
Andy Ross f033d542ad tests: samples: Disable newlib tests on x86_64
This builds with a host compiler, not one from the SDK, and so no
newlib library is available.  There is work to enable newlib detection
at and above the cmake level.  This patch can be reverted when that
lands.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Andy Ross 0cc362f873 tests/kernel: Simplify timer spinning
There is actually nothing wrong with this test code idiom.  But it's
tickling a qemu emulator bug with the hpet driver and x86_64[1].  The
rapidly spinning calls to k_uptime_get_32() need to disable
interrupts, read timer hardware state and enable them.  Something goes
wrong in qemu with this process and the timer interrupt gets lost.
The counter blows right past the comparator without delivering its
interrupt, and thus the interrupt won't be delivered until the counter
is next reset in idle after exit from the busy loop, which is
obviously too late to interrupt the timeslicing thread.

Just replace the loops with a single call to k_busy_wait().  The
resulting code ends up being much simpler anyway.  An added bonus is
that we can remove the special case handling for native_posix (which
was an entirely unrelated thing, but with a similar symptom).

[1] But oddly not the same emulated hardware running with the same
driver under the same qemu binary when used with a 32 bit kernel.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Andy Ross 870e8188a8 tests/kernel/sched/schedule_api: Honor TEST_EXTRA_STACKSIZE
Stacks created by tests should add this amount so thread-hungry
architectures can tune it.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Andy Ross 31e79a791e tests/kernel/mem_protect/stackprot: Whitelist x86_64
This architecture doesn't support stack canaries.  In fact the gcc
-fstack-protect features don't seem to be working at all.  I'm
guessing it's an x32 ABI mismatch?

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Andy Ross b69d0da82d arch/x86_64: New architecture added
This patch adds a x86_64 architecture and qemu_x86_64 board to Zephyr.
Only the basic architecture support needed to run 64 bit code is
added; no drivers are added, though a low-level console exists and is
wired to printk().

The support is built on top of a "X86 underkernel" layer, which can be
built in isolation as a unit test on a Linux host.

Limitations:

+ Right now the SDK lacks an x86_64 toolchain.  The build will fall
  back to a host toolchain if it finds no cross compiler defined,
  which is tested to work on gcc 8.2.1 right now.

+ No x87/SSE/AVX usage is allowed.  This is a stronger limitation than
  other architectures where the instructions work from one thread even
  if the context switch code doesn't support it.  We are passing
  -no-sse to prevent gcc from automatically generating SSE
  instructions for non-floating-point purposes, which has the side
  effect of changing the ABI.  Future work to handle the FPU registers
  will need to be combined with an "application" ABI distinct from the
  kernel one (or just to require USERSPACE).

+ Paging is enabled (it has to be in long mode), but is a 1:1 mapping
  of all memory.  No MMU/USERSPACE support yet.

+ We are building with -mno-red-zone for stack size reasons, but this
  is a valuable optimization.  Enabling it requires automatic stack
  switching, which requires a TSS, which means it has to happen after
  MMU support.

+ The OS runs in 64 bit mode, but for compatibility reasons is
  compiled to the 32 bit "X32" ABI.  So while the full 64 bit
  registers and instruction set are available, C pointers are 32 bits
  long and Zephyr is constrained to run in the bottom 4G of memory.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Andy Ross 0f075753b8 tests/kernel/threads/thread_apis: Fix include hygine
These files were relying on _thread_essential_set() from
kernel_internal.h, but not including it directly.  New architectures
won't transitively include things the same way.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Adithya Baglody 4c1667fbfa tests: Updated all the tests which use k_thread_access_grant.
With the new implementation we do not need a NULL terminated list
of kobjects. Therefore the list will only contain valid entries
of kobjects.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2019-01-03 12:35:14 -08:00
Andy Ross b748d5219a tests/kernel/timer_api: Synchronize racy subtest
The test_timer_periodicity test is racy and subject to initial state
bugs.  The operation of that test is to:

1. Start a timer with a known period
2. Take the current time with k_uptime_get()
3. Wait for the timer to fire with k_timer_status_sync()
4. Check that the current time minus start time is the period

But that's wrong, because a tick expiring between any of the first
three steps is going to skew the math (i.e. the timer will have
started on a different tick than the "start time").

And taking an interrupt lock around the process can't fix the issue,
because in the tickless world we live in k_uptime_get() is actually a
realtime quanity based on a hardware counter and doesn't rely on
interrupt delivery.

Instead, use another timer object to synchronize the test start to a
driver tick, ensuring that even if the race is unfixable the initial
conditions are always correct.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-03 12:29:02 -05:00
Anas Nashif 5060ca6a30 cmake: increase minimal required version to 3.13.1
Move to latest cmake version with many bug fixes and enhancements.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-01-03 11:51:29 -05:00
Anas Nashif 74a74bb6b8 power: rename api sys_soc -> sys_
sys_soc is just redundant, just call APIs with sys_*.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-12-28 16:16:28 -05:00
Anas Nashif 9151fbebf2 power: rename APIs and removing leading _
Remove leading underscore from PM APIs. _ was used for internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-12-28 16:16:28 -05:00
Spoorthi K e62e54bdcd tests: interrupt: Change IRQ priorities in test
Keeping IRQ0 priority as 1 and IRQ1 priority as 0
so that system timer which of priority 0 in ARC
will be interrupted by IRQ1 of same priority.
In ARM, system timer is of priority 1, hence
making ISR0 priority as 2 and ISR1 priority as 1.
Thus system timer will always be interrupted by
ISR1 in both the architectures.

Fixes: #12147

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-12-21 21:04:36 +01:00
Spoorthi K 82f73bd5e3 tests: nested_irq: Fix k_busy_wait usage and interrupt priority
k_busy_wait() call used in test expects time in us, but the test
is specifying wait in ms.

Also the test fails on NRF5 platform as the test hardcodes the
interrupts priority to 0 and 1 and assumes system timer to be of
priority 0 which is not the case in NRF5 platforms as per
@pizi-nordic where system timer is at priority 1. Hence changing
test interrupts to 1 and 2.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-12-11 13:36:52 -05:00
Andrew Boie 5f793cc25c tests: mem_pool_api: reduce stack usage
Some arches were getting a stack overflow in ISR context.

Fixes: #9777

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-12-07 20:09:47 -05:00
Ioannis Glaropoulos e8e5c388b4 test: kernel: userspace: add include for arm core mpu
In the wake of dfa7a354ff2a31fea8614b3876b051aadc30b242, where
the inclusions for MPU APIs were clean-up, we need to directly
include arm_core_mpu_dev.h in the userspace test suite, which
invokes arm_core_mpu_enable/disable(), directly. The same is
already done for ARC MPU.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-12-05 15:15:07 -05:00
Patrik Flykt 440b535602 tests: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Andrew Boie 2b1d54e897 kernel: add user mode work_q capability
This allows for workqueues to be started in user mode.
No additional kernel objects or system calls are defined
other than starting the workqueue in user mode; for
permission purposes the embedded queue and thread objects
are sufficient.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-11-29 09:21:18 -08:00
Andrew Boie 3ced428f2f tests: don't enable application memory
This shouldn't be enabled unless the test case is
specifically testing the feature.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-11-28 15:33:11 -08:00
Piotr Mienkowski 970aef2905 kernel: ensure System Power Managment enables Tickless Idle.
System Power Management is only supported in Tickless Idle mode.
This patch modifies Kconfig dependencies to ensure System Power
Management option selects Tickless Idle one.

Fixes: #11046

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2018-11-21 23:16:35 -05:00
Andrew Boie 3aa59a6eed tests: test dynamic IRQ APIs
The gen_isr_table test now tries to install two dynamic
IRQ handlers.

RISCV32 has a workaround due to limited number of SW
triggerable interrupts that can be configured.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-11-20 09:30:34 -05:00
Spoorthi K 06fa2e6764 tests: msgq: Modify test to verify k_msgq_peek
Verify k_msgq_peek() API functionality by
modifying existing test suite.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-11-19 22:43:04 -05:00
Andy Ross 39b2a09f38 drivers/timer: New xtensa timer with tickless support
Rewritten Xtensa CCOUNT driver along the lines of all the other new
drivers.  The new API permits much smaller code.

Notably: The Xtensa counter is a 32 bit up-counter with a comparator
register.  It's in some sense the archetype of this kind of timer as
it's the simplest of the bunch (everything else has quirks: NRF is
very slow and 24 bit, HPET has a runtime frequency detection, RISC-V
is 64 bit...).  I should have written this one first.

Note also that this includes a blacklist of the xtensa architecture on
the tests/driver/ipm test.  I'm getting spurious failures there where
a k_sem_take() call with a non-zero timeout is being made out of the
console output code in interrupt context.  This seems to have nothing
to do with the timer; I suspect it's because the old timer drivers
would (incorrectly!) call z_clock_announce() in non-interrupt context
in some contexts (e.g. "expiring really soon").  Apparently this test
(or something in the IPM or Xtensa console code) was somehow relying
on that on Xtensa.  But IPM is a Quark thing and there's no particular
reason to run this test there.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-11-13 17:10:07 -05:00
Andy Ross ea35343eb1 tests/kernel/interrupt: Shrink very long k_busy_wait() argument
This test was written with an outrageously long timeout of 25 seconds.
That blows right through the 32 bit cycle counter on qemu_cortex_m3[1]
and produces an essentially random delay instead of the desired
number, causing a hang with the new SysTick driver in tickless mode.

Push the number down so it doesn't overflow.  The root cause, though,
is that k_busy_wait() can take arguments it can't handle.  It ought to
have an outer loop or something so that it can spin for INT_MAX
milliseconds correctly.

[1] Which has a 12MHz clock rate.  Many hardware implementations are
much faster still.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-11-13 17:10:07 -05:00
Andy Ross 4b305e1a25 tests/kernel/context: Limit no-tick-during-irq-load to !TICKLESS
When TICKLESS_KERNEL is enabled, the current time in ticks is based on
a hardware counter and not interrupt delivery (which is the whole
point of tickless), so irq-locking does not prevent time from
advancing.  Disable this test in that configuration.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-11-13 17:10:07 -05:00
Andy Ross 0f444c84e5 drivers/timer: Add a standard workaround for known qemu issues
Qemu doesn't like tickless.  By default[1] it tries to be realtime as
vied by the host CPU -- presenting read values from hardware cycle
counters and interrupt timings at the appropriate real world clock
times according to whatever the simulated counter frequency is.  But
when the host system is loaded, there is always the problem that the
qemu process might not see physical CPU time for large chunks of time
(i.e. a host OS scheduling quantum -- generally about the same size as
guest ticks!) leading to lost cycles.

When those timer interrupts are delivered by the emulated hardware at
fixed frequencies without software intervention, that's not so bad:
the work the guest has to do after the interrupt generally happens
synchronously (because the qemu process has just started running) and
nothing notices the dropout.

But with tickless, the interrupts need to be explicitly programmed by
guest software!  That means the driver needs to be sure it's going to
get some real CPU time within some small fraction of a Zephyr tick of
the right time, otherwise the computations get wonky.

The end result is that qemu tends to work with tickless well on an
unloaded/idle run, but not in situations (like sanitycheck) where it
needs to content with other processes for host CPU.

So, add a flag that drivers can use to "fake" tickless behavior when
run under qemu (only), and enable it (only!) for the small handful of
tests that are having trouble.

[1] There is an -icount feature to implement proper cycle counting at
the expense of real-world-time correspondence.  Maybe someday we might
get it to work for us.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-11-13 17:10:07 -05:00
Alberto Escolar Piedras f1da7abc75 tests: kernel: context: Bugfix for POSIX arch in TICKLESS
In the POSIX architecture, with the inf_clock "SOC", time does
not pass while the CPU is running. Tests that require time to pass
while busy waiting should call k_busy_wait() or in some other way
set the CPU to idle. This test was setting the CPU to idle while
waiting for the next time slice. This is ok if the system tick
(timer) is active and awaking the CPU every system tick period.
But when configured in tickless mode that is not the case, and the
CPU was set to sleep for an indefinite amount of time.
This commit fixes it by using k_busy_wait(a few microseconds) inside
that busy wait loop instead.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-11-13 09:19:03 -05:00
Alberto Escolar Piedras 0682a51686 tests: kernel: sched: Bugfix for POSIX arch in TICKLESS
In the POSIX architecture, with the inf_clock "SOC", time does
not pass while the CPU is running. Tests that require time to pass
while busy waiting should call k_busy_wait() or in some other way
set the CPU to idle. This test was setting the CPU to idle while
waiting for the next time slice. This is ok if the system tick
(timer) is active and awaking the CPU every system tick period.
But when configured in tickless mode that is not the case, and the
CPU was set to sleep for an indefinite amount of time.
This commit fixes it by using k_busy_wait(a few microseconds) inside
that busy wait loop instead.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-11-13 09:19:03 -05:00
Alberto Escolar Piedras 018073b359 tests: kernel: tickless: Bugfix for POSIX arch in TICKLESS
In the POSIX architecture, with the inf_clock "SOC", time does
not pass while the CPU is running. Tests that require time to pass
while busy waiting should call k_busy_wait() or in some other way
set the CPU to idle. This test was setting the CPU to idle while
waiting for the next time slice. This is ok if the system tick
(timer) is active and awaking the CPU every system tick period.
But when configured in tickless mode that is not the case, and the
CPU was set to sleep for an indefinite amount of time.
This commit fixes it by using k_busy_wait(a few microseconds) inside
that busy wait loop instead.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-11-13 09:19:03 -05:00
Alberto Escolar Piedras 74e9ee967a tests: kernel: common: Bugfix for POSIX arch in TICKLESS
In the POSIX architecture, with the inf_clock "SOC", time does
not pass while the CPU is running. Tests that require time to pass
while busy waiting should call k_busy_wait() or in some other way
set the CPU to idle. This test was setting the CPU to idle while
waiting for the next time slice. This is ok if the system tick
(timer) is active and awaking the CPU every system tick period.
But when configured in tickless mode that is not the case, and the
CPU was set to sleep for an indefinite amount of time.
This commit fixes it by using k_busy_wait(a few microseconds) inside
that busy wait loop instead.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-11-13 09:19:03 -05:00
Alberto Escolar Piedras bdc0a20f4e tests: sched: schedule_api: Bugfix for POSIX arch in TICKLESS
In the POSIX architecture, with the inf_clock "SOC", time does
not pass while the CPU is running. Tests that require time to pass
while busy waiting should call k_busy_wait() or in some other way
set the CPU to idle. This test was setting the CPU to idle while
waiting for the next time slice. This is ok if the system tick
(timer) is active and awaking the CPU every system tick period.
But when configured in tickless mode that is not the case, and the
CPU was set to sleep for an indefinite amount of time.
This commit fixes it by using k_busy_wait(a few microseconds) inside
that busy wait loop instead.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-11-13 09:19:03 -05:00
Niranjhana N 6316d774f2 tests: kernel: test force suspend of device
Add test for the force suspend of device by
setting state to device_set_power_state API.

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2018-11-10 13:50:42 -05:00
Ioannis Glaropoulos ff5d942db8 tests: kernel: userspace: minor typo fixes
Some minor style and typo fixes in
tests/kernel/mem_protect/userspace/src/main.c.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-11-06 16:14:41 -05:00
Flavio Ceolin aecd4ecb8d kernel: Change k_poll_signal api
k_poll_signal was being used by both, struct and function. Besides
this being extremely error prone it is also a MISRA-C violation.
Changing the function to contain a verb, since it performs an action
and the struct will be a noun. This pattern must be formalized and
followed and across the project.

MISRA-C rules 5.7 and 5.9

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-11-04 11:37:24 -05:00
Flavio Ceolin a406b88fca kernel: Remove duplicated identifier
There was an struct and a variable called _kernel. This is error prone
and a MISRA-C violation. It is changing the struct to have a unique
identifier.

MISRA-C rule 5.8

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-11-04 11:37:24 -05:00
Kumar Gala 9db7175e67 tests: Remove board.h include
We either don't need board.h in the test or we should be include soc.h
instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-01 13:15:18 +01:00
Alberto Escolar Piedras 847b7ccbcc tests: kernel tickless: Bugfix for POSIX arch in TICKLESS
In the POSIX architecture, with the inf_clock "SOC", time does
not pass while the CPU is running. Tests that require time to pass
while busy waiting should call k_busy_wait() or in some other way
set the CPU to idle. This test was setting the CPU to idle while
waiting for the next time slice. This is ok if the system tick
(timer) is active and awaking the CPU every system tick period.
But when configured in tickless mode that is not the case, and the
CPU was set to sleep for an indefinite amount of time.
This commit fixes it by using k_busy_wait(a few microseconds) inside
that busy wait loop instead.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-10-31 19:43:10 -04:00
Alberto Escolar Piedras 574fc953e2 tests: sleep: Bugfix for POSIX arch in TICKLESS
In the POSIX architecture, with the inf_clock "SOC", time does
not pass while the CPU is running. Tests that require time to pass
while busy waiting should call k_busy_wait() or in some other way
set the CPU to idle. This test was setting the CPU to idle while
waiting for the next time slice. This is ok if the system tick
(timer) is active and awaking the CPU every system tick period.
But when configured in tickless mode that is not the case, and the
CPU was set to sleep for an indefinite amount of time.
This commit fixes it by using k_busy_wait(a few microseconds) inside
that busy wait loop instead.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-10-31 19:43:10 -04:00
Alberto Escolar Piedras a57ddef003 tests: sched: schedule_api: Bugfix for POSIX arch in TICKLESS
In the POSIX architecture, with the inf_clock "SOC", time does
not pass while the CPU is running. Tests that require time to pass
while busy waiting should call k_busy_wait() or in some other way
set the CPU to idle. This test was setting the CPU to idle while
waiting for the next time slice. This is ok if the system tick
(timer) is active and awaking the CPU every system tick period.
But when configured in tickless mode that is not the case, and the
CPU was set to sleep for an indefinite amount of time.
This commit fixes it by using k_busy_wait(a few microseconds) inside
that busy wait loop instead.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-10-31 19:43:10 -04:00
Spoorthi K a94f97b4b3 tests: kernel: Validate set thread name to current thread
Enhance test to validate a scenario where k_thread_name_set()
    with NULL as thread ID should set thread name to current
    thread.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-10-29 10:17:10 -04:00
Adithya Baglody 24b89f12eb tests: sched: schedule_api: Increase the minimum ram needed.
This test was failing on nrf52810_pca10040 due to lack of RAM.
It was a side effect of increasing the privilege stack size.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-10-28 11:43:32 -04: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
Anas Nashif d3ed3f11fa tests: interrupt: disable riscv32
This is a new test and we have riscv32 failing on that all of the
sudden. Disabling while we look into it and identify if that is a
testcase issue or not.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-16 21:27:23 -04:00
Andy Ross a715a5fc57 tests/kernel/context: Skip test_kernel_cpu_idle when tickless
This test was written to assume that on idle the CPU would wake up on
the next tick boundary because of the timer interrupt.  No such
interrupt arrives in tickless mode and it hangs forever.

A more whiteboxy test involving setting a clock timout will have to be
written for this feature if we want to keep it on tickless systems.
Alternatively we could move this test out of tests/kernel/context and
always disable tickless.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-10-16 15:03:10 -04:00
Andy Ross 4f02dd1407 tests/kernel/context: Disable test_kernel_interrupts when tickless
The theory behind this test seems to be that taking an IRQ lock should
prevent the advance of the kernel's tick counter.  That works on
traditional timers only.  In tickless mode the timer hardware/driver
is expected to be able to give us an answer for time independent of
interrupt delivery, so the test fails spuriously.  The "bug" detected
is a feature of tickless!

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-10-16 15:03:10 -04:00
Andy Ross cfe62038d2 kernel: Checkpatch fixups
I was pretty careful, but these snuck in.  Most of them are due to
overbroad string replacements in comments.  The pull request is very
large, and I'm too lazy to find exactly where to back-merge all of
these.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-10-16 15:03:10 -04:00
Andy Ross af7bf89ed2 tests/kernel: Bump stack size for mem_protect/stackprot
This test needs just a tiny bit of extra stack.  512 bytes isn't
enough on x86 with the most recent set of timer patches.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-10-16 15:03:10 -04:00
Andy Ross 7aae75bd1c idle: Fix tickless timeout behavior
If the idle code was detecting that it needed to sleep for less than
CONFIG_SYS_TICKLESS_IDLE_THRESH, then it would never call
z_clock_set_timeout() at all, which means that the system would never
wake up unless it already had a timeout scheduled!  Apparently we
lacked a test case to detect this condition.

Honestly this seems like a crazy feature to me.  There's no benefit in
delivering needless tick announcements.  If the system has the
capacity to enter deeper sleep for long timeouts, that's already
exposed via the PM APIs, the timer subsystem needn't be involved.
But... we actually have a test (tickless_concept) that looks at this,
so support it for now and consider deprecation later.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-10-16 15:03:10 -04:00
Andy Ross 317178b88f sys_clock: Fix unsafe tick count usage
The system tick count is a 64 bit quantity that gets updated from
interrupt context, meaning that it's dangerously non-atomic and has to
be locked.  The core kernel clock code did this right.

But the value was also exposed to the rest of the universe as a global
variable, and virtually nothing else was doing this correctly.  Even
in the timer ISRs themselves, the interrupts may be themselves
preempted (most of our architectures support nested interrupts) by
code that wants to set timeouts and inspect system uptime.

Define a z_tick_{get,set}() API, eliminate the old variable, and make
sure everyone uses the right mechanism.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-10-16 15:03:10 -04:00
Andy Ross b2e4283555 sys_clock: Make sys_clock_hw_cycles_per_tick() a proper API
This was another "global variable" API.  Give it function syntax too.
Also add a warning, because on nRF devices (at least) the cycle clock
runs in kHz and is too slow to give a precise answer here.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-10-16 15:03:10 -04:00
Andy Ross 220d4f8347 sys_clock.h: Make "global variable" APIs into proper functions
The existing API defined sys_clock_{hw_cycles,ticks}_per_sec as simple
"variables" to be shared, except that they were only real storage in
certain modes (the HPET driver, basically) and everywhere else they
were a build constant.

Properly, these should be an API defined by the timer driver (who
controls those rates) and consumed by the clock subsystem.  So give
them function syntax as a stepping stone to get there.

Note that this also removes the deprecated variable
_sys_clock_us_per_tick rather than give it the same treatment.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-10-16 15:03:10 -04:00
Anas Nashif 621f75bfa7 tests: remove bat_commit, replace core with kernel
bat_commit is an old and obsolete tag that has not been maintained over
time and was supposed to serve a purpose that is obsolete now. Also
rename core tag with kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-16 09:17:51 -04:00
Anas Nashif 91cdb35584 tests: fatal: fix condition for NXP MPU
Fixed condition and wrong Kconfig name, shoud be CONFIG_CPU_HAS_NXP_MPU
instead of only CPU_HAS_NXP_MPU.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-15 09:07:43 -04:00
Ajay Kishore 2a103ea674 tests: add tests to validate interrupt nesting feature
This test is intended to verify the interrupt nesting.
Interrupt nesting feature allows an ISR to be preempted
in mid-execution if a higher priority interrupt is signaled.
The lower priority ISR resumes execution once the higher
priority ISR has completed its processing.

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-10-10 19:59:47 -04:00
Ulf Magnusson 92ef8582b9 Kconfig: Remove redundant $(ZEPHYR_BASE) from 'source's
The $srctree environment variable gives the path relative to which
'(o)source' statements work (the current directory is used if $srctree
is unset). It is set to $ZEPHYR_BASE in cmake/kconfig.cmake, so there's
no need to qualify the source of Kconfig.zephyr in sample Kconfig files
(or in external projects).

All 'source's in Zephyr assume that the Zephyr root directory is used as
the srctree as well, and would break otherwise.

Remove the $(ZEPHYR_BASE)s to make it clearer that all 'source'
statements work relative to the Zephyr root. There was some user
confusion on IRC.

Also explain how things work in the documentation.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-10 11:28:27 -05:00
Ioannis Glaropoulos 52b729a6a4 arch: arm: fix mem domain sample/test for ARMv8-M access permissions
This commit updates the mem_domain_apis_test sample and the
mem_protect test, so they can compile and execute in ARMv8-M
platforms, which do not support the P_RW_U_RO access permissions
combination (privileged read/write, unprivileged read-only). The
modification consists of, simply, selecting a different access
permission (P_RO_U_RO) when building for ARMv8-M MPUs with the
unmodified ARM MPU architecture.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-10-09 19:33:24 -04:00
Anas Nashif 0a0c8c831f kernel: move to new logger
Use the new logger framework for kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-08 17:49:12 -04:00
Rajavardhan Gundi fa77e400aa tests/kernel: fifo_timeout: Remove wake-up order checking
There is no guarantee of wake-up order when multiple threads
are woken up on the same tick. Hence, modified the tests
accordingly.

Fixes #8159.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-10-02 14:06:50 -07:00
Mark Ruvald Pedersen d67096da05 portability: Avoid void* arithmetics which is a GNU extension
Under GNU C, sizeof(void) = 1. This commit merely makes it explicit u8.

Pointer arithmetics over void types is:
 * A GNU C extension
 * Not supported by Clang
 * Illegal across all ISO C standards

See also: https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-09-28 07:57:28 +05:30
Anas Nashif f6e7e98909 tests: test k_thread_name_set
Basic test for new API: k_thread_name_set.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-09-27 08:58:55 +05:30
Sebastian Bøe 72e7bfa680 cmake: Remove unnecessary KCONFIG_ROOT configuration
It is no longer necessary to set the KCONFIG_ROOT variable when the
KConfig file is in the application root directory.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-21 13:37:21 -04:00
Ajay Kishore 22d653fd20 tests: sched: Use SCHED_MULTIQ for native posix platform
To improve the code coverage on native posix, adding CONFIG_SCHED_MULTIQ
for scheduler api tests.

Extracting a separate prj_native_posix.conf file for the scheduler test,
which validates the "multi queue" scheduler on native posix.

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-09-21 08:50:13 -04:00
Adithya Baglody 0e11792f4e tests: userspace: Incorrect location to the privileged stack.
The test case was supposed to access the privileged stack area
but instead it was accessing the stack guard region.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-09-20 20:35:25 -04:00
Adithya Baglody b19f3ec2ba tests: mem_protect: mem_protect: Update the stack size.
This patch updates the alignment for the memory domain partitions.
Also update the stack size for qemu_cortex_m3.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-09-20 20:35:25 -04:00
Adithya Baglody 44057a197f tests: kernel: pipe : Update the stack size.
Now the stack size is a function of CONFIG_TEST_EXTRA_STACKSIZE.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-09-20 20:35:25 -04:00
Adithya Baglody a8f2675604 tests: userspace: Update the required stack size for mps2_an385
Increasing the stack size to 1024.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-09-20 20:35:25 -04:00
Piotr Zięcik 1c16cfcc30 arch: arm: Make ARM_MPU the sole option controlling MPU usage
This commit removes all MPU-related (ARM_CORE_MPU and NXP_MPU)
options exept ARM_MPU, which becomes master switch controlling
MPU support on ARM.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2018-09-20 14:16:50 +02:00
Kumar Gala 05272d62b3 tests: mem_protect: syscalls: set CONFIG_USERSPACE in prj.conf
Set CONFIG_USERSPACE in the prj.conf to ensure its set, right now
getting CONFIG_USERSPACE depends on tests/Kconfig setting it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-09-18 17:03:57 -04:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Ajay Kishore 75780a8135 tests: pipe: Enhance tests to improve code coverage
This test is intended to validate k_pipe_alloc_init()
and k_pipe_cleanup(), when CONFIG_USERSPACE is not defined.
Also added test to validate pending reader and pending writer
feature in pipe.

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-09-14 09:06:31 -04:00
Ulf Magnusson d713033d5c Kconfig: Use new preprocessor syntax for env. variables
With the new Kconfig preprocessor (described in
https://github.com/torvalds/linux/blob/master/Documentation/kbuild/
kconfig-macro-language.txt), the syntax for expanding environment
variables is $(FOO) rather than $FOO.

$(FOO) is a general preprocessor variable expansion, which falls back to
environment variables if the variable isn't set (like in Make). It can
also be used in prompts, 'comment's, etc.

The old syntax will probably be supported forever in Kconfiglib for
backwards compatibility, but might as well make it consistent now that
people might start using the preprocessor more.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-09-11 19:17:25 -04:00
Andy Ross a7e5d2f02e tests/kernel/sched/deadline: Disable CONFIG_BT
The BT threads are interfering with the main thread priority selection
and the test fails semi-spuriously on NRF5x boards with "threads ran
too soon" (i.e. not an EDF failure per se, but the fact that the new
threads at K_LOWEST_APPLICATION_PRIO are running instead of the test
thread).  This is a reasonable workaround for testing the
SCHED_DEADLINE ordering behavior, though.

Fixes #9843

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-09-08 08:43:06 -04:00
Andy Ross 02aa980042 tests: Add kernel/sched/deadline test for EDF validation
Simple test for CONFIG_SCHED_DEADLINE.  It creates a bunch of threads
at randome deadlines but within the same priority, and validates that
they run in the correct order.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-09-06 14:26:22 -04:00
Anas Nashif c8402bc3ce tests: preempt: increase stack size for test
Failed with:

Running test suite suite_preempt
===================================================================
starting test - test_preempt
***** Stack Check Fail! *****
Current thread ID = 0x0040019c
eax: 0x00400254, ebx: 0x00400254, ecx: 0x004002b0, edx: 0x00000001
esi: 0x004001f8, edi: 0x00401080, ebp: 0x00408024, esp: 0x00408000
eflags: 0x00000046 cs: 0x0008
call trace:
eip: 0x00002115
     0x000021b8 (0x40019c)
     0x00002685 (0x4001f8)
     0x00004f65 (0x401120)
     0x00005187 (0x401120)
     0x000051c2 (0x40019c)
     0x000052be (0xffffffff)
     0x00005bab (0x246)
     0x000019c4 (0x400078)
Fatal fault in thread 0x0040019c! Aborting.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-08-31 11:14:39 -04:00
Anas Nashif af17c195b4 tests: syscalls: ignore faults, they are intentional
We are blowing up the kernel here intentionally, so ignore the faults on
some platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-08-30 15:05:30 -04:00
Andy Ross 2f95e2400f tests/kernel/threads/no-multithreading: Disable USERSPACE
Building with !MULTITHREADING is designed for bootloaders and similar
minimal-functionality use cases.  It's pathologically silly to combine
it with MMU drivers and address space partitioning, even though on
some architectures that technically works (on ARM, it seems not to).

The test intent was to disable this originally, but it turns out that
doesn't work.  There is a TEST_USERSPACE kconfig symbol that also
needs to be explicitly turned off, otherwise it will reselect
USERSPACE against our wishes.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-08-30 13:29:09 -04:00
Paul Sokolovsky 14742d79fe tests: k_poll: Add testcase to poll fifo which gets k_fifo_cancel_wait
In this case k_poll() returns -EINTR, while still fills in event
states.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-08-30 09:28:29 -04:00
Maureen Helm 3e41864e25 tests: gen_isr_table: Add barriers after triggering the irq
Fixes the gen_isr_table kernel test on mimxrt1050_evk by using data and
instruction synchronization barriers instead of disabling compiler
optimization on arm platforms. According to [1] section 4.5, "if a
pended interrupt request needs to be recognized immediately after being
enabled in the NVIC, add a DSB instruction and then an ISB instruction"

[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0321a/BIHJDAAE.html

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-08-29 18:48:42 -04:00
Daniel Leung 4a2ba0dd04 tests/kernel: pipes: add tests for smaller pipe buffers
This adds some test cases where the pipe buffer is smaller than
the size of data being pushed through the pipe.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2018-08-29 15:57:28 -04:00
Wayne Ren 3f2f6dda1a tests: a fix for ARC and MPU VER 3
For ARC MPU version 3, the defined partitions are not added to MPU
when appmem_init_app_memory is doning app_bss_zero().

So need to disable mpu first to allow appmem_init_app_memory to
access all partitions.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-08-28 13:57:50 -04:00
Anas Nashif d2b4d8f049 tests: thread_api: increase stack for test
Add more stack for this test, it was failing and hidden by sanitycheck
(which needs to be fixed somewhere else).

Fixes #9664

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-08-27 18:41:22 -04:00
Ajay Kishore f17b111e39 tests: kernel: init: Fix integer overflow issue
Cast the msec to nsec conversion macro with u64_t to fix the
integer overflow issue.

Fixes #9135

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-08-26 18:47:08 -07:00
Adithya Baglody 871cc3232f tests: kernel: sched: schedule_api: Increase stack size.
The stack size was way too less. Increasing the size to minimum
of 512 for all platforms.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-08-24 07:03:34 -07:00
Spoorthi K 2a72f500cb tests: smp: Modify test to verify thread delay
Improved test with thread delay and removed few prints.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-08-20 17:51:07 -07:00
Ajay Kishore 8c456f755d tests: mempool: Enhance tests to improve code coverage
Assisning system heap to the current thread.
And validate allocation and free memory from the same system
heap memory pool.

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-08-19 13:09:35 -07:00
Anas Nashif ce88792a6e tests: fp_sharing: use filter
use CONFIG_ARMV7_M_ARMV8_M_FP as filter instead of platform_whitelist.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-08-19 12:26:13 -07:00
Adithya Baglody f3e0566650 tests: kernel: fp_sharing: Added support for Cortex-M7
Added required macros to get the test case working with a
cortex-M7.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-08-19 12:26:13 -07:00
Ajay Kishore 47889cd12c tests: fatal: Add description and RTM links
Add doxygen groups, description and RTM links for
fatal test cases

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-08-17 06:18:21 -07:00
Flavio Ceolin 0866d18d03 irq: Fix irq_lock api usage
irq_lock returns an unsigned int, though, several places was using
signed int. This commit fix this behaviour.

In order to avoid this error happens again, a coccinelle script was
added and can be used to check violations.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-08-16 19:47:41 -07:00
Spoorthi K 1c721217df tests: smp: Additional tests to verify SMP functionality
Add tests to verify SMP functionality

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-08-16 15:48:40 -07:00
Praful Swarnakar 94acc18b3e coverage: tests: poll: Add test to validate multiple polling threads
Add testcase for validating poll events by manipultaing thread
state to improve code coverage. Also, add multiple threads to
wait on same event.

Signed-off-by: Praful Swarnakar <praful.swarnakar@intel.com>
2018-08-16 15:31:43 -07: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
Piotr Zięcik 5b3a7ed740 tests: kernel: Do not use exact time in timing checks.
This commit replaces exact time compassion by a range check, allowing
the tests to pass on platforms which needs rounding in __ticks_to_ms()
and _ms_to_ticks().

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2018-08-14 07:18:44 -07:00
Ajay Kishore 4cc2866358 tests: FIFO: Add description and RTM links
Add doxygen groups, description and RTM links for
FIFO test cases

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-08-13 12:35:10 -07:00
Ajay Kishore 648477c6ed tests: static_idt: Add description and RTM links
Add doxygen groups, description and RTM links for
static idt test cases

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-08-13 12:34:11 -07:00
Spoorthi K a54a887a70 tests: kernel: Add doxygen groups
Add doxygen groups for kernel test cases

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-08-13 07:02:21 -07:00
Spoorthi K db9f6a9094 tests: obj_tracing: Enhance object tracing test
Enhance object tracing test to improve code coverage
of kernel object initialization.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-08-13 06:39:01 -07:00
Praful Swarnakar 68bde79ee5 tests: kernel: device: Add RTM link, description and doxygen group
Add RTM links, description and doxygen group for device test cases.

Signed-off-by: Praful Swarnakar <praful.swarnakar@intel.com>
2018-08-10 04:06:42 -07:00
Ajay Kishore b3f4d6b057 tests: lifo: Add description and RTM links
Add doxygen groups, description and RTM links for
lifo test cases

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-08-10 04:03:59 -07:00
Ajay Kishore dec8b9e559 tests: msgq: Add description and RTM links
Add doxygen groups, description and RTM links for
msgq test cases

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-08-10 04:03:16 -07:00
Spoorthi K 234f48e1ef tests: userspace: Add description and doxygen links
Add description and doxygen links to userspace test cases

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-08-10 03:55:44 -07:00
Spoorthi K 6910f15fcf tests: protection: Add description and doxygen group
Add description and doxygen groups for protection
test cases

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-08-10 03:55:44 -07:00
Spoorthi K b32b39af05 tests: userspace: Remove extra call to same testcase
The test read_kobject_user_pipe() is called twice in
the test suite. There is no need of calling same test
twice. Removing the extra call.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-08-10 03:54:43 -07:00
Spoorthi K 0975663e3f tests: x86_mmu_api: Add description and doxygen groups
Add description, RTM links and doxygen groups for
x86_mmu_api test cases.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-08-10 03:53:57 -07:00
Spoorthi K 477219b2dc tests: syscall: Add description and RTM links
Add description, RTM links and doxygen groups for
syscall test cases

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-08-10 03:52:47 -07:00
Spoorthi K 4ae9dd5a7c tests: mp: Add description, RTM links and doxygen group
Add description, RTM links and doxygen group for
test cases in mp.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-08-10 03:51:35 -07:00
Daniel Leung b16b4e6e4b tests: kernel: add tests for dynamic threads
This adds two test cases to create dynamic threads, and one test
case to make sure permissions are set correctly.

Origin: Original

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2018-08-09 09:20:14 -07:00
Daniel Leung cd3e5b561d tests/kernel: kernel.queue.poll: fails if MAX_THREAD_BYTES > 2
The kernel.queue.poll test fails if CONFIG_MAX_THREAD_BYTES is larger
than 2, complaining about no memory for semaphore object. Turns out
the memory pool is not large enough. So make it a bit larger.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2018-08-09 09:20:14 -07:00
Spoorthi K 67d2ddc6ad tests: mem_protect: Add RTM links and description
Add doxygen groups, RTM links and description for
memory protection test cases

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-08-01 10:14:44 -07:00
Praful Swarnakar a51fb782d7 coverage: tests: poll: Add missing poll event to improve code coverage
Add testcase for validating K_POLL_TYPE_IGNORE poll event to
improve code coverage.

Signed-off-by: Praful Swarnakar <praful.swarnakar@intel.com>
2018-07-31 20:39:19 -04:00
Spoorthi K 0b76567ac3 tests: mem_protect: Add description and doxygen groups
Add descriptions and doxygen groups for app_memory,
    stack_protection, stack_randomization and
    obj_validation.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-31 11:56:49 -04:00
Andrew Boie cef0748687 userspace: add syscalls test case
Test that we can define our own system calls in application code
and that fault handling works properly.

Additional tests for base system call infrastructure, outside of
specific system calls, go here.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-07-31 07:47:15 -07:00
Spoorthi K 07a8c0cf84 tests: kernel: Add test to verify k_thread_user_mode_enter()
Test to verify k_thread_user_mode_enter() when usermode is
not enabled or supported by architecture. The thread which calls
k_thread_user_mode_enter() with CONFIG_USERSPACE disabled or
architecture doesn't support usermode, should be marked
as usermode and if it is essential, then it has to be cleared.
This is added to improve code coverage.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-30 14:20:09 -07:00
Praful Swarnakar d05bee87e2 tests: kernel: profiling: Add description and doxygen group
Add doxygen group, test description and RTM links for
Profiling test cases.

Signed-off-by: Praful Swarnakar <praful.swarnakar@intel.com>
2018-07-30 08:46:24 -04:00
Ajay Kishore dbc8789a19 tests: sched: Enhance tests to improve code coverage
call k_wakeup() if the timer has expired and the thread
is not even in the sleep state.

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-07-27 12:38:49 -04:00
Spoorthi K 55642afe4c tests: obj_tracing: Add obj_tracing tests for kernel objects
Add obj tracing test for all kernel objects to improve code
coverage.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-27 07:51:26 -04:00
Spoorthi K bb8cb5acf5 tests: pipe: Add description and RTM links
Add doxygen groups, description and RTM links for
pipe test cases

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-26 14:59:02 -04:00
Ramakrishna Pallala 00e29c176d tests: kernel: Move k_thread_foreach() API test to thread_apis test
Move k_thread_foreach() API test from tests/kernel/profiling to
tests/kernel/threads/thread_apis.

Fixes #7966

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-07-26 00:53:31 -04:00
Shawn Mosley 573f32b6d2 userspace: compartmentalized app memory organization
Summary: revised attempt at addressing issue 6290.  The
following provides an alternative to using
CONFIG_APPLICATION_MEMORY by compartmentalizing data into
Memory Domains.  Dependent on MPU limitations, supports
compartmentalized Memory Domains for 1...N logical
applications.  This is considered an initial attempt at
designing flexible compartmentalized Memory Domains for
multiple logical applications and, with the provided python
script and edited CMakeLists.txt, provides support for power
of 2 aligned MPU architectures.

Overview: The current patch uses qualifiers to group data into
subsections.  The qualifier usage allows for dynamic subsection
creation and affords the developer a large amount of flexibility
in the grouping, naming, and size of the resulting partitions and
domains that are built on these subsections. By additional macro
calls, functions are created that help calculate the size,
address, and permissions for the subsections and enable the
developer to control application data in specified partitions and
memory domains.

Background: Initial attempts focused on creating a single
section in the linker script that then contained internally
grouped variables/data to allow MPU/MMU alignment and protection.
This did not provide additional functionality beyond
CONFIG_APPLICATION_MEMORY as we were unable to reliably group
data or determine their grouping via exported linker symbols.
Thus, the resulting decision was made to dynamically create
subsections using the current qualifier method. An attempt to
group the data by object file was tested, but found that this
broke applications such as ztest where two object files are
created: ztest and main.  This also creates an issue of grouping
the two object files together in the same memory domain while
also allowing for compartmenting other data among threads.

Because it is not possible to know a) the name of the partition
and thus the symbol in the linker, b) the size of all the data
in the subsection, nor c) the overall number of partitions
created by the developer, it was not feasible to align the
subsections at compile time without using dynamically generated
linker script for MPU architectures requiring power of 2
alignment.

In order to provide support for MPU architectures that require a
power of 2 alignment, a python script is run at build prior to
when linker_priv_stacks.cmd is generated.  This script scans the
built object files for all possible partitions and the names given
to them. It then generates a linker file (app_smem.ld) that is
included in the main linker.ld file.  This app_smem.ld allows the
compiler and linker to then create each subsection and align to
the next power of 2.

Usage:
 - Requires: app_memory/app_memdomain.h .
 - _app_dmem(id) marks a variable to be placed into a data
section for memory partition id.
 - _app_bmem(id) marks a variable to be placed into a bss
section for memory partition id.
 - These are seen in the linker.map as "data_smem_id" and
"data_smem_idb".
 - To create a k_mem_partition, call the macro
app_mem_partition(part0) where "part0" is the name then used to
refer to that partition. This macro only creates a function and
necessary data structures for the later "initialization".
 - To create a memory domain for the partition, the macro
app_mem_domain(dom0) is called where "dom0" is the name then
used for the memory domain.
 - To initialize the partition (effectively adding the partition
to a linked list), init_part_part0() is called. This is followed
by init_app_memory(), which walks all partitions in the linked
list and calculates the sizes for each partition.
 - Once the partition is initialized, the domain can be
initialized with init_domain_dom0(part0) which initializes the
domain with partition part0.
 - After the domain has been initialized, the current thread
can be added using add_thread_dom0(k_current_get()).
 - The code used in ztests ans kernel/init has been added under
a conditional #ifdef to isolate the code from other tests.
The userspace test CMakeLists.txt file has commands to insert
the CONFIG_APP_SHARED_MEM definition into the required build
targets.
  Example:
        /* create partition at top of file outside functions */
        app_mem_partition(part0);
        /* create domain */
        app_mem_domain(dom0);
        _app_dmem(dom0) int var1;
        _app_bmem(dom0) static volatile int var2;

        int main()
        {
                init_part_part0();
                init_app_memory();
                init_domain_dom0(part0);
                add_thread_dom0(k_current_get());
                ...
        }

 - If multiple partitions are being created, a variadic
preprocessor macro can be used as provided in
app_macro_support.h:

        FOR_EACH(app_mem_partition, part0, part1, part2);

or, for multiple domains, similarly:

        FOR_EACH(app_mem_domain, dom0, dom1);

Similarly, the init_part_* can also be used in the macro:

        FOR_EACH(init_part, part0, part1, part2);

Testing:
 - This has been successfully tested on qemu_x86 and the
ARM frdm_k64f board.  It compiles and builds power of 2
aligned subsections for the linker script on the 96b_carbon
boards.  These power of 2 alignments have been checked by
hand and are viewable in the zephyr.map file that is
produced during build. However, due to a shortage of
available MPU regions on the 96b_carbon board, we are unable
to test this.
 - When run on the 96b_carbon board, the test suite will
enter execution, but each individaul test will fail due to
an MPU FAULT.  This is expected as the required number of
MPU regions exceeds the number allowed due to the static
allocation. As the MPU driver does not detect this issue,
the fault occurs because the data being accessed has been
placed outside the active MPU region.
 - This now compiles successfully for the ARC boards
em_starterkit_em7d and em_starterkit_em7d_v22. However,
as we lack ARC hardware to run this build on, we are unable
to test this build.

Current known issues:
1) While the script and edited CMakeLists.txt creates the
ability to align to the next power of 2, this does not
address the shortage of available MPU regions on certain
devices (e.g. 96b_carbon).  In testing the APB and PPB
regions were commented out.
2) checkpatch.pl lists several issues regarding the
following:
a) Complex macros. The FOR_EACH macros as defined in
app_macro_support.h are listed as complex macros needing
parentheses.  Adding parentheses breaks their
functionality, and we have otherwise been unable to
resolve the reported error.
b) __aligned() preferred. The _app_dmem_pad() and
_app_bmem_pad() macros give warnings that __aligned()
is preferred. Prior iterations had this implementation,
which resulted in errors due to "complex macros".
c) Trailing semicolon. The macro init_part(name) has
a trailing semicolon as the semicolon is needed for the
inlined macro call that is generated when this macro
expands.

Update: updated to alternative CONFIG_APPLCATION_MEMORY.
Added config option CONFIG_APP_SHARED_MEM to enable a new section
app_smem to contain the shared memory component.  This commit
seperates the Kconfig definition from the definition used for the
conditional code.  The change is in response to changes in the
way the build system treats definitions.  The python script used
to generate a linker script for app_smem was also midified to
simplify the alignment directives.  A default linker script
app_smem.ld was added to remove the conditional includes dependency
on CONFIG_APP_SHARED_MEM.  By addining the default linker script
the prebuild stages link properly prior to the python script running

Signed-off-by: Joshua Domagalski <jedomag@tycho.nsa.gov>
Signed-off-by: Shawn Mosley <smmosle@tycho.nsa.gov>
2018-07-25 12:02:01 -07:00
Ramakrishna Pallala d9d3a5adf8 tests: kernel: timer: Add a test case to cover k_timer_start
Added test to cover the case where the app can start the timer
even before the previous one is expired. In this case the timer
will start with latest settings or params.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-07-25 07:15:54 -04:00
Ajay Kishore 7b24690e14 tests: msgq: Enhance tests to improve code coverage
This test is intended to validate k_msgq_alloc_init()
and k_msgq_cleanup(), when CONFIG_USERSPACE is not defined.
Also added test to validate k_msgq_get() api, if any thread is
pending to write in message queue.

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-07-24 20:07:12 -04:00
Spoorthi K 7c8aa526cb tests: queue: Enhance tests to improve coverage
Modify test to cover k_queue_insert() and k_queue_alloc_prepend(),
       and allocation failure/success scenario.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-24 19:28:36 -04:00
Ajay Kishore cea73067ce tests: kernel: Add test to validate k_stack_alloc_init, k_stack_cleanup
This test is intended to validate k_stack_cleanup() and
k_stack_alloc_init(). Passed stack pointer in k_stack_alloc_init()
is statically defined.

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-07-24 15:28:31 -07:00
David B. Kinder 9af485adf8 doc: fix incorrect defgroup comment in Queue tests
defgroup was missing the group title parameter

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-07-24 16:24:28 -04:00
Spoorthi K 4c6b90e317 tests: queue: Add description and doxygen groups
Add description for queue tests and doxygen groups

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-24 11:54:41 -04:00
Spoorthi K cb499d3232 tests: stack: Add description for test cases
Add description for test cases and some uncrustify
changes

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-24 11:53:42 -04:00
Ajay Kishore 4238418eb2 tests: kernel: document gen_isr_table tests for RTM
Group interrupt test in doxygen.

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-07-20 10:26:39 -04:00
Ramakrishna Pallala 09a322ae21 tests: kernel: device: Set device power state
Set device state to DEVICE_PM_ACTIVE_STATE before making it busy.

Also improves the kernel/device.c coverage.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-07-20 10:12:27 -04:00
Piotr Zięcik 2fe998cdef kernel: Deprecate sys_clock_us_per_tick variable.
On some architectures tick time cannot be expressed as integer
number of microseconds, introducing error in calculations using
sys_clock_us_per_tick variable.

This commit deprecates the sys_clock_us_per_tick variable and
replaces its usage by more precise calculations based on
sys_clock_hw_cycles_per_sec and sys_clock_ticks_per_sec.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2018-07-20 00:03:52 -04:00
Piotr Zięcik 81a2c4b8ff tests: sleep: Fix _TICK_ALIGN correction.
This commit replaces _TICK_ALIGN correction in the test (which was based
on simple division), by more precise estimation using __ticks_to_ms()
and _ms_to_ticks() functions.

This commit fixes #8899.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2018-07-20 00:00:36 -04:00
Spoorthi K 34ee20a375 tests: sleep: Add description and RTM links
Add test description for sleep and some uncrustify
changes

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-18 12:37:39 -04: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
Spoorthi K bffae85488 tests: kernel: Add description for common and interrrupt
Add test description, RTM links and doxygen links for common,
    interrupt and boot page table test cases.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-18 06:52:18 -04:00
Praful Swarnakar 5b8e4ae4df tests: kernel: init: Add description and RTM links
Add description for init boot delay tests and group
them for doxygen.

Signed-off-by: Praful Swarnakar <praful.swarnakar@intel.com>
2018-07-17 12:19:49 -04:00
Praful Swarnakar f789a728bb doc: tests: Add test description and doxygen groups in timer
Add test case description and doxygen groups for tracebility.
Add references to APIs being tested in timer component.

Signed-off-by: Praful Swarnakar <praful.swarnakar@intel.com>
2018-07-17 10:56:24 -04:00
Spoorthi K 25966c8406 tests: semaphore: Add description for semaphore tests
Add description for test cases in semaphore and group
them for doxygen.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-17 07:55:35 -04:00
Spoorthi K 02addfff50 tests: poll: Add description and RTM links
Add description and RTM links for polling tests.
Also uncrustify changed indentations.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-16 08:23:42 -04:00
Spoorthi K c6c811072f tests: kernel: Add description and group tests for doxygen
Updated test description for tickless test cases, grouped test cases
as per doxygen requirements and some uncrustify's cosmetic changes.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-11 10:20:53 -04:00
Spoorthi K 3e1c0bd386 tests: kernel: Add description and doxygen groups for workq
Update and rearrange doxygen groups and test description
for workq tests

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-11 10:18:04 -04:00
Spoorthi K 22ea79db70 tests: pending: Add description and RTM links
Add test description, doxygen and RTM links to tests
in pending

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-07-11 10:17:04 -04:00
Ajay Kishore 0de49e5d40 tests: kernel: Add description for test case
Add description to test case in tests/kernel/fatal

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-07-05 12:52:21 -04:00
Piotr Zięcik 91fe22ec7d kernel: Improve tick <-> ms conversion.
The kernel incorrectly assumed, that system timer frequency is always
divisible without remainder by couple "natural" tick rates (like 100).
As result on some SoCs, time calculations was not correct, producing
strange effects (invalid sleep times, incorrect k_uptime_get() etc.).

This commit enables accurate, but costly (using 64-bit math) tick <-> ms
conversion if the selected tick interval is not exact due to hardware
limitations.

Also, this commit fixes tests in which removed _ms_per_tick were used.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2018-07-03 22:46:39 -04:00
Andy Ross dd33b37eff tests/sched/scheduler_api: samples/philosophers: Use SCHED_SCALABLE
These two tests ask for lots of priority levels, more than the 32
maximum allowed by SCHED_MULTIQ (which is by design: if you have
requirements like that DUMB or SCALABLE are better choices due to the
RAM overhead of MULTIQ), so the build will fail on boards that defined
MULTIQ as default.

Don't let the platform choose the scheduler backend, ask for SCALABLE
explicitly.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-07-03 17:09:15 -04:00
Maureen Helm c4123643b5 tests: fp_sharing: Extract x86 configs to separate .conf
The SSE and SSE_FP_MATH configs exist only in the x86 architecture, so
extract them to a separate prj_x86.conf file for the fp_sharing test.

Fixes Kconfig warnings when building the test for frdm_k64f:
- warning: attempt to assign the value "y" to the undefined symbol SSE
- warning: attempt to assign the value "y" to the undefined symbol
  SSE_FP_MATH

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-06-25 12:49:42 -07:00
Carles Cufi 6eeeb2a3e5 tests: Fix sizing for several test for chips with 24KB of RAM
When adding the nRF52810, which has 24KB of RAM, some of the tests don't
compile anymore due to lack of SRAM. Address this by either filtering
the test out or reducing the amount of memory allocation.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-25 19:34:33 +02:00
Spoorthi K a3fe7af2dd tests: obj_tracing: Enhance object counter logic
Restructured the test, added description and enhanced
semaphore count logic to check for semaphores created
only in the test.

Fixes: #7106

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-06-14 23:54:31 -04:00
Leandro Pereira c16bce7a6a samples, subsys, tests: Use ARRAY_SIZE() whenever possible
The ARRAY_SIZE() utility macro will actually test the parameter types,
and ensure that it is only called with arrays, and not arrays decayed
to pointers.

Changes were performed with a simple Coccinelle script.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-06-14 19:12:51 -04:00
Andy Ross 7bbd3a79ae tests/kernel: Add a test for CONFIG_MULTITHREADING=n
This is a feature Ben added so you could use Zephyr's arch layer to
bootstrap things like bootloaders without sucking in the whole kernel.
And it's worked until now.

But we never had a test for it, and I just broke it with the scheduler
rework.  Add a trivial test just to make sure this continues to link
and run.  Longer term it would be nice to have some kind of size
metric here to guarantee that the feature stays lean and doesn't pull
in needless code.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-06-13 17:23:05 -04:00
Ulf Magnusson 072a43d1a4 tests: Do not build arm_irq_vector_table .config's for ARC
Previously, ARC .config's would get built for this test, giving Kconfig
warnings along the lines of

  warning: NUM_IRQS ... was assigned the value "3" but got the value
  "38". Check its dependencies...

Add an 'arch_whitelist: arm' so that .configs only get built for ARM.

These warnings will soon be turned into errors.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-06-12 20:18:14 -04:00
Alberto Escolar Piedras 4a2d109a4b native tests: fix kernel sched preempt for arch posix
The test kernel.sched.preempt was hanging in the posix arch,
due to a busy wait loop in wakeup_src_thread() added in
a803af2fa7.

We fix it by halting the cpu to let time pass in the posix
arch.

Reenabling the testcase in this board by reverting
e8a906c29c

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-06-12 08:16:12 -04:00
Anas Nashif e8a906c29c tests: disable preempt testcase for native_posix
Disabling testcase due to hang during sanitycheck run while we figure
out the real cause of this.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-06-11 21:13:23 -04:00
Alberto Escolar Piedras 252be0b909 tests/kernel/sched/preempt: enable test for native_posix
The native_posix board does model irq_offload properly now
and therefore this test can be executed without problems.
So let's enable it.

Related to commit:
86b5364335

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-06-11 17:25:58 -04:00
Wayne Ren a91f1e5e14 tests: modify the test conditions for emsk_em7d_v22
Because the address and size alignment of MPUv2,
limite the thread numbers for emsk_em7d_v22.

If not, build will faill because of DCCM overflow

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-06-11 09:05:15 -05:00
Wayne Ren 144a4390b5 tests: fix the bug of sentinel.conf
Even CONFIG_HW_STACK_PROTECTION is no here,
it is still yes as it will be re-selected by
CONFIG_TEST_HW_STACK_PROTECTION in tests/Kconfig.

So the correct setting here is:

CONFIG_TEST_HW_STACK_PROTECTION=n

This fixes #8092 (case1)

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-06-08 16:37:22 -05:00
Leandro Pereira 33aa90539a tests: kernel: fifo_timeout: Do not potentially dereference NULL ptrs
The return value from k_fifo_get() might be NULL in some situations,
so protect against that.

Coverity-ID: 186190
Coverity-ID: 186058
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-06-08 13:07:19 -05:00
Anas Nashif b20c4846dd sanitycheck: fail on faults/panics/oopses
Fail in tests where we have an OOPS or a panic. Right now and in many
cases we continue and test case might be reported as PASS.

Cases that have the tag ignore_faults will ignore those faults (cases
that are testing faults for example).

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-06-07 18:01:49 -05:00
Carles Cufi bb631076f6 tests: arm: irq_vector_table: Fix Kconfig override
Since on ARM CONFIG_NUM_IRQS option has no prompt, it cannot be properly
overridden by a prj.conf fragment. Instead make it have a prompt for
this particular test to be able to override it properly.

Fixes #8200

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-06 15:23:07 -04:00
Leandro Pereira a07d0731c7 tests: mbox_api: Fully initialize k_box_msg struct
`mmsg` should be fully initialized prior to calling k_mbox_get().  The
mailbox implementation (mainly, mbox_message_match()) will look inside
the second parameter passed to k_mbox_get() in order to determine if
which pending messages should be returned to the caller.

Fixes Valgrind warning listed in #7478.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-06-05 10:26:59 -04:00
Andy Ross a803af2fa7 tests/kernel/preempt: Add yield and sleep cases
Scheduler choice is subtle across yield and k_sleep(), add calls to
those to the state table and validate that we're making the right
decisions.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-06-04 23:07:13 -04:00
Andrew Boie 2237ce6b56 tests: mem_protect: use better stack size arg
True stack sizes may be rounded up, instead of using a multiplier
just fetch the true stack size and add one to it, just one byte
over should produce an error.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-06-02 16:29:46 -04:00
Nagaraj Hegde 75e2af20ea tests: fifo_timeout : Dereference after null check
fifo data obtained is dereferenced after NULL check.

Coverity-CID:186190

Signed-off-by: Nagaraj Hegde <hegdenagaraj4@gmail.com>
2018-06-02 16:27:34 -04:00
Andy Ross 2d03b55293 tests/kernel/mem_slab: Fix memory overcommit for real
Commit 4ef36a4b54 ("tests/kernel/mem_slab: Fix memory overcommit")
caught this error, but missed the fact that there are two slabs that
need to be resized.  I also failed to properly explain (or, to be
honestly, fully understand) the deadlock condition, so add a nice big
comment explaining it.

Basically: you have a bunch of threads that can allocate all but one
of their blocks before trying to allocate their last one and pending.
There must be at least one block left so all the threads don't
symmetrically go to sleep waiting on each other.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-06-02 16:24:47 -04:00
Ramakrishna Pallala 338f451981 tests: kernel: profiling: Fix _sys_soc_suspend logic
Call k_thread_foreach only once from _sys_soc_suspend()
otherwise it will flood the console with stack dumps. As per
the test implementation, the one time call happens through
test_call_stacks_analyze_idle test case.

Also removed the the stack size comparision logic from
thread_callback() as the actual size allocated could be
different from what is requested based on the Kconfig option
CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT

Fixes Issue #7858

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-06-01 08:57:59 -04:00
Andy Ross 4ef36a4b54 tests/kernel/mem_slab: Fix memory overcommit
This test spawned 4 threads all of which try to allocate 3 blocks from
the same mem_slab before freeing any, leading to a maximum of 12
in-flight allocations.  But the slab contained only 3 blocks!

Most of the time it passed, but CI caught it failing on occasion,
possibly more often now due to recent scheduler changes.  Fixes #8069
(hopefully).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-05-31 14:54:15 -04:00
Anas Nashif 2f7fe7e252 tests: mem_pool: organise test documentation
Add references to tests APIs. Create new group for memory pools.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-31 14:05:38 -04:00
Anas Nashif bed0ac6877 tests: workqueue: fix doxygen group
Use group name folowing the new conventions.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-31 14:05:38 -04:00
Andy Ross c782d07a1c tests/kernel/smp: Properly synchronize CPU counters at test start
The idea behind this test is to race two CPUs against each other,
validating that each is truly running simultaneously.  But it just
assumed that the other thread/cpu would start synchronously as soon as
k_thread_create() returned.

Normally, that works fine.  But while debugging I added some code that
was slowing down entry to the other thread (or maybe the return from
k_thread_create() into the main thread) long enough to allow one
thread to get a significant head start.  That breaks the logic in the
test and things were inexplicably "failing".

Put a spin loop around the count so that the main thread can start
counting to within the memory system's ability to inform it of the
change from the other thread.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-05-31 14:02:03 -04:00
Wayne Ren 92a3c41dd5 tests: necessary fixes for ARC
* because stack analysis is required, so STACK_CHECK must be
turned off. No HW_STACK_PROTECTION has no impact on current test

* If CONIFG_USERSPACE, the real stack size is bigger than the declared
stack size

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-05-30 20:23:35 -04:00
Wayne Ren 467f8fbe3d tests: fixes for ARC
Like ARM, ARC also needs to return

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-05-30 20:23:35 -04:00
Wayne Ren e63cccdc41 tests: fixes for ARC
In arc, privileged stack is merged into defined stack. So
the real stack size should add privileged stack size.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-05-30 20:23:35 -04:00
Anas Nashif 8c8ddb8196 tests: workqueue: add API references and doxygen group
Add a doxygen group and reference tested APIs using @see.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-28 08:52:46 -04:00
Anas Nashif c2e9eef8b0 tests: kernel context: rewrite test to use ztest correctly
The test was using ztest incorrectly exposing everything as one single
test function. We now have multiple tests that can be tracked back to
features and requirements.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-28 08:52:46 -04:00
Anas Nashif 6faf5b8608 test: early_sleep: cleanup test
Fixed comments and naming of test functions.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-28 08:52:46 -04:00
Anas Nashif f0f11289ad tests: schedule_api: change category to sched
Use kernel.sched instead of kernel.thread

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-28 08:52:46 -04:00
Anas Nashif 20e969b8f1 tests: schedule_api: fix references to tested APIs
Use @see instead of custom keyword.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-28 08:52:46 -04:00
Anas Nashif c5be083df5 tests: move schedule_api under sched/
Group tests per area.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-28 08:52:46 -04:00
Anas Nashif 43293b9016 tests: critical: fix naming and comments
We were referring to old function names and still using the task
terminology which can be confusing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-28 08:52:46 -04:00
Anas Nashif eeae0eeffb tests: kernel: put all thread tests on one level
Remove unnecessary deep hierarchy and put all tests on one level.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-26 09:16:42 -04:00
Anas Nashif fe4693bd9f tests: threads: fold customdata tests into main test
Move this small test to the main thread test project.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-26 09:16:42 -04:00
Anas Nashif fa4aa9fec0 tests: threads: fold systemthread tests into main test
such a simple test does not deserve to be on its own, lets just put it
with other thread tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-26 09:16:42 -04:00
Anas Nashif 0a4389839f tests: kernel: document thread tests for RTM
Group threads in doxygen.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-26 09:16:42 -04:00
Andy Ross 86b5364335 tests/kernel: Add preemption priority test
This test exaustively tests preemption points between threads of all
priority classes (cooperative, preemptible, and metairq), done both
from a synchronous reschedule (via k_sem_give() and from interrupt
context (via irq_offload()), and with and without the sched_lock()
held.  It then detects the next thread that runs and validates vs. the
documented priority rules.

Note that there is a whitelisted case on ARM, where irq_offload()
seems not to be working like a true interrupt (it always returns to
the interrupted context and doesn't seem to hit the normal exception
return path which can context switch).  And native_posix is excluded
because of failures and the fact that it's actually never possible to
truly preempt a thread there (they run to completion inside _Swap()
et. al. and then block themselves).  Both of these should be fixable
in the future but don't (seem to) directly relate to this test.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-05-25 09:40:55 -07:00
Ioannis Glaropoulos e8182fa03d test: kernel: remove workaround for arm_mpu (keep for nxp_mpu)
The generation of Stack Corruptions reports is, now, supported
in ARM SOCs with the ARM MPU (CONFIG_ARM_MPU). Therefore, this
commit removes the workaround for ARM architecture in
tests/kernel/fatal/ and keeps it only for SOCs with the NXP MPU
(CONFIG_MXU_MPU).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-05-25 09:46:24 -05:00
Punit Vara ba8c8c3ceb tests: mslab_threadsafe: Check for return value
Check return value for k_mem_slab_alloc()

issue: #6693

Signed-off-by: Punit Vara <punit.vara@intel.com>
2018-05-24 10:56:58 -04:00
Andy Ross e9174c6dde tests/kernel/common: Add rigorous integer typing test
Zephyr code routinely assumes conventional ILP32/LP64 integer
behavior, and occasionally relies on it to perform some nice tricks.
This is despite the fact that this behavior (while pervasively adopted
and in use on all architectures we care about supporting) isn't
actually guaranteed by the language standard which allows much looser
semantics than actual exist on hardware.

Put it into the intmath section of this test as a build time thing.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-05-23 19:40:07 -07:00
Anas Nashif d73e970084 tests: stack: improve test documentation
Add references to APIs being tested and groups tests correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-23 18:58:03 -04:00
Anas Nashif 876195de4d tests: pipe: improve test documentation
Add references to APIs being tested and groups tests correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-23 18:58:03 -04:00
Anas Nashif 234484fda8 tests: msgq: improve test documentation
Add references to APIs being tested and groups tests correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-23 18:58:03 -04:00
Anas Nashif e989283f35 tests: lifo: improve test documentation
Add references to APIs being tested and groups tests correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-23 18:58:03 -04:00
Anas Nashif 12d47cc553 tests: fifo: improve test documentation
Add references to APIs being tested and groups tests correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-23 18:58:03 -04:00
Anas Nashif c2be441712 tests: alert: improve test documentation
Add references to APIs being tested and groups tests correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-23 18:58:03 -04:00
Anas Nashif 6f40b5330a tests: semaphore: improve test documentation
Add references to APIs being tested and groups tests correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-23 18:58:03 -04:00
Kumar Gala e1fab4c310 tests: kernel: timer: timer_api: Remove nonexistent config option
CONFIG_NUM_DYNAMIC_TIMERS doesn't exist so remove setting it in prj conf
file.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-05-23 17:57:06 -04:00
David B. Kinder 071b1bd6b6 doc: fix misspellings in test documentation
Found some misspellings missed during normal review

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-23 15:27:19 -05:00
Ramakrishna Pallala a1492325c0 tests: kernel: fifo: Do NULL pointer check before accessing data
Do NULL pointer check before accessing data.

CID: 186058

Fixes Issue #7716

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-05-23 13:14:17 -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
Andrew Boie 5b8da206c1 tests: fatal: fix several issues
An errant commit accidentally disabled all testing of
hardware-based stack protection. Restore it, and work
around a problem with how these kinds of exceptions are
reported on ARM until #7706 is fixed.

We need to globally disable user mode due to how the
select statements in Kconfig work, the stack sentinel
is incompatible with user mode.

Some build warnings when compiling as native_posix
fixed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-22 15:59:07 -07:00
Andrew Boie 9f30a6caed tests: mem_protect: fix off-by-one
A test was trying to add the maximum number of partitions,
but when the domain was initialized there was already one
added which needed to be accounted for to avoid an
assertion failing.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-22 15:59:07 -07:00
Spoorthi K c182520ee1 tests: kernel: Add description for test cases
Add description to test cases in tests/kernel/mem_heap,
    tests/kernel/mem_slab and tests/kernel/mem_pool

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-05-21 11:23:09 -04:00
Andy Ross 0c80ee0831 tests/kernel: Bump stack sizes for a few tests on qemu_x86
These tests had very small stacks, and the rbtree scheduler on
qemu_x86 (which does need a little extra stack room, though not much)
is bumping up against the limit.  Increase by ~128 bytes in most
cases.  In the case of the mbox_api test, there are other platforms
(which don't use the tree) which are right against the limit already
and will fail to link with a larger stack, so bump it for qemu_x86
only.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-05-19 07:00:55 +03:00
Spoorthi K 7393cb2478 tests: threads: Add test case to verify k_wakeup()
Test case to verify wakeup() of pending thread

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-05-18 17:02:55 +03:00
Ajay Kishore 8b31cdad16 tests: kernel: Add description for test cases
Add description to test case in
tests/kernel/arm_runtime_nmi/

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-05-18 13:33:20 +03:00
Ajay Kishore ad6b890471 tests: kernel: Add description for test cases
Add description to test case in
tests/kernel/arm_irq_vector_table/

Signed-off-by: Ajay Kishore <ajay.kishore@intel.com>
2018-05-18 02:10:35 +03:00
Anas Nashif 39f396a8ad doc: tests: remove obsolete and bogus test groups
Remove unstructured and unused doxygen groups for tests. We will now add
doxygen comments per test function and follow a more structured
grouping.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-18 01:48:31 +03:00
Andrew Boie 3772f77119 k_poll: expose to user mode
k_poll is now accessible from user mode. A memory allocation takes place
from the caller's resource pool to copy the provided poll_events
array; this can be large enough to make allocating it on the stack
not preferable.

k_poll_signal are now proper kernel objects. Two APIs have been added,
one to reset the signaled state and one to check the current signaled
state and result value.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-17 23:34:03 +03:00
Andrew Boie 2b9b4b2cf7 k_queue: allow user mode access via allocators
User mode may now use queue objects. Instead of embedding the kernel's
linked list information directly in the data item, a container struct
is allocated from the caller's resource pool which is then added to
the queue. The new sflist type is now used to store a flag indicating
whether a data item needs to be freed when removed from the queue.

FIFO/LIFOs are derived from k_queues and have had allocator functions
added.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-17 23:34:03 +03:00
Anas Nashif a1fc3969fc tests: common: fixed pointer formatting
Make this test also build with newlib enabled.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-17 13:21:39 +03:00
Andrew Boie f3bee951b1 kernel: stacks: add k_stack_alloc() init
Similar to what has been done with pipes and message queues,
user mode can't be trusted to provide a buffer for the kernel
to use. Remove k_stack_init() as a syscall and offer
k_stack_alloc_init() which allocates a buffer from the caller's
resource pool.

Fixes #7285

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-16 17:32:59 -07:00
Andrew Boie 0fe789ff2e kernel: add k_msgq_alloc_init()
User mode can't be trusted to provide a memory buffer to
k_msgq_init(). Introduce k_msgq_alloc_init() which allocates
the buffer out of the calling thread's resource pool and expose
that as a system call instead.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-16 17:32:59 -07:00
Andrew Boie 44fe81228d kernel: pipes: add k_pipe_alloc_init()
User mode can't be trusted to provide the kernel buffers for
internal use. The syscall for k_pipe_init() has been removed
in favor of a new API to draw the buffer memory from the
calling thread's resource pool.

K_PIPE_DEFINE() now properly locates the allocated buffer into
kernel memory.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-16 17:32:59 -07:00
Andrew Boie 97bf001f11 userspace: get dynamic objs from thread rsrc pools
Dynamic kernel objects no longer is hard-coded to use the kernel
heap. Instead, objects will now be drawn from the calling thread's
resource pool.

Since we now have a reference counting mechanism, if an object
loses all its references and it was dynamically allocated, it will
be automatically freed.

A parallel dlist is added for efficient iteration over the set of
all dynamic objects, allowing deletion during iteration.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-16 17:32:59 -07:00
Andrew Boie e9cfc54d00 kernel: remove k_object_access_revoke() as syscall
Forthcoming patches will dual-purpose an object's permission
bitfield as also reference tracking for kernel objects, used to
handle automatic freeing of resources.

We do not want to allow user thread A to revoke thread B's access
to some object O if B is in the middle of an API call using O.

However we do want to allow threads to revoke their own access to
an object, so introduce a new API and syscall for that.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-16 17:32:59 -07:00
Andrew Boie 577d5ddba4 userspace: fix kobj detection declared extern
If a variable is declared extern first, the name and type
information is stored in a special DW_DIE_variable which
is then referenced by the actual instances via the
tag DW_AT_specification.

We now place extern variable instances in an extern environment
and use this data to fetch the name/type of the instances,
which do not have it (which is why they were being skipped).

As it turns out, the gross hack for the system workqueue was
due to this problem because of the extern declaration in
kernel.h.

Fixes: #6992

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-16 17:00:27 -07:00
Ramakrishna Pallala bb7177830d tests: kernel: profiling: Add test for k_thread_foreach API
Add a test case for k_thread_foreach API.

Replace deprecated k_call_stacks_analyze API with
k_thread_foreach for existing test cases.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-05-15 13:43:00 +03:00
Alberto Escolar Piedras 0e8daafd4c tests kernel pending: unitialized variable
Fix in an unitialized variable in tests/kernel/pending.
To avoid a set of valgrind errors.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-05-10 08:20:15 -07:00
Spoorthi K 79a0fa68e3 tests: mem_protect: Add memory domain testcases
Add few tests to check access permissions of memory partitions
of a memory domain, validate memory domain destroy.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-05-09 21:10:56 -07:00