Commit graph

4754 commits

Author SHA1 Message Date
Andy Ross af4ce4a166 tests/lib: Add heap_align test
Test of the sys_heap_aligned_alloc() API.  This is separate from the
existing heap test because aligned_alloc() requires a kconfig to
enable it that can change the heap block header format and will impact
code coverage of the "small" block variant.

It's a fairly simple whitebox test that instantiates a heap and then
enumerates all possible alignments within it, with and without
pre-allocated data, to verify that the resulting memory is correctly
aligned and the heap stays consistent.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-06-22 14:54:04 -04:00
Krzysztof Chruscinski 4baf24203d tests: unit: util: Add tests for new macros
Added tests for GET_ARG_N and GET_ARGS_LESS_N

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-22 15:18:07 +02:00
Håkon Øye Amundsen a4957be25b storage/stream: allow NULL data pointer
This is done to support the idiomatic way of performing flush
operations, where the caller might not have access to the proper data
pointer. Also, there is no reason why reading from address 0 should
not be allowed.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-06-22 14:36:05 +02:00
Dominik Ermel 076282a117 subsys/fs/nvs: Use flash_get_parameters() to get erase value
Use new flash API call to obtain erase value instead of relaying on
hardcoded literals.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-06-22 14:35:03 +02:00
Dominik Ermel 6ea6321586 drivers/flash: Add support for flash_get_parameters to drivers
With addition of flash_get_parameters API call, it is needed to provide
support for the API to flash drivers.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-06-22 14:35:03 +02:00
Stephanos Ioannidis 27d42f060d tests: kernel: lifo_usage: Exclude on qemu_arc_em
This test has a very high failure rate on `qemu_arc_em` and needs to be
disabled until a fix is available.

To be addressed in #26163.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-06-21 09:47:24 -04:00
Marek Porwisz 3c0124a0a0 tests: openthread: Test passing net_pkt to OpenThread thread
Passing TX messages from sockets was reworked for openthread
thus tests need to be created/updated in order to pass.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-06-18 19:37:06 +02:00
Henrik Brix Andersen 0997265111 tests: drivers: sensor: add test case for getting a sensor attribute
Add test case for getting the value of a sensor attribute.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-06-17 17:13:14 +02:00
Roman Vaughan 0562d9fac6 tests: fs: Ensure file_path includes max file name length
A hardcoded path lenth of 80 will not be able to suppor the full length
of 255 when LFN is enabled. This does produce a compiler error,
thankfully, this is only applicable to the test cases.

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
2020-06-17 17:07:45 +02:00
Roman Vaughan 70df7a87a1 tests: fs: Add test case for LFN with FATFS
Rerun the same test but with CONFIG_FS_FATFS_LFN=Y and
with a long filename.

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
2020-06-17 17:07:45 +02:00
the BASTION 3f5a32a7d4 boards: arm: add ruuvi_ruuvitag
Adds ARM based Ruuvtag baord. This board is based on the nRF52832.

Signed-off-by: the BASTION <thebasti0ncode@gmail.com>
2020-06-17 12:29:41 +02:00
Maksim Masalski 6a805dff9f tests: fix text output in timing_info test
After reviewing that test I found output looks too messy.
1. Remove words starting from capital letter in the middle of the
sentence.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2020-06-17 11:17:27 +02:00
Lukasz Maciejonczyk 8acebb5cd0 tests: net: Add tests for IPv6 mesh addresses
This tests make sure that the right source address is chosen during
the mesh multicasting.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-16 19:14:52 +02:00
Piotr Mienkowski 4b194eb4fc gpio: remove deprecated API functions/macros
This commit removes API functions and macros which were deprecated in
2.2 release. GPIO drivers are updated accordingly.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-06-16 19:13:05 +02:00
Krzysztof Chruscinski 34baec32ce tests: drivers: uart: Update uart_async read_abort test
Updated test to reflect API change.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-16 19:11:57 +02:00
Ningx Zhao c42297c2f1 tests: ringbuffer modify a tesecase
Update code comments in ringbuffer/src/main.c
modify a testcase to verify the address stored by ring buffer
is contiguous, and the size of every element is equal to the size of
pointer.

Signed-off-by: Ningx Zhao <ningx.zhao@intel.com>
2020-06-16 16:55:51 +02:00
Marcin Niestroj 3b0917bcbf tests: posix: eventfd_basic: add new test
Introduce new test for eventfd, which will test it in only basic
scope. The real reason why this is introduced is to have a test with
minimal set of configuration dependencies, such as disabled
pthreads (compared to full tests/posix/eventfd/ variant). This allows to
test eventfd mechanism with both POSIX_API=n and POSIX_API=y.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-15 16:52:29 +02:00
Maciej Perkowski bd14a9d493 tests: littlefs: Increase timeout to 180s
The test takes ~175s to end on nrf5284dk_nrf52840 and was failing
due to too short default timeout (60s).

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2020-06-15 16:45:38 +02:00
Marcin Niestroj f74bea04aa tests: net: poll: disable NET_IPV4
Unit test code uses IPv6 only, so disable IPv4.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-15 10:31:37 +03:00
Marcin Niestroj 0995246edb tests: net: poll: select NET_CONFIG_NEED_IPV6
Unit test code requires IPv6 to be ready. Select
CONFIG_NET_CONFIG_NEED_IPV6=y to ensure that.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-15 10:31:37 +03:00
Marcin Niestroj acd8b8d93e tests: net: select: disable NET_IPV4
Unit test code uses IPv6 only, so disable IPv4.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-15 10:31:37 +03:00
Marcin Niestroj ec57ebff66 tests: net: select: select NET_CONFIG_NEED_IPV6
Unit test code requires IPv6 to be ready. Select
CONFIG_NET_CONFIG_NEED_IPV6=y to ensure that.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-15 10:31:37 +03:00
Anas Nashif 6f4f5b1fe5 tests: exclude qemu_arc_hs in lifo_usage test
Fails very frequently in CI, disabling until a fix is available, see

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-06-12 23:22:57 -04:00
Hake Huang abce94bb98 dma: add EDMA test support for MCUX
for RT series CONFIG_NOCACHE_MEMORY need enabled
for Kinetis series CONFIG_DMA_TEST_SLOT_START for test
modify the target and dest alignment

