Commit graph

512 commits

Author SHA1 Message Date
Punit Vara 85be9db682 tests: fatal: convert legacy test to ztest
Clear checkpatch errors and make use of ztest apis to
support ztest framework.

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-11-13 16:35:27 -05:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Ramakrishna Pallala a44e88df2a tests: kernel: timer: Fix TC_PRINT format specifiers
Pass Zephyr type format specifiers to TC_PRINT().

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2017-11-03 10:59:43 -07:00
Punit Vara d8f85d736d tests: static_idt: convert legacy test to ztest
Migrate testcase to ztest and use ztest macros

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-11-03 12:55:56 -04:00
Punit Vara c2f60ebe56 tests: bitfield: Convert legacy test case to ztest
migrate testcase to ztest and use ztest macros.

Signed-off-by: Punit Vara <punit.vara@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-02 18:32:56 -04:00
Punit Vara e2a974497b tests: mslab: convert legacy test to ztest
This patch removes checkpatch warnings as well as
make use of ztest apis to convert legacy test to ztest.

Signed-off-by: Punit Vara <punit.vara@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-02 18:20:32 -04:00
Punit Vara cb81b5ebb4 tests: mem_pool: convert legacy test in ztest
Make legacy test case use of ztest test api to support
test framework

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-11-02 17:18:38 -04:00
Leandro Pereira da9b0ddf5b drivers: Rename random to entropy
This should clear up some of the confusion with random number
generators and drivers that obtain entropy from the hardware.  Also,
many hardware number generators have limited bandwidth, so it's natural
for their output to be only used for seeding a random number generator.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-11-01 08:26:29 -04:00
Anas Nashif 1efce2b3cc tests: removed stray bitfield.c file
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-31 12:32:34 -04:00
Anas Nashif 0ef69a3361 tests: minor cleanup for fp_sharing test
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-31 12:32:34 -04:00
Anas Nashif 780324b8ed cleanup: rename fiber/task -> thread
We still have many places talking about tasks and threads, replace those
with thread terminology.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-30 18:41:15 -04:00
Andrew Boie 4c305a51e9 tests: schedule_api: slightly increase stack size
Two tests were on the knife-edge of their current stack limit and
were overflowing when UART system calls were added and userspace
enabled.

Test case stack sizes are often pulled out of thin air, the current
value of 256 was just a guess.

Kick these stacks up to 384; verified with sanitycheck --all that
this doesn't break anything.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-30 13:20:19 -07:00
Sebastian Bøe b7eaeb9f0a cleanup: Use quote include instead of system include
When the header file is located in the same directory as the source
file it is better to use a relative quote-include, e.g.

than a system include like

Avoiding the use of system includes in these cases is beneficial
because;

* The source code will be easier to build because there will be fewer
system include paths.

* It is easier for a user to determine where a quote-include header
  file is located than where a system include is located.

* You are less likely to encounter aliasing issues if the list of
  system include paths is minimized.

Authors:
Anas Nashif
Sebastian Bøe

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-28 07:11:53 -04:00
Adithya Baglody 990809799b tests: protection: Enable the complete test suit for qemu_x86.
Using the PAE page tables it is possible to disable code execution
form RAM.

JIRA:ZEP-2511

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-10-23 10:13:07 -07:00
Andrew Boie 967ee03271 tests: thread_init: run in user mode
main.c and test_thread_init.c merged.

All tests which don't require cooperative priorities now running in
user mode.

Userspace tag added to testcase.yaml.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-19 15:07:45 -07:00
Andrew Boie c725e64b64 tests: lifecycle_api: run in user mode
Some unnecessary k_thread_abort() removed.

userspace tag added to testcase.yaml.

Suspend/resume, spawn_forever, and spawn_priority tests remain in
supervisor mode due to the priority requests they make.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-19 15:07:45 -07:00
Andrew Boie a9557ef219 tests: custom_data: run in user mode
main.c and test_customdata_api.c merged.

Preemptive priority case now run in user mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-19 15:07:45 -07:00
Andrew Boie 60e6632e65 tests: stack_api: run in user mode when possible
All non ISR tests now run in user mode.

