Most calls to ztest_assert() contain a message with no trailing
newline. So when it fails, we get (eg:):
starting test - test_multilib
Assertion failed at multilib.c:19: test_multilib: (c not equal to 323)
smoke-test failed: wrong multilib selectedFAIL - test_multilib.
when we'd like to get:
smoke-test failed: wrong multilib selected
FAIL - test_multilib.
among other things, because it is easier to parse for correctness.
So this patch adds a trailing newline to the message instead of going
around trying to police every call site to do it.
print[kf]() is used vs k_str_out() as we need something that is
available also for unit tests. As this is not in any hot path,
performance wise is not such a big deal.
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Group tests under 'Zephyr Tests' and only document the actual tests.
Create cross references to APIs being tested where applicable.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Some tests cant run everywhere, instead of completely dropping them, we
should report them as being skipped.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The read/write_kernel_stack tests are confusingly named and incorrectly
implemented for ARM; they are intended to test that user mode threads
cannot read or write their privileged stacks. The privileged stacks
on ARM are not relative to the user stack, and thus their location
cannot be computed from the user stack. To find the privileged stack on
ARM, we have to use _k_priv_stack_find(), which we do during setup
in test_main() rather than from the usermode thread itself. Accessing
thread_stack directly from the test function requires making it
non-static in ztest, so we also give it a ztest_ prefix to avoid
collisions with other test programs. Rename the test functions and
global pointer variable to more accurately reflect their purpose.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Reusing the k_thread structure requires a cleanup of all essential
info. We need to remove the ztest_thread information from the timeout_q.
If left untouched, when a tick occurs the thread's delta_ticks_from_prev
would be corrupted. This inturn causes a chain reaction of problems.
Thus once the unit test is completed the timeout_q is scrubbed.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
This reverts commit 5e545e47fb.
This is breaking some tests, needs to be retested with latest master.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Reusing the k_thread structure requires a cleanup of all essential
info. We need to remove the ztest_thread information from the timeout_q.
If left untouched, when a tick occurs the thread's delta_ticks_from_prev
would be corrupted. This inturn causes a chain reaction of problems.
Thus once the unit test is completed the timeout_q is scrubbed.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
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>
All ztest_* apis now support format specifier which will
evetually help to pass variable arguments to ztest assert
apis in different test cases while showing error messages.
Signed-off-by: Punit Vara <punit.vara@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
We add macros to define test cases that should be run with the CPU
in user mode, if the CPU supports it.
ztest_test_suite() declarations are now static as they can't go on
the main thread stack; the data gets shared between multiple threads.
It's better here anyway as a large test suite could fill up the main
stack, which is by default reduced to 512 bytes.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
ztest unit tests run on the host system, so provide those empty files to
make it build host tests. Those files are auto-generated and not
available when building unit tests.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This patch eliminates need to add logging/sys_log.h in test
cases which required to use this header file.
Signed-off-by: Punit Vara <punit.vara@intel.com>
ztest provides a ztest_test_fail() interface to fail the currently
running test, but does not provide an equivalent ztest_test_pass().
Normally a test passes just by returning without an assertion failure
or other call to ztest_test_fail(). However, if the correct behavior
for a test is to trigger a fatal fault (as with tests/kernel/fatal or
protection or MPU tests), then we need a way for the test to pass the
currently running test before aborting the current thread.
Otherwise, ztest hangs forever in run_test() on the
k_sem_take(&test_end_signal, K_FOREVER) call. Add
a ztest_test_pass() interface and implement it for kernel and
userspace variants of ztest. This interface will be used in the
protection tests.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
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>
Historically, space for struct k_thread was always carved out of the
thread's stack region. However, we want more control on where this data
will reside; in memory protection scenarios the stack may only be used
for actual stack data and nothing else.
On some platforms (particularly ARM), including kernel_arch_data.h from
the toplevel kernel.h exposes intractable circular dependency issues.
We create a new per-arch header "kernel_arch_thread.h" with very limited
scope; it only defines the three data structures necessary to instantiate
the arch-specific bits of a struct k_thread.
Change-Id: I3a55b4ed4270512e58cf671f327bb033ad7f4a4f
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
ztest has a number of assert style macros and used a baseline assert()
that varies from the system definition of assert() so lets rename
everything as zassert to be clear.
Change-Id: I7f176b3bae94d1045054d665be8b5bda947e5bb0
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
The directive exists for platforms that require more stack space than
usual. However, it wasn't being applied to the ztest thread stack
which ztest-enabled cases are run on.
Fixes numerous failures on xtensa simulator targets.
Change-Id: Iafa84de002421f03729c0f0cdeefdea51842ae32
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
If user is trying to use ztest by including ztest.h but has
not defined CONFIG_ZTEST, then fail the compilation as the
result binary will not do anything.
There is no check for CONFIG_ZTEST for unit tests that are run
without qemu.
Change-Id: Ief9bba3a3a0f6acc6a264f17cde828b6d7e543a5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
It was named 'mutex', which is not representative of what it is used for
since it is not used for mutual exclusion, but rather for signaling.
Change-Id: Icfef0011f890b2546af1686ba6b57e3fc13c6576
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
There is an implicit expectation that the priority of threads spawned by
a ztest suite is still higher than the main suite thread own priority
when a test signals the main suite thread that it has completed.
Change-Id: Id7caec3e9e553712c828a93c212b8e82bd16eabd
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
Current users of sys_bitfield*() are bending over backwards to cast
what is most of the times a pointer into an integer.
Bitfields can be better described with an void *, so
uint{8,16,32,64}_t or any other container can be used. Most
sys_bitfield*() operations, by extension, can do the same. Note void *
has byte arithmetic, like char *.
This change will also make it implicit, for any future split of the
address space between virtual (what the SW is seeing) and physical
(what the HW is seeing) way clearer, as the functions dealing with
physical, non directly referentiable/mappeable addreses to use an
integer type, like mem_addr_t.
- include/arch/ARCH/*asm_inline*:
- sys_bitfield*() all modified to take 'void *'
Note 'void *' arihtmethic is byte based, which makes some things
easier.
- include/sys_io.h:
- introduces DEFINE_BITFIELD
- update docs
- tests/kernel/bitfield: remove all the cast contortions, use DEFINE_BITFIELD
PENDING: update other TCs
- include/arch/nios/nios2.h, drivers/interrupt_controller/ioapic_intr.c:
remove cast contortions
Change-Id: I901e62c76af46f26ff0d29cdc37099597f884511
Jira: ZEP-1347
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.
Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.
Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file. Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.
Jira: ZEP-1457
Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
To customise test builds and support test related features such as time
stamps and a boot banner, introduce a Makefile variant that is dedicated
to testing.
Initially we introduce a new config overlay that is used for all tests, in
this case we enable BOOT_BANNER and BUILD_TIMESTAMP. This will print the
current version and the date, useful when reporting bugs and also an
indicator that the system has booted before the test has started.
For example:
[QEMU] CPU: qemu32
***** BOOTING ZEPHYR OS v1.6.99 - BUILD: Dec 21 2016 19:57:13 *****
tc_start() - Test Nanokernel CPU and thread routines
Initializing nanokernel objects
...
..
Change-Id: I224318cdeb55a301964ea366dbc577e2e3a09175
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Legacy FIFO operations were failing and thus the TC was failing to run.
Stop using k_fifo_get() for allocation and use a bitmap allocator. A
couple of the bitmap operations should be moved to a common header
once ZEP-1347 is completed.
Passes on all arches and boards, whitelist removed; ARM excluded
though due to missing bitfield implementation as per ZEP-82.
Note there is a false checkpatch positive in the decl of
sys_bitfield_find_first_clear().
Change-Id: I1d3ce8e988bf799573041026e419e3946d153590
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Remove those from Makefiles and testcase.ini, we now support unified kernel
only and sanitycheck script now knows how to deal with this.
Change-Id: I853ebcadfa7b56a4de5737d95f2ba096babb2e13
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
ztest execute syncronization depends on sem take and give
between TC. Current issues are
*) test execution go to next one before current TC finish
*) one TC failure will block whole testing.
Fix this issue by move k_sem_take from init_testing to
run_test and add k_sem_give in run_test_fail.
Meanwhile, set init sem value range from 0 to 1
Issue: ZEP-1164
Change-Id: I7b2d38501d0965455a71863a4729ee81472a63ec
Signed-off-by: jing wang <jing.j.wang@intel.com>