frdmk64f need replace strlen to sizeof in irq callback
clean the unused receive buffer, so output is tidy

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2020-06-12 13:03:28 -05:00
Christopher Friedt 72e7debca5 tests: posix: tests for nanosleep(2)
This commit provides test-cases for nanosleep(2)

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-06-12 17:02:03 +02:00
Vinayak Kariappa Chettimada 372a2e2fd3 tests: Bluetooth: bsim_test: Include advx testing in CI
Update compile.sh and added test_script, so that
bsim_test_advx bsim_test application is built and run in
CI.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 353bb6d5cf tests: Bluetooth: make ctrl_advx a BabbleSim test
Convert the ctrl_advx application into a Babblesim test.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 0a18b7e2cb tests: Bluetooth: advx: disable periodic SYNC_IND packets
Added function call to test disable of the started periodic
SYNC_IND packets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada b92abf8e6a tests: Bluetooth: advx: Use 2M PHY auxiliary PDUs.
Use 2M PHY auxiliary PDUs in test.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 1bd7f26cb0 tests: Bluetooth: advx: Update data while periodic advertising
Update Aux PDU AD Data while periodic advertising.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada f0174527f9 tests: Bluetooth: advx: Added code to test periodic advertising
Added code to invoke starting of periodic advertising.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada dd0c46c371 tests: Bluetooth: advx: test application for adv. ext. development
Added a new advx test application to aid test driven
development.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Torsten Rasmussen e1c1d1daca cmake: make find_package(ZephyrUnittest...) REQUIRED
This commit is a followup to PR #25808 which updates the tests to
ensure the REQUIRED keyword is also used for the ZephyrUnitest package.

This provides a better error message when building with CMake and
forgetting ZEPHYR_BASE or not registering Zephyr in the CMake package
registry.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-06-12 11:10:23 +02:00
Ilya Tagunov 3dc6ee048d boards: nucleo_l073rz/l152re: use node labels in DAC samples and tests
Use node labels instead of aliases to select ADC and DAC instance
in samples and tests.

Signed-off-by: Ilya Tagunov <tagunil@gmail.com>
2020-06-12 11:06:44 +02:00
Ilya Tagunov 02d673c564 tests: drivers: dac: Add Nucleo-L152RE board
Enable DAC tests for Nucleo-L152RE board.

Signed-off-by: Ilya Tagunov <tagunil@gmail.com>
2020-06-12 11:06:44 +02:00
Jian Kang 445576c8a2 tests: kernel: Add a new test for providing time duration in milliseconds
Add a new test case to verify whether kernel allow proving time duration
in milliseconds.

Signed-off-by: Jian Kang <jianx.kang@intel.com>
2020-06-11 07:13:23 -04:00
Ying ming 1b1d728a18 tests: atomic operation: add new test cases
add new test cases to illustrate the zephyr OS
support an array of atomic variables, each bit
of which can be modified.

Signed-off-by: Ying ming <mingx.ying@intel.com>
2020-06-10 10:46:28 -04:00
Krzysztof Chruscinski 727f8e0889 tests: unit: util: Add test for nested FOR_EACH call
Added test for case were FOR_EACH call is nested.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-10 11:58:13 +02:00
Krzysztof Chruscinski 1b4b9386e5 sys: util: Added separator to FOR_EACH_ macros
Added separator (e.g. comma or semicolon) parameter to FOR_EACH_ family.
Separator is added between macro execution for each argument and not at
the end.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-10 11:58:13 +02:00
Krzysztof Chruscinski 77bc550746 tests: drivers: clock_control: nrf: increased LFCLK startup time
Fixed occasional test failures when clock was not ready after
specified time.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-10 11:57:04 +02:00
Anas Nashif 603c24dec9 tests: common: skip bootdelay test on qemu_cortex_m0
Test fails on this one platform, to unblock other changes, skip the test
while the issues is being looked at. This test never ran on this
platform before due to ram restrictions.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-06-09 23:36:16 -04:00
Anas Nashif ac7756d4b1 tests: kernel: common: rename test boot_delay
rename boot_delay function name for clarity and change doxygen group to
be more generic and part of the init group.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-06-09 23:36:16 -04:00
Anas Nashif c815b062c6 tests: kernel: remove ram restrictions
Remove all ram restrictions in kernel tests and revisit all tests and
try to make them pass on all platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-06-09 23:36:16 -04:00
Maksim Masalski 82855aa4e0 tests: update doxygen tags for syscalls tests
Reason is that some tests have poor description in Doxygen tags,
decided to fix that situation in some tests which I understand.
Also remove small misprints from some parts of code.

Update Doxygen tags for the next tests:
test_access_kobject_without_init_access
test_thread_without_kobject_permission
test_bad_syscall
test_syscall_invalid_kobject

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2020-06-09 17:46:23 -04:00
Peter Bigot 31d615eab5 tests: kernel: timer_api: remove extra adjustment to expected result
The converted target value for remaining ticks was increased by one to
match original code, which used a one-sided test.  The current test is
two-sided, so that increment is already present in the allowed 1 tick
error for boards with no slew, and incorporating it into the absolute
error can cause the test to fail.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-09 18:57:31 +02:00
Ningx Zhao 09310462fd tests: rbtree to add and modify some tastcases
Add two testcases,one of them verify rbtree node can be embedded
in any user struct.
And another verify some operations in logarithmic time.

Signed-off-by: Ningx Zhao <ningx.zhao@intel.com>
2020-06-09 10:21:33 -04:00
Reto Schneider 0b4b3ae4dd cmake, 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 multiple projects
"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, small, manual adjustments
have been done.