userspace added to testcase.yaml tag list.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-19 15:07:45 -07:00
Andrew Boie bcd3803180 tests: msgq: run in user mode when possible
Unnecessary k_thread_abort() removed from test_msgq_purge_when_put.

A single global msgq object is now shared instead of being declared
on thread stacks, except for an ISR test case which has had its
semaphore renamed.

Moved k_sem_init() call from msgq_thread() to test_msgq_thread()
to fix a race condition.

userspace tag added to testcase.yaml.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-19 15:07:45 -07:00
Andrew Boie bf7d53395e tests: semaphore: run some threads in user mode
main.c and test_sema_contexts.c merged

userspace tag added to testcase.yaml

stack-allocated semaphore in test_sema_thread2thread now just uses
the global semaphore with the same name.

ISR tests run in supervisor mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-19 15:07:45 -07:00
Andrew Boie 39d55ac6a9 tests: alert_api: run in user mode
main.c and test_alert_contexts.c merged.

User threads can't look inside the alert structures, so an extra
variable 'htype' introduced to track expectations for any given
alert object in alert_recv().

Alert objects have to be initialized by supervisor threads since
they register callbacks. An array of toplevel alert objects created
and initialized in test_main(), replacing the ones that used to
live on thread stacks.

Added userspace tag to testcase.yaml

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-19 15:07:45 -07:00
Andrew Boie 776a084216 tests: mutex: run in user mode
Main thread grants itself access to objects it or its children need
and does the rest of the test case in user mode.

Statically defined threads now all run in user mode, with permissions
granted via K_THREAD_ACCESS_GRANT().

Added userspace tag to testcase.yaml.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-19 15:07:45 -07:00
Andrew Boie 610f5d1ce7 tests: obj_validation: add to userspace tests
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-19 15:07:45 -07:00
Luiz Augusto von Dentz 15c115bc61 tests: fifo: Add prj_poll.conf
This enables testing k_fifo test with CONFIG_POLL=y.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-10-18 13:02:52 -04:00
David B. Kinder 4600c37ff1 doc: Fix misspellings in header/doxygen comments
Occasional scan for misspellings missed during PR reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-10-17 19:40:29 -04:00
Andrew Boie c5c104f91e kernel: fix k_thread_stack_t definition
Currently this is defined as a k_thread_stack_t pointer.
However this isn't correct, stacks are defined as arrays. Extern
references to k_thread_stack_t doesn't work properly as the compiler
treats it as a pointer to the stack array and not the array itself.

Declaring as an unsized array of k_thread_stack_t doesn't work
well either. The least amount of confusion is to leave out the
pointer/array status completely, use pointers for function prototypes,
and define K_THREAD_STACK_EXTERN() to properly create an extern
reference.

The definitions for all functions and struct that use
k_thread_stack_t need to be updated, but code that uses them should
be unchanged.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-17 08:24:29 -07:00
Anas Nashif 40acd7e153 tests: timer: remove obsolete CONFIG_NANO_TIMEOUTS
Cleanup testcase as well.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-17 08:55:38 -04:00
Anas Nashif 7076613b22 tests: errno: using new extra_configs
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-17 08:55:38 -04:00
Andrew Boie a2b40ecfaf userspace handlers: finer control of init state
We also need macros to assert that an object must be in an
uninitialized state. This will be used for validating thread
and stack objects to k_thread_create(), which must not be already
in use.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-16 19:02:00 -07:00
Anas Nashif 0356590df5 tests: samples: fix yaml syntax
Fix indentation and syntax and make it pass yamllint tool.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-15 08:15:00 -04:00
Andrew Boie e5b5407ece tests: obj_validation: cleanup
Improved test coverage to reflect current policy and converted to
ztest.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-12 16:26:28 -05:00
Andrew Boie 7e3d3d782f kernel: userspace.c code cleanup
- Dumping error messages split from _k_object_validate(), to avoid spam
  in test cases that are expected to have failure result.

- _k_object_find() prototype moved to syscall_handler.h

- Clean up k_object_access() implementation to avoid double object
  lookup and use single validation function