See also 7eabab2f5d ("samples, tests: Use semi-accurate project names")

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2020-06-09 08:18:29 -04:00
Peter Bigot 9c2c12d10f tests: tickless: fix build error on qemu_cortex_m3
Code compiled only for this platform had an unconverted legacy
sleep delay.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-09 08:14:53 -04:00
YouhuaX Zhu 0b2fa63191 Tests: create new test cases to verify sensor APIs.
1. Create a dummy sensor driver and implement the sensor interfaces:
    .sample_fetch = &dummy_sensor_sample_fetch,
    .channel_get = &dummy_sensor_channel_get,
    .attr_set = dummy_sensor_attr_set,
    .trigger_set = dummy_sensor_trigger_set.

2. Create below two test cases to verify the sensor subsys APIs:
    test_sensor_get_channels() for verifying sensor channel APIs,
    test_sensor_handle_triggers for verifying sensor trigger APIs.

Signed-off-by: YouhuaX Zhu <youhuax.zhu@intel.com>
2020-06-09 08:14:17 -04:00
YouhuaX Zhu 79481837fe Tests: Adjust code and annotations for poll test cases.
1. Shorten the long function body for test_poll_wait() to
increase readability, split it into below two method:
    test_poll_wait(),
    check_results().

2. Adjust annotations for below poll test cases:
    test_poll_wait(),
    test_poll_cancel(),
    test_poll_threadstate().

Signed-off-by: YouhuaX Zhu <youhuax.zhu@intel.com>
2020-06-09 08:14:01 -04:00
Zhu YouhuaX 1f416d8d0d Tests: Add and modify testcases for pipe.
1. Add a new testcase for defining and initializing pipes at run time.
2. Add details comments for some testcases.

Signed-off-by: Zhu YouhuaX <youhuax.zhu@intel.com>
2020-06-09 08:13:46 -04:00
Kumar Gala 1737bd082d zephyr: Use deprecated instead of legacy for Kconfig int types
Rename the Kconfig symbol from LEGACY_ZEPHYR_INT_TYPES to
DEPRECATED_ZEPHYR_INT_TYPES.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-09 06:49:56 -05:00
Stephanos Ioannidis 9cf4cab53d soc: arm: Fix header inclusion from deprecated paths
This commit fixes Cortex-M header inclusions from the deprecated paths.

The Cortex-M headers were relocated from `include/arch/arm/cortex_m` to
`include/arch/arm/aarch32/cortex_m` by the refactoring done in the
commit d048faacf2.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-06-09 10:38:36 +02:00
Alexey Brodkin b98058ecd0 tests: Exclude qemu_arc{em|hs} in some
See https://app.shippable.com/github/zephyrproject-rtos/zephyr/runs/73233/4/tests

And so until "icount" is implemented in QEMU for ARC we exclude
"tickless_concept" & "timer_api" from sanitycheck tests.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2020-06-08 16:58:37 -04:00
Alberto Escolar Piedras 0ecfdf1070 tests: kernel benchmark: Avoid timeout in nrf52_bsim
This test was configuring the system tick period to 1 second.
The test also constantly aligns to system tick boundaries,
in between each test part, which means the test runs for very long
(it is holding for longer than 1 minute just on those waits between
tests alone).
The nrf sys tick driver configures the RTC to produce still
all RTC interrupts at 32KHz intervals, which cause lots of
interrupts which slow down simulation quite bit.
Overall the test could take longer than 30 seconds in the
nrf52_bsim in CI even that this platform simulated time is decoupled
from real time.

=> Add a new config overlay for the nrf52_bsim board so
we configure there a much higher system tick frequency
It does not affect the test in any way more than shortening
the wait periods between in test part.

Also increment the sys tick to twice per second to speed up
the test in other platforms.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2020-06-08 17:13:10 +02:00
Kumar Gala e353d123fd zephyr: Make Zephyr int types deprecated by default
As the int types defined in include/zephyr/types.h are typdef's we
utilize a Kconfig option (LEGACY_ZEPHYR_INT_TYPES) to enable/disable
the support for them.  By default to LEGACY_ZEPHYR_INT_TYPES not
being enabled and add an explicit test to ensure the types continue to
function until removed in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Kumar Gala d00d0f1266 samples/tests: Convert use of %ll{u,d} to PRI{u,d}64
Move to using PRIu64/PRId64 instead of %llu/%lld since on
native_posix_64 the uint64_t/int64_t type is defined in terms of 'long
int' and not 'long long int'.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Peter Bigot 06afe554c9 tests: kernel: timer_api: compensate inaccurate conversion
When millisecond/tick conversion is not exact tick delta's are
dependent on the initial tick value.  In those cases exact comparisons
need to also allow an adjacent value.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-05 17:14:48 +02:00
Peter Bigot b22cef027f tests: kernel: timer_api: compensate for fast clocks
When HFCLK has a slew making it faster than LFCLK the busy wait can
expire before the timer fires.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-05 17:14:48 +02:00
Peter Bigot 365fd524cd tests: kernel: timer_api: use slew for duration timer test
Reduce the duration of the timer test so that it will fire before the
busywait elapses even in the worst case of slew between the tick and
busy-wait clocks.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-05 17:14:48 +02:00
Peter Bigot ac94ffedce tests: kernel: timer_api: use slew for remaining timer threshold
This test sets a timer using one clock, waits using a second clock,
then sees whether the remaining time is the expected value.  When the
two clocks are skewed the comparison requires a threshold.  Provide a
means to estimate the maximum expected error.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-05 17:14:48 +02:00
Krzysztof Chruscinski c61dfdc680 tests: drivers: clock_control: nrf: Disable calibration in LFRC test
When test is performed, it assumes that no other entity is changing
the state of the clock. That was not true because calibration was
turning on/off high frequency clock.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-04 11:20:01 +02:00
Andrew Boie 4482f83cdb tests: net: tcp: test zsock_get_context_object
Add test case to prove that this new API works.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-03 22:33:32 +02:00
Andrew Boie 9a27ba57bb tests: net_mgmt: grant socket access
This socket is shared by all the test cases which run in
different threads. Just make it a global object here.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-03 22:33:32 +02:00
Andrew Boie 378024c510 userspace: add z_is_in_user_syscall()
Certain types of system call validation may need to be pushed
deeper in the implementation and not performed in the verification
function. If such checks are only pertinent when the caller was
from user mode, we need an API to detect this situation.

This is implemented by having thread->syscall_frame be non-NULL
only while a user system call is in progress. The template for the
system call marshalling functions is changed to clear this value
on exit.

A test is added to prove that this works.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-03 22:33:32 +02:00
Jukka Rissanen a2f0a9effe net: sockets: Fix sendmsg() user mode param checks for aux data
If we are calling sendmsg() without any aux data, then msg_controllen
is 0 and msg_control is NULL. Check these allowed values properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-03 18:33:59 +02:00
Jukka Rissanen d3dde1ad1c net: sockets: Fix sendmsg() user mode param checks for dst address
If we are calling sendmsg() for a connected socket, then msg_namelen
is 0 and msg_name is NULL. Check these allowed values properly.

Also modify unit tests so that we test this scenario.

Fixes #25925

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-03 18:33:59 +02:00
Christopher Friedt 79728a63ab tests: socket: socketpair: init param before passing by ref
Fixes #25797
Coverity-CID: 210607

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-06-03 18:33:19 +02:00
Christopher Friedt 3f30ce21cb tests: socket: socketpair: init param before passing by ref
Fixes #25796
Coverity-CID: 210579

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-06-03 18:33:19 +02:00
Christopher Friedt 15a2a6ddb7 tests: socket: socketpair: assert recvfrom returns >= 0
Fixes #25731
Coverity-CID: 210568

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-06-03 18:33:19 +02:00
Peter Bigot 8949680482 tests: bluetooth: ctrl_sw_privacy_unit: remove legacy timeout API
This test doesn't depend on the legacy API.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-03 17:47:58 +02:00
Peter Bigot 4438b103c2 tests: kernel: mem_protect: futex: convert to new timeout API
Remove use of the legacy timeout API.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-03 17:47:58 +02:00
Peter Bigot 76d8f8f1e2 include: sys: time_units: fix 32-bit near conversion for overflow
Adjusting the input value to allow round to nearest can cause an
overflow which invalidates the expectation that the 32-bit result is
the low 32 bits of the 64-bit result.  If the adjustment overflows do
the full-precision conversion and truncate in the caller.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-03 01:49:42 +02:00
Andy Ross 7ff3f8ac1c tests/kernel/queue: Add regression test for CONFIG_POLL race condition
When CONFIG_POLL was set, it was historically true that the queue
could (if a higher priority thread "stole" an insert) return a
spurious NULL instead of continuing to wait on a timeout.

This deliberately exercises that race.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-06-03 01:47:41 +02:00
Andy Ross 99c2d2d047 kernel/queue: Remove interior use of k_poll()
The k_queue data structure, when CONFIG_POLL was enabled, would
inexplicably use k_poll() as its blocking mechanism instead of the
original wait_q/pend() code.  This was actually racy, see commit
b173e4353f.  The code was structured as a condition variable: using
a spinlock around the queue data before deciding to block.  But unlike
pend_current_thread(), k_poll() cannot atomically release a lock.

A workaround had been in place for this, and then accidentally
reverted (both by me!) because the code looked "wrong".

This is just fragile, there's no reason to have two implementations of
k_queue_get().  Remove.

Note that this also removes a test case in the work_queue test where
(when CONFIG_POLL was enabled, but not otherwise) it was checking for
the ability to immediately cancel a delayed work item that was
submitted with a timeout of K_NO_WAIT (i.e. "queue it immediately").
This DOES NOT work with the origina/non-poll queue backend, and has
never been a documented behavior of k_delayed_work_submit_to_queue()
under any circumstances.  I don't know why we were testing this.

Fixes #25904

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-06-03 01:47:41 +02:00
Jukka Rissanen 1bb41c49ce tests: net: udp: Enable more usermode tests for sendmsg()
Some of the sendmsg() tests were not run when in usermode.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-02 15:22:47 +02:00
Peter Bigot 394ff7a28b tests: drivers: gpio_basic_api: silence Coverity warning
The tests normally verify that pin configuration succeeded by checking
the return value.  That's not necessary on the cleanup path, so
expressly ignore the result.

Also lift the common code to before the exit branching.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-01 21:59:17 +02:00
Henrik Brix Andersen 8b5b7fcf8d test: lib: devicetree: add tests for DT_ macros for retrieving PWM period
Add tests for DT_ macros for retrieving the 'period' cell value.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-05-29 14:48:12 +02:00
Marc Herbert debade9121 tests: make find_package(Zephyr...) REQUIRED
... because it is (required).

This makes a difference when building with CMake and forgetting
ZEPHYR_BASE or not registering Zephyr in the CMake package registry.

In this particular case, REQUIRED turns this harmless looking log
statement:

-- Could NOT find Zephyr (missing: Zephyr_DIR)
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- ...
-- ...
-- ...
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:8 (target_sources):
  Cannot specify sources for target "app" which is not built by
  this project.

... into this louder, clearer, faster and (last but not least) final
error:

CMake Error at CMakeLists.txt:5 (find_package):
  Could not find a package configuration file provided by "Zephyr" with
  any of the following names:

    ZephyrConfig.cmake
    zephyr-config.cmake

  Add the installation prefix of "Zephyr" to CMAKE_PREFIX_PATH or set
  "Zephyr_DIR" to a directory containing one of the above files.  If
  "Zephyr" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-05-29 10:47:25 +02:00
Martí Bolívar e4a761cffe devicetree: add migration guide documentation and tests
Add test cases that verify various bits and pieces of the legacy
devicetree macros match the new APIs.

Writing these test cases without giving rise to deprecated macro
warnings which might break people's CI if they build with -Werror
requires turning off the __WARN() generation in
devicetree_legacy_unfixed.h. The entire file is deprecated at this
point and must be explicitly enabled with an opt-in Kconfig option, so
there isn't any harm in doing this.

Nevertheless, take a minimally invasive approach to avoiding __WARN()
generation in gen_legacy_defines.py, to avoid the possibility of
breakage. This code is basically frozen anyway, so hacks like this
won't cause maintainability problems since it isn't being actively
maintained.