- Added comments, minor whitespace changes

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-12 16:26:28 -05:00
Andrew Boie cee72411e4 userspace: move _k_object_validate() definition
This API only gets used inside system call handlers and a specific test
case dedicated to it. Move definition to the private kernel header along
with the rest of the defines for system call handlers.

A non-userspace inline variant of this function is unnecessary and has
been deleted.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-11 17:54:47 -07:00
Andrew Boie 22118bf772 tests: obj_validation: only run if HW supported
The test should only run on platforms where CONFIG_USERSPACE
dependencies are met.

Remove the whitelist, the filter will capture the right platforms.

Fixes: #4050

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-11 09:50:05 -07:00
Piotr Mienkowski c4688ea58c tests: tickless: Add support for Atmel SAM family
This patch updates tickless testcase replacing existing support
for Atmel SAM3X with support for the whole Atmel SAM family.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-10-10 10:50:55 -04:00
Andrew Boie b60867fb32 tests: add CONFIG_APPLICATION_MEMORY test
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-25 19:22:02 -07:00
Andrew Boie 2450ce4867 tests: consolidate memory protection tests
All moved under tests/kernel/mem_protect to reduce clutter. Many more
tests are coming for 1.10 and 1.11.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-24 13:32:21 -04:00
Andrew Boie 6781e9908d tests: schedule_api: add extra stack size
Fixes a stack overflow on Xtensa.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-12 22:31:18 -04:00
Anas Nashif 6fa67585e2 cleanup: remove obsolete nano_work.h
Empty file that is a left-over from the migration to unified kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 19:24:12 -04:00
Anas Nashif 46f66f4295 kconfig: generalised stack protection options
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 09:42:35 -07:00
Anas Nashif b1991eba94 cleanup: remove the whitespaces before the # character
Indenting preprocessor directives reduces the code readability, because
it make preprocessor directives harder to spot.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 12:41:07 -04:00
Punit Vara de3f3a9bd4 tests: xip: Remove unnecessary prints
Remove unnecessary prints and update function name

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-09-11 09:53:14 -04:00
Punit Vara e04f8276ad tests: irq_offload: Use SYS_LOG_INF instead of TC_PRINT
Do not print messages by default on console for test cases.
Use SYS_LOG_INF which provides functionality to choose print whenever
require.

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-09-11 09:53:14 -04:00
Ricardo Salveti 9b453e0298 tests: kernel: threads: add specific test tags
Extend test tags to make it easier to filter threads related tests.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-09-10 10:02:18 -04:00
Andrew Boie 7d627c5971 k_thread_create(): allow K_FOREVER delay
It's now possible to instantiate a thread object, but delay its
execution indefinitely. This was already supported with K_THREAD_DEFINE.

A new API, k_thread_start(), now exists to start threads that are in
this state.

The intended use-case is to initialize a thread with K_USER, then grant
it various access permissions, and only then start it.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-07 16:35:04 -07:00
Andrew Boie d76f0a9644 tests: add object validation test case
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-07 16:33:33 -07:00
Andrew Boie d182d0c298 tests: gen_isr_table: don't set compiler opt
Instead, just set -O0 for the particular function which needs it.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-07 16:33:33 -07:00
Andrew Boie 6acd75b2b8 tests: gen_isr_table: set default BOARD properly
This test doesn't work on x86, which doesn't use gen_isr_tables.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-07 16:33:33 -07:00
Andrew Boie a0fd10facf arm_irq_vector_table: don't change optimization
This is unnecessary.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-07 16:33:33 -07:00
Andy Ross 637087cc56 tests/kernel/mem_pool/mem_pool_api: Fix stack sizes
The (artificially small) ISR stack was overflowing on this test when
CONFIG_DEBUG was enabled on qemu_x86.  Really there's no reason to be
restricting stack size at all in a memory pool test, just remove those
settings and use the defaults, which are fine.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-09-06 17:17:15 -07:00
Anas Nashif de8b88bb0b license: fix license identifiers
Also add copyright headers and license tags where missing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-29 07:42:09 -04:00
Luiz Augusto von Dentz 251a8a8c28 test: queue: Add test for multiple threads using k_queue_get
This tests the situation when there are multiple threads calling
k_queue_get which was causing issues when using k_poll.