Use the new tests as fodder for a migration guide from the old API in
the documentation.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-28 22:12:38 +02:00
Martí Bolívar f1808c4a80 tests: move lib/devicetree to lib/devicetree/api
This is preparation for an additional test suite specifically for the
legacy API which will be added next.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-28 22:12:38 +02:00
Martí Bolívar 930c5807d5 tests: devicetree: test great-grandchild bindings
At some point, "child-binding:" apparently only worked up to 2 levels
deep. That's not the case anymore, but add a regression test to make
sure that doesn't break. 3 levels deep ought to be enough for anyone.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-28 22:12:38 +02:00
Andrzej Puzdrowski 48af970339 tests/subsys/settings/functional/nvs: add nrf52xx configuration
Added configuration which allows to run test-suite
on nrf52840dk_nrf52840 and nrf52dk_rf52832 boards.

fixes #25701

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-05-28 17:11:12 +02:00
Ioannis Glaropoulos 79ff37b9cc tests: kernel: stackprot: increase Main stack size for this test
Increase the main thread stack size for this test
to 2048; this increase prevents stacking errors in
the main thread, in several Cortex-M platforms.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-05-28 10:31:05 +02:00
Andrew Boie 4cdaa71444 tests: userspace: check TLS location
Ensure that the TLS region is within the stack object.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-05-27 19:48:27 +02:00
Alexandre Bourdiol 3152a0d567 tests: kernel: mem_protect: syscalls: configurable faulty address
On nucleo_f429zi and nucleo_f207zg boards,
0xFFFFFFF0 is not a faulty address.
Instead we can use 0x0FFFFFFFF.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-05-27 19:29:03 +02:00
Kumar Gala da40dd4c78 devicetree: Fix argument order for DT_*_CELL_BY_IDX
The cell paramater should have been last to match both the
DT_*_CELL_BY_NAME macros as well as how DT_PHA_BY_IDX works.  We fix the
DT_INST_*_CELL_BY_NAME macros as well.

The dma macro's implemented the behavior correctly, but got the argument
names in correct.  We fix that to make everything consistent.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-27 17:58:35 +02:00
Ioannis Glaropoulos b273803537 tests: arch: arm_interrupt: minor style fixes in comments/README
Add some missed style fixes in inline comments and test README.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-05-27 11:57:55 +02:00
Ioannis Glaropoulos dbea2b757a tests: arm: arm_interrupt: improve sample console output
Enhance the sample console output of the arm_interrupt
test, to reflect recent changes in test context as well
as kernel fault handling log output format.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-05-27 10:10:22 +02:00
Ioannis Glaropoulos 42826f786a tests: arm: interrupt: test-case for stacking error check
We add a test case to verify that the Cortex-M fault
handling is able to catch stacking errors explicitly
due to exception entry frame stacking (that is, when
the Cortex-M MCU does not report Data Access Violation
MemManage fault with a valid MMFAR value, but only a
Stacking MemManage fault). We update the README file
accordingly.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-05-27 10:10:22 +02:00
Tomasz Bursztyka 9dd822dc93 tests/net: Test network power management awareness
A quick test on a dummy device that:
- opens a socket (success)
- sends data (success)
- suspends (success)
- suspends (failure)
- sends data (failure)
- resumes (success)
- resumes (failure)
- sends data (success)

This permits to show that PM states are properly handled in network
stack.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-26 21:41:00 +02:00
Wayne Ren 52992b0658 tests: skip the cpu_idle test for nsim_hs_smp
Because the sleep instruction issue for nsim_hs_smp, idle
loop is used to simulate behavior of sleep, so arch_cpu_idle will
forever loop. This causes cpu idle test loop, then the whole
context test timeouts.

as a fix, skip the cpu_idle test for nsim_hs_smp now.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2020-05-26 17:47:42 +02:00
Andrzej Puzdrowski 74730d0c5f tests/subsys/storage/stream_flash: add unaligned flash test
Added test for check proper service of flush-write when buffer
contains unaligned amount of data.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-05-26 16:35:19 +02:00
Carles Cufi 855b6c1a5d tests: logging: Add a clean ouput test and clarify output
Add a new test with clean output and warn the user that the version
without clean output will output garbled text.

Fixes #23799

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-25 21:41:46 +02:00
Oleg Zhurakivskyy 593f7c4556 tests: net: tcp2: Avoid trying to free net_pkt twice
For success cases, the net_pkt is handled by the IP stack
so no need to free the net_pkt. The double free is not causing
any issues as the net_pkt code will just ignore the request but
we should avoid doing it because of error prints that are printed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Peter Bigot 8fbc83c651 tests: timer_api: avoid compounding errors in imprecise conversions
When the timer frequency is not a multiple of 1000 converting between
ticks and milliseconds introduces error.  Avoid propagating the error
by converting divided values rather than dividing converted values.

Also compensate for observed rate differences between the busywait
clock and the timeout clock.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-24 20:28:58 +02:00
Peter Bigot a44bc7026e tests: timer_api: compensate for fast clocks
A fast timer clock can advance before or after the remaining time
until an event is captured.  Verify the expected relationship between
current and remaining time holds for at least one captured current
time.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-24 20:28:58 +02:00
Peter Bigot 46e402dd6e tests: timer_api: fix for inexact ms/tick conversions
When one millisecond is not an integral number of ticks measuring
durations between tick events will sometimes be less than expected to
correct for error that was accumulated between other events.  Allow
for that in the duration and period comparisons.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-24 20:28:58 +02:00
Anas Nashif 0c908e124e tests: gpio_basic: this test requires a fixture
This test requires a fixture to be installed, in this case a wire
connecting two GPIO pins.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-05-24 20:25:51 +02:00
Anas Nashif 8067663671 tests: maxim_ds3231_api: use fixture
This test depends on additional hardware being connected to the board,
add a fixture and cleanup whitelist.