Jira: ZEP-2553

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-08-25 09:00:46 -04:00
Luiz Augusto von Dentz 7d01c5ecb7 poll: Enable multiple threads to use k_poll in the same object
This is necessary in order for k_queue_get to work properly since that
is used with buffer pools which might be used by multiple threads asking
for buffers.

Jira: ZEP-2553

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-08-25 09:00:46 -04:00
Anas Nashif b8e2ed02b0 tests: kernel: mutex: minor rework
Rename task -> thread and use main as the entry thread saving 512
bytes of RAM.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-24 14:49:24 -04:00
Anas Nashif 5a938df11b tests: mslab: use main thread
Fix legacy naming and function names to be tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-24 09:29:14 -07:00
Anas Nashif 704f879f8a tests: ztest: call test_main() without arguments
Arguments are not needed and in some cases are being set as unused in
the same function. The test_main function is called from ztest main
routine without any arguments.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-24 09:29:14 -07:00
Andrew Boie 5996bca13b schedule_api: fix stack overflow on xt-sim
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-16 10:59:10 -07:00
Andrew Boie 222f37ded9 tests: schedule_api: fix variable shadowing
The array of k_thread "t" was declared non-static in 2 different
C files. Make them static.

Semaphores only used in local C file now declared static.

Use of variable 't' in thread_tslice() no longer shadows global
definition.

Fixes build errors with XCC compiler.

Increase RAM requirement to 20K.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-16 10:59:10 -07:00
Andy Ross 40e669e798 tests/kernel: Add pthread API test
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-08-15 19:42:07 -04:00
Gil Pitney 4f67a6c76d cc3200: Remove TI cc3200 SOC and LaunchXL board support
Per ZEP-1958, Phase 2 of adding CC3220sf LaunchXL support,
was to "deprecate the CC3200 launchxl support in Zephyr
(redundant to the CC3220)."

Effectively, the CC3220 SOC replaces the CC3200.

This patch removes the following:
* the imported CC3200 SDK
* CC3200 SOC, board, DTS files.
* adjusts other files where cc3200 was mentioned.

Also, it fixes explicit references to CC3200 in generic
CC32xx driver files.

Jira: ZEP-1958

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2017-08-15 11:02:48 -05:00
Luiz Augusto von Dentz 4c6007756c tests: work_q: Add test for k_delayed_work_cancel
This adds a test that attempts to submit a work with 0 timeout thus
causing it to immediatelly be submitted to the queue so it is pending
execution which is then cancelled with k_delayed_work_cancel.

Note this can only be done with coop threads with the same or higher
priority otherwise the work_q thread is wakeup before
k_delayed_work_cancel takes place, thus why test_delayed_cancel uses
K_HIGHEST_THREAD_PRIO.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-08-15 08:49:09 -04:00
Luiz Augusto von Dentz c1fa82b3c6 work_q: Make k_delayed_work_cancel cancel work already pending
This has been a limitation caused by k_fifo which could only remove
items from the beggining, but with the change to use k_queue in
k_work_q it is now possible to remove items from any position with
use of k_queue_remove.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-08-15 08:49:09 -04:00
Luiz Augusto von Dentz 84db641de6 queue: Use k_poll if enabled
This makes use of POLL_EVENT in case k_poll is enabled which is
preferable over wait_q as that allows objects to be removed for the
data_q at any time.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-08-15 08:49:09 -04:00
Luiz Augusto von Dentz 42d9aa785d tests: queue: Add tests for k_queue_remove
Add another list of elements which is removed before k_queue_get is
called.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-08-15 08:49:09 -04:00
Anas Nashif 2de59023dc tests: update min ram requirements and filters
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-14 13:28:42 -04:00
Anas Nashif e0e559001f tests: kernel: reduce thread stack size for pend
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-14 13:28:42 -04:00
Wayne Ren f8d061faf7 arch: arc: add nested interrupt support
* add nested interrupt support for interrupts
   + use a varibale exc_nest_count to trace nest interrupt and exception
   + regular interrupts can be nested by regular interrupts and fast