Fixes #25177

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-05-24 20:25:51 +02:00
Peter Bigot 726bff2353 tests: kernel: device: bypass device pm tests
The dummy driver never implemented device power management, so the
fact the not-implemented stub returned success was a false negative.
Verify the expected behavior now, leaving the test code in place for
when somebody provides a non-trivial PM control function.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-21 20:32:12 +02:00
Krzysztof Chruscinski a719b8c5e4 drivers: timer: nrf: Remove RTC1 dependency
Removed RTC1 dependencies in the code. Single define picks the instance.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-05-21 17:43:08 +02:00
Maureen Helm 164434a01e tests: adc: Configure adc_api test for frdm_k82f board
Configures the adc api test to use the arduino header A2 pin on the
frdm_k82f board. This follows frdm_k64f and frdm_kw41z boards, which
also use the arduino header A2 pin for the test.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-05-21 11:01:18 +02:00
Wayne Ren e0470d0f93 tests: add a workaround for arc emsdp
arc emsdp's console will use irq 108/107 which will
conflict with irqs used in tests (emsdp has 112 irqs),
so add a workaround for emsdp.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2020-05-21 10:59:36 +02:00
Daniel Leung 625b5f5a49 tests: timing_info: need to calibrate TSC frequency on x86
For x86, TSC is being used to gather timing information. However,
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC is not the same as TSC
frequency when HPET (or other) timer is used. So use the system
clock to calibrate the TSC frequency so we can use it to
calculate timing information.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-05-20 22:34:39 +02:00
Christopher Friedt ecf32b6eca tests: socket: socketpair: fix userspace thread permissions
Kernel objects were being directly accessed without previously
calling k_thread_access_grant().

This change allows each test that requires an asynchronous
event to send it to a common work queue with correct
permissions.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-05-20 10:34:07 +02:00
Alexandre Bourdiol 10d8fd4b47 test: lib: heap: increase timeout
On some STM32 boards : nucleo_wb55rg, nucleo_l152re
the test lasts longer than defaut 60sec timeout.
Increase timeout to 120 sec.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-05-20 10:32:36 +02:00
Daniel Leung ec9a413983 boards: x86: make up_squared default to x86_64
This makes the up_squared board default to x86_64.
This also adds a new board, up_squared_32, for when 32-bit
is desired.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-05-19 19:19:51 +02:00
Andy Ross 1af8a04fa9 tests/kernel/common: Make test_timeout_order 1cpu
This test works by starting a bunch of poll events, dropping the test
thread priority, calling k_poll(), and assuming that all the timeouts
that fired woke up high priority threads and thus ran before k_poll()
could return.  But that isn't true if you have another CPU that can
run the low priority thread while the last high priority thread
finishes up!

This just isn't SMP-correct.  Mark 1cpu.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-05-19 19:19:51 +02:00
Peter Bigot 4ec5ab2059 tests: cmsis_rtos_v2: adjust timer period to avoid starvation
Most boards run with 10 kHz ticks producing a period of 5 ms for 50
tick interval used in the timer periodic test.  On Nordic 50 ticks
corresponds to 1.5 ms which is too short to complete the TC_PRINT()
call within the handler, causing the periodic timer to starve the
osDelay that would turn off the timer.

Adjust the period to be at least 5 ms or 50 ticks to avoid this
problem while not breaking other platform with slower tick rates.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-19 17:18:43 +02:00
Carles Cufi c80a75d7d1 Revert "test: kernel: context: Exclude for qemu_cortex_r5 (temporary)"
This reverts commit f87bce135a.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-19 17:14:18 +02:00
Alexandre Bourdiol 9368211265 test/benchmarks/latency_measure: adapt test to 24bit Systick for STM32
Cortex-M has 24bit systick.
But this test by default set 1 TICK per seconds, which  is
achievable only if frequency is below 0x00FFFFFF (around 16MHz).
20 Ticks per secondes allows a frequency up to 335544300Hz (335MHz)

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-05-19 17:14:01 +02:00
Jennifer Williams d2c74eb987 drivers: serial: uart: ns16550 add missing isr locking
The existing uart driver ns16550 did not have ISR locking that
effected IO APIC working in fixed delivery mode in SMP system
x86_64. This commit adds ISR locking mechanism using spinlock
for the interrupt related services.

The CONFIG_IPM_CONSOLE_STACK_SIZE is increased to lift
limitation of stack size experienced in IPM driver test with
this spinlock impelentation.

Fixes #23026

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
2020-05-18 19:35:37 -04:00
Alexandre Bourdiol b2a7397a17 tests: drivers: counter: counter_basic_api: allow equality in assert
Since introduction of #24374 this test fails on STM32 boards.
Due to 1Hz frequency of RTC used, the 'diff' could be 0.
But then 'counter_us_to_ticks(dev, processing_limit_us)' is also 0.
We should allow the equality in the assert.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-05-18 19:13:04 +02:00
Alexandre Bourdiol 2f8167fc08 test: drivers: gpio: gpio_basic_api: disable interrupt at end of test
When switching from rising edge to falling edge of test:
test_gpio_deprecated(),
because exti callback is already configured (from rising edge test),
the pin configuration abort for EBUSY reason.
It is necessary to disable interrupt,
so that next test will start with clean configuration.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-05-18 19:12:46 +02:00
Vincent Wan 0b12a7b463 tests: timer_api: fix assertion in test_timer_remaining()
This commit fixes the assertion in test_timer_remaining() that checks
whether the remaining ticks on a timer is less than or equal to half of
the timer duration after a busy wait of that time. If the timer
duration corresponds to an odd number of ticks, 1 should be added to
the upper bound given k_timer_remaining_ticks() returns
<ticks til next deadline> - <elapsed ticks>,
and <elapsed ticks> is truncated to closest integer tick count.

For example, if
    dur_ticks = 3277
    <ticks til next deadline> = 3277
    <elapsed ticks> = 1638.5 rounded to 1638

rem_ticks would be 1639, which is 1 greater than dur_ticks/2.

Fixes #25331

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2020-05-18 11:08:21 +02:00
Daniel Leung 01445ef873 tests: gpio_basic_api: change GPIOs for mec15xxevb_assy6853
GPIO 050/051 are being used for tachometer sensor as
CONFIG_TACH_XEC is enabled by default. So for the gpio_basic_api
test, another set of GPIOs are needed. GPIO 156/157 are chosen
as they are (more or less) dedicated for two LEDs on board and
not being used for other functions (pinmux-wise).

Fixes #25272

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-05-15 17:18:41 +02:00
Wentong Wu 9189acba03 tests: kernel: reduce test interval to save execution time
In Qemu icount mode, busy wait will cause lots of wall time and it's
very easy to get sanitycheck timeout(this case will be successful if
given enough timeout value for sanitycheck), so reduce test interval
to save execution time.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-05-14 13:52:07 +02:00
Wentong Wu 72227574d8 timer: remove QEMU_TICKLESS_WORKAROUND
Qemu icount mode enabled, remove QEMU_TICKLESS_WORKAROUND.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-05-14 13:52:07 +02:00
Wentong Wu b8724377e8 tests: lib: heap: exclude qemu_riscv32 platform
This CPU-bound test on qemu_riscv32 platform is very slow when
QEMU icount mode enabled, taking upwards of several minutes.
There's little value here, this is a unit test of library code
and we have coverage of the RISC-V 32 bit arch via hifive1.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-05-14 13:52:07 +02:00
Christoph Reiter d49e7da7da sensor: add sensor driver for Infineon DPS310
Add driver for Infineon DPS310 temperature and pressure sensor.

Signed-off-by: Christoph Reiter <christoph.reiter@infineon.com>
2020-05-14 11:02:29 +02:00
Andrew Boie 3f00daea1e tests: userspace: check for TLS leakage
TLS data set when a thread is in supervisor mode should not
leak if it drops later to user mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-05-13 22:02:48 +02:00
Kumar Gala 9fa3048d62 tests: deprecated: dts: Test deprecated DTS functionality
This this covers two small aspects of DTS functionality: first ensuring
the legacy generation script continues to generally function and second
that FLASH_AREA id's are the same between the old and new generator.

This test will be removed when the legacy generator is removed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-13 21:22:53 +02:00
Kumar Gala ff579a3af3 flash: Convert DT_FLASH_AREA to FLASH_AREA macros
Convert with a combo of scripts and by hand fixups:

git grep -l DT_FLASH_AREA_.*_ID | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_ID/FLASH_AREA_ID(\L\1)/'

git grep -l DT_FLASH_AREA_.*_OFFSET | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_OFFSET/FLASH_AREA_OFFSET(\L\1)/'

git grep -l DT_FLASH_AREA_.*_SIZE | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_SIZE/FLASH_AREA_SIZE(\L\1)/'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-13 21:22:53 +02:00
Gerard Marull-Paretas b35152ed4b devicetree: add DT_INST_FOREACH_CHILD macro
The macro iterates through the list of child nodes in a DT_DRV_COMPAT
instance and invokes provided macro for each node.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-05-13 21:22:06 +02:00
Martí Bolívar 6e8775ff84 devicetree: remove DT_HAS_NODE_STATUS_OKAY
Several reviewers agreed that DT_HAS_NODE_STATUS_OKAY(...) was an
undesirable API for the following reasons:

- it's inconsistent with the rest of the DT_NODE_HAS_FOO names
- DT_NODE_HAS_FOO_BAR_BAZ(node) was agreed upon as a shorthand
  for macros which are equivalent to
  DT_NODE_HAS_FOO(node) && DT_NODE_HAS_BAR(node) &&
- DT_NODE_HAS_BAZ(node), and DT_HAS_NODE_STATUS_OKAY is an odd duck
- DT_NODE_HAS_STATUS(..., okay) was viewed as more readable anyway
- it is seen as a somewhat aesthetically challenged name

Replace all users with DT_NODE_HAS_STATUS(..., okay), which is
semantically equivalent.

This is mostly done with sed, but a few remaining cases were done by
hand, along with whitespace, docs, and comment changes. These special
cases include the Nordic SOC static assert files.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 18:24:42 +02:00
Peter Bigot 4f16b419e8 device: avoid casting away const from config_info pointer
The driver-specific config_info structure referenced from the device
structure is marked const.  Some drivers fail to preserve that
qualifier when casting the pointer to the driver-specific structure,
violating MISRA 11.8.

Changes produced by scripts/coccinelle/const_config_info.cocci.

Some changes proposed by the script are not included because they
reveal mutation of state through the const pointer, though the
code works as long as the driver-specific object is defined without
the const qualifier.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-13 18:21:52 +02:00
Anas Nashif ad82b38b8f tests: ztest: prefix tests with test_
Tests should always start with test_, otherwise detection of subtests
will not work through sanitycheck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-05-13 18:16:07 +02:00
Stephanos Ioannidis 28e9b145cd tests: benchmarks: latency_measure: Fix atsame54_xpro
Reduce the system timer frequency on `atsame54_xpro` to prevent timer
from ticking while measuring average context switch time between
threads.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-05-12 16:40:34 +02:00
Stephanos Ioannidis 2c3d0b83e3 tests: kernel: context: Fix test_busy_wait timeout
The commit b7e363661d added an additional
busy wait call in the `busy_wait_thread` function -- effectively making
the minimum time required for the thread to exit twice that of the
original implementation.

This commit updates the busy wait thread completion timeout to reflect
that change.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-05-11 21:34:35 +02:00
Henrik Brix Andersen 6f5af9efa5 tests: i2s: api: fix compilation with new timeout api
Fix compilation of the I2S API tests with the new timeout API.

Remove the defines for sleep periods and embed them directly into the
code to improve consistency.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2020-05-11 21:34:18 +02:00
Stephanos Ioannidis 4b37e6cd36 tests: drivers: console: Skip semihosting console device testing
The semihosting console test (`drivers.console.semihost`) is currently
only supported on the ARM Cortex-M QEMU targets.