interrupts
   + fast interrupt's priority is the highest, cannot be nested
* remove the firq stack and exception stack
   + remove the coressponding kconfig option
   + all interrupts (normal and fast) and exceptions will be handled
     in the same stack (_interrupt stack)
   + the pros are, smaller memory footprint (no firq stack), simpler
     stack management, simpler codes, etc.. The cons are, possible
     10-15 instructions overhead for the case where fast irq nests
     regular irq
* add the case of ARC in test/kernel/gen_isr_table

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-10 12:47:15 -04:00
Youvedeep Singh 1c856d2b10 tests: kernel: Stress test for preemptive scheduling.
Tests if preemptive threads are picked up as per priority.
This creates 10 threads with priority in increasing order
from 1 to N and each thread prints an Alphabet.
This test fails when threads are picked up out of order.

Jira: ZEP-2370

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2017-08-09 21:44:53 -04:00
Youvedeep Singh ee5d84ca9a tests: kernel: Stress test for round robin scheduling.
This creates 10 threads with equal priority and tests predictibility
of picking all threads in round robin fashion. Test fails when any
thread consumes more time than time slice allocated to it or threads
are not scheduled in round robin fashion.

Jira: ZEP-2371

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2017-08-09 21:44:53 -04:00
Johan Hedberg 2975ca0754 Bluetooth: Kconfig: Rename CONFIG_BLUETOOTH_* to CONFIG_BT_*
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.

Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 11:14:19 +03:00
Niranjhana N 50f112cdc1 tests: xip: convert to ztest
- replaced a test point with ztest API
- separated the main file into two:
    - main.c, which has ztest entry
    - xip.c, which has the original routine

JIRA: ZEP-2382

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-07 22:31:27 -04:00
Niranjhana N 7e5baf0495 tests: multilib: convert to ztest
- added a ztest test point
- separated the main file into two files:
    - main.c, which has ztest entry
    - multilib.c, which has the original routine

JIRA: ZEP-2382

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-07 22:31:27 -04:00
Niranjhana N 502c7c0c83 tests: libs: convert to ztest
- file already had ztest functions
- separated the main file into two:
    - main.c, which has the ztest entry
    - libraries.c, which has the original routines

JIRA: ZEP-2382

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-07 22:31:27 -04:00
Niranjhana N c235ff4959 tests: arm_runtime_nmi: convert to ztest
- file does not use ztest asserts
- separated the main file into two files:
    - main.c, which has ztest entry
    - arm_runtime_nmi.c, which has the original routine

JIRA: ZEP-2382

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-07 22:31:27 -04:00
Niranjhana N 8dc47d6a3b tests: arm_irq_vector_table: convert to ztest
- file already had ztest functions
- separated the main file into two:
    - main.c, which has the ztest entry
    - arm_irq_vector_table.c, which has the original routines

JIRA: ZEP-2382

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-07 22:31:27 -04:00
Anas Nashif 3ac7b3a229 doc: qemu target was deprecated, use 'run'
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-03 11:48:55 -04:00
Andrew Boie 80e82e7205 x86: stack overflow improvements
As luck would have it, the TSS for the main IA task has
all the information we need, populate an exception stack
frame with it.

The double-fault handler just stashes data and makes the main
hardware thread runnable again, and processing of the
exception continues from there.

We check the first byte before the faulting ESP value to see
if the stack pointer had run up to a non-present page, a sign
that this is a stack overflow and not a double fault for
some other reason.

Stack overflows in kernel mode are now recoverable for non-
essential threads, with the caveat that we hope we weren't in
a critical section updating kernel data structures when it
happened.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-03 11:46:26 -04:00
Anas Nashif abb4b09a08 build: remove unused Kconfig variables
Removed unused variables
- CONFIG_NUM_TASK_PRIORITIES
- CONFIG_NUM_COMMAND_PACKETS
- CONFIG_NUM_TIMER_PACKETS

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-03 07:19:29 -05:00
Andrew Boie 507852a4ad kernel: introduce opaque data type for stacks
Historically, stacks were just character buffers and could be treated
as such if the user wanted to look inside the stack data, and also
declared as an array of the desired stack size.

This is no longer the case. Certain architectures will create a memory
region much larger to account for MPU/MMU guard pages. Unfortunately,
the kernel interfaces treat both the declared stack, and the valid
stack buffer within it as the same char * data type, even though these
absolutely cannot be used interchangeably.

We introduce an opaque k_thread_stack_t which gets instantiated by
K_THREAD_STACK_DECLARE(), this is no longer treated by the compiler
as a character pointer, even though it really is.

To access the real stack buffer within, the result of
K_THREAD_STACK_BUFFER() can be used, which will return a char * type.

This should catch a bunch of programming mistakes at build time:

- Declaring a character array outside of K_THREAD_STACK_DECLARE() and
  passing it to K_THREAD_CREATE
- Directly examining the stack created by K_THREAD_STACK_DECLARE()
  which is not actually the memory desired and may trigger a CPU
  exception

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-01 16:43:15 -07:00
Punit Vara e379aed0f2 tests: irq_offload: Convert test case to use ztest
This patch reduces unnecessary output on console. Those things
are replaced by ztest framework APIs

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-08-01 08:46:48 -04:00
Punit Vara cbf40bc6d3 tests: errno: convert test case to use ztest
This patch convert normal test case to use ztest framework
APIs and remove unnecessary output.

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-08-01 08:46:48 -04:00
Punit Vara a0fb3b4d67 tests: critical: Convert testcase into ztest
This commit uses ztest framework APIS to make ouput unified
with other test cases.

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-08-01 08:46:48 -04:00
Leandro Pereira 732424f065 drivers, net: Clean up semaphore initialization
Change the common "init with 0" + "give" idiom to "init with 1".  This
won't change the behavior or performance, but should decrease the size
ever so slightly.

This change has been performed mechanically with the following
Coccinelle script:

    @@
    expression SEM;
    expression LIMIT;
    expression TIMEOUT;
    @@

    - k_sem_init(SEM, 0, LIMIT);
    - k_sem_give(SEM);
    + k_sem_init(SEM, 1, LIMIT);

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-07-27 15:23:07 -04:00
Andrew Boie 416eca5b13 tests: fatal: enable x86 MMU stack protection
Show that this mechanism can detect stack overflows with the
guard page. We only do it once since are are in an alternate
IA HW task after it happens.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-25 11:32:36 -04:00
Andrew Boie c3fce81d13 tests: fatal: fix stack size to k_thread_create
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-25 11:32:36 -04:00
Savinay Dharmappa cc48d40c5f tests: kernel: sprintf: Fix build warning.
As there is no suffix to represent a literal as unsigned short
it is typecasted. It is fix for Jira ZEP-2156

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2017-07-19 11:16:52 -04:00
Andrew Boie e55fd562ec tests: protection: don't do exec tests on x86
The IA32 MMU has no concept of a "no execute" flag, this is
unfortunately only implemented in x86_64.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-10 11:44:56 -07:00
Andrew Boie 65a9d2a94a kernel: make K_.*_INITIALIZER private to kernel
Upcoming memory protection features will be placing some additional
constraints on kernel objects:

- They need to reside in memory owned by the kernel and not the
application
- Certain kernel object validation schemes will require some run-time
initialization of all kernel objects before they can be used.

Per Ben these initializer macros were never intended to be public. It is
not forbidden to use them, but doing so requires care: the memory being
initialized must reside in kernel space, and extra runtime
initialization steps may need to be peformed before they are fully
usable as kernel objects. In particular, kernel subsystems or drivers
whose objects are already in kernel memory may still need to use these
macros if they define kernel objects as members of a larger data
structure.

It is intended that application developers instead use the
K_<object>_DEFINE macros, which will automatically put the object in the
right memory and add them to a section which can be iterated over at
boot to complete initiailization.

There was no K_WORK_DEFINE() macro for creating struct k_work objects,
this is now added.