While running this test on real hardware targets is possible, there is
no standardised way for sanitycheck to validate its output, so we
filter by `CONFIG_QEMU_TARGET` to skip running it on non-QEMU targets
(including physical hardware targets with `--device-testing`).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-05-11 17:11:35 +02:00
Christopher Friedt 3bfc765aad tests: socket: socketpair: tests for socketpair(2) syscall
Tests for issue #24366

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-05-10 17:46:43 +02:00
Meng xianglin 0b1ef3f6bc test: msgq: remove number of cpu restriction
Remove CONFIG_MP_NUM_CPU=1 from test cases of msgq.
For CONFIG_MP_NUM_CPU > 1, start a thread with K_NO_WAIT to get
message from message queue will run immediately on another cpu and
cause message peek failure if there is no message in queue, so put
messages in msgq before start that thread.

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2020-05-09 19:06:53 +02:00
Daniel Leung 21797051a9 tests: latency_measure: allow use of other timer for timestamp
Some platforms have slow system clock resulting in not very
accurate latency measurements. This updates how the timestamps
are obtained by copying the mechanism from the timing_info test.
This allows using alternate higher speed timers to measure
latency.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-05-09 13:09:50 +02:00
Kumar Gala db725c0ec9 drivers: Replace GPIO_CS Kconfig with devicetree detection
Use DT_INST_SPI_DEV_HAS_CS_GPIOS() in drivers to determine if we should
utilize CS_GPIO base SPI chipselect handling.  This allows us to remove
Kconfig option for this feature.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-09 13:07:05 +02:00
Jan Van Winkel 57671d9716 tests: flash_simulator: Add native posix support
Added support for native posix boards to flash_simulator tests by
making sure that flash layout lines up with layout expected by
tests.

Resolves #25109

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2020-05-08 22:37:21 -04:00
Kumar Gala c2135f8721 devicetree: DT_NODE_HAS_COMPAT_STATUS_OKAY -> DT_NODE_HAS_COMPAT_STATUS
Swap this out and make the status a parameter.
Leave a couple of cases of DT_NODE_HAS_COMPAT().

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-08 19:37:18 -05:00
Kumar Gala 90ffbcb9d3 tests: devicetree: Add explicit has_status checks
Add some tests for DT_NODE_HAS_STATUS

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-08 19:37:18 -05:00
Martí Bolívar 7e0eed9235 devicetree: allow access to all nodes
Usually, we want to operate only on "available" device
nodes ("available" means "status is okay and a matching binding is
found"), but that's not true in all cases.

Sometimes we want to operate on special nodes without matching
bindings, such as those describing memory.

To handle the distinction, change various additional devicetree APIs
making it clear that they operate only on available device nodes,
adjusting gen_defines and devicetree.h implementation details
accordingly:

- emit macros for all existing nodes in gen_defines.py, regardless
  of status or matching binding
- rename DT_NUM_INST to DT_NUM_INST_STATUS_OKAY
- rename DT_NODE_HAS_COMPAT to DT_NODE_HAS_COMPAT_STATUS_OKAY
- rename DT_INST_FOREACH to DT_INST_FOREACH_STATUS_OKAY
- rename DT_ANY_INST_ON_BUS to DT_ANY_INST_ON_BUS_STATUS_OKAY
- rewrite DT_HAS_NODE_STATUS_OKAY in terms of a new DT_NODE_HAS_STATUS
- resurrect DT_HAS_NODE in the form of DT_NODE_EXISTS
- remove DT_COMPAT_ON_BUS as a public API
- use the new default_prop_types edtlib parameter

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-08 19:37:18 -05:00
Tomasz Bursztyka 97326c0445 device: Fix structure attributes access
Since struct devconfig was merged earlier into struct device, let's fix
accessing config_info, name, ... attributes everywhere via:

grep -rlZ 'dev->config->' | xargs -0 sed -i 's/dev->config->/dev->/g'

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-08 23:07:44 +02:00
Ioannis Konstantelias 3f0797488c boards: arm: stm32_min_dev: Add ADC_1
Added ADC_1 support.

Signed-off-by: Ioannis Konstantelias <ikonstadel@gmail.com>
2020-05-08 15:56:33 -05:00
Dominik Ermel 6ba69f19d4 sys/util.h: Add IS_EMPTY and LIST_DROP_EMPTY macros
IS_EMPTY macro allows to check if defined name is empty, i.e.
does not contain replacement list.
LIST_DROP_EMPTY macro may be used to process __VA_ARGS__ type lists,
e.g. a,b,,c , and remove empty elements.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-05-08 17:50:25 +02:00
Andrew Boie b7e363661d tests: context: busy-wait with interrupts locked
This is expected to work on all platforms.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-05-08 17:44:17 +02:00
Paul Sokolovsky b07489614f tests: posix: clock: Workaround to align clocks before querying
Before calling clock_gettime() 2 times in row, issue k_usleep(1)
to align code execution to timer interrupt to prevent (well,
minimize) possibility of getting different ticks values.

Suggested by @andyross.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-05-08 17:31:45 +02:00
Paul Sokolovsky 32270ae1b9 tests: posix: eventfd: Don't mix POSIX and Zephyr kernel APIs
K_MSEC() shouldn't be used with poll(), as they come from 2 different
API domains.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-05-08 17:31:45 +02:00
Paul Sokolovsky a61f86ea8e tests: posix: common: Switch k_sleep() -> k_msleep().
As a step in migration to new timeout API.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-05-08 17:31:45 +02:00
Carles Cufi b67a31e411 Bluetooth: controller: Remove legacy LL
Remove the legacy Link Layer implementation.

Closes #24187.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-08 15:07:00 +02:00
Sahaj Sarup 351f39f9cd board: arm: Add Support For 96Boards Aerocore2
Changes:

- Added all required board files in /boards/arm/96b_aerocore2
- Modified pinmux for stm32f4

Most of the changes in this PR is based on reverse-engineering of the
PCB layout and following commits in the PX4 firmware repository for
the same board. The manufacturer does not provide and or generate
schematics and pinout tables for this board.

This PR includes almost all of the interfaces connected to the STM32
MCU, the only thing not included is the J9 and J8 headers that connect
to a 96Boards baseboard.
These headers are not vital to the functionality of the Aerocore2.

Signed-off-by: Sahaj Sarup <sahaj.sarup@linaro.org>
2020-05-08 07:33:43 -05:00