k_poll_event and k_poll_signal are intended to be instatiated from
application memory and have not been changed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-10 11:44:56 -07:00
Kumar Gala 8953db8008 tests: tickless: fix building of test
Build issues caused by commit fe882f407d
which missed camel case conversion of _TimestampOpen, _TimestampRead,
and _TimestampClose.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-06-29 13:14:18 -05:00
Punit Vara fe882f407d tests: Remove camel case and fix coding style
Test whichever had Camel case defined for functions and variables have
been replaced.

Following warnings have been fixed in test cases as well.
- line over 80 characters
- Macros with flow control statements should be avoided
- Macros with complex values should be enclosed in parentheses
- break quoted strings at a space character
- do not add new typedefs
- Comparisons should place the constant on the right
  side of the test
- suspect code indent for conditional statements
- Missing a blank line after declarations
- macros should not use a trailing semicolon
- Macros with multiple statements should be
  enclosed in a do - while loop
- do not use C99 // comments

JIRA: ZEP-2249

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-06-29 07:00:50 -04:00
Anas Nashif d1e562c924 tests: replace filters in testcase files
Where possible, replace the use of filter with newly added keywords.
This will speed things up and in some cases add more coverage due to bad
filters.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-28 09:51:40 -05:00
Stephen Smalley 0ed343070c tests: protection: add testcase.yaml
commit d859295be9 ("tests: protection: convert to testcase.yaml")
removed testcase.ini but did not add an equivalent testcase.yaml.
Add it.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-06-22 16:15:32 -04:00
Anas Nashif d859295be9 tests: protection: convert to testcase.yaml
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 22:25:14 -04:00
Stephen Smalley c997577670 tests: Add a self-protection test suite
Add a self-protection test suite with a set of tests
to check whether one can overwrite read-only data
and text, and whether one can execute from data,
stack, or heap buffers.  These tests are modeled after
a subset of the lkdtm tests in the Linux kernel.

These tests have twice caught bugs in the Zephyr NXP MPU
driver, once during initial testing/review of the code
(in its earliest forms on gerrit, reported to the original
author there) and most recently the regression introduced
by commit bacbea6e21 ("arm: nxp: mpu: Rework handling
of region descriptor 0"), which was fixed by
commit a8aa9d4f3dbbe8 ("arm: nxp: mpu: Fix region descriptor
0 attributes") after being reported.

This is intended to be a testsuite of self-protection features
rather than just a test of MPU functionality.  It is envisioned
that these tests will be expanded to cover a wider range of
protection features beyond just memory protection, and the
current tests are independent of any particular enforcement
mechanism (e.g. MPU, MMU, or other).

The tests are intended to be cross-platform, and have been
built and run on both x86- and ARM-based boards.  The tests
currently fail on x86-based boards, but this is an accurate
reflection of current protections and should change as MMU
support arrives.

The tests leverage the ztest framework, making them suitable
for incorporation into automated regression testing for Zephyr.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-06-21 21:52:50 -04:00
Anas Nashif 470c5f3189 tests: remove testcase.ini files
We now use yaml files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 20:56:53 -04:00
Anas Nashif cc24f4b03c tests: samples: convert testcase files to yaml
This will prepare test cases and samples with metadata and information
that will be consumed by the sanitycheck script which will be changed to
parse YAML files instead of ini.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 20:56:53 -04:00
Andrew Boie 0f669132a0 kernel: remove gdb_server
This is unmaintained and currently has no known users. It was
added to support a Wind River project. If in the future we need it
again, we should re-introduce it with an exception-based mechanism
for catching out-of-bounds memory queries from the debugger.

The mem_safe subsystem is also removed, it is only used by the
GDB server. If its functionality is needed in the future, it
shoudl be replaced with an exception-based mechanism.

The _image_{ram, rom, text}_{start, end} linker variables have
been left in place, they will be re-purposed and expanded to
support memory protection.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-19 14:29:40 -04:00
Anas Nashif af416a98b0 tests: pipe: fix style
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-19 09:01:14 -04:00
Anas Nashif dc57fa61bf tests: pipe: rename test directory
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-19 09:01:14 -04:00