zephyr/subsys
Andrew Boie 1ff066548a ztest: end tests more robustly
If a ztest test case creates child thread(s), and one of the
descendent threads invokes ztest_test_pass(), ztest_test_fail(),
or ztest_thread_skip(), only that descendent thread will be
aborted.

Then ztest will try to run the next scenario on the ztest_thread
which is already in use. This was causing corruption issues on
SMP systems, and possibly other subtle, hard-to-debug
situations.

This patch ensures that ztest_thread is always dead before
re-using it, as run_test() now attempts to join on it instead
of using a semaphore.

The ztest_test_* functions now ensure that the ztest_thread
is always aborted, in addition to the current thread.

This isn't perfect. If the testcase spawned other threads,
they will keep running. The most robust way to fix this is to
iterate over all non-essential threads in the system and abort
them. Unfortunately, Zephyr doesn't have a facility to do
this safely.

It would also be simpler to re-use thread objects if
k_thread_create() could detect whether the thread was already
active and abort it, but this is currently not possible
since k_thread_create() can be used with uninitialzed
thread object memory and no checks are possible. This
may be improved in the future, see #23030.

Fixes: #22738
Partial fix for: #24713

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-05-07 19:21:16 -04:00
..
bluetooth Bluetooth: shell: Add phy handling to the shell 2020-05-07 20:12:29 +02:00
canbus canbus: Convert canbus driver and subsys to new timeout API 2020-05-06 10:19:13 +02:00
console console: Port to the new timeout API 2020-05-07 11:01:55 +02:00
cpp
debug debug: thread_analyzer: Implement thread analyzer 2020-04-28 09:11:13 -04:00
dfu dfu: use stream_flash in flash_img 2020-05-06 11:14:00 +02:00
disk dts: Rename DT_HAS_NODE macro to DT_HAS_NODE_STATUS_OKAY 2020-05-06 05:25:41 -05:00
fb subsys/cfb: move MSB_FIRST down to font capabilities 2020-04-27 13:27:03 +02:00
fs
jwt
logging
mgmt
net net/ieee802154: Validate length on received frames 2020-05-07 13:20:46 +03:00
power timeouts: Fix power _sys_suspend invocation 2020-05-07 11:01:55 +02:00
random
settings settings: add const qualifier for unmodified data source 2020-05-07 10:51:49 +02:00
shell shell: Support output using a va_list 2020-05-07 10:04:28 +02:00
stats
storage storage: add stream flash library 2020-05-06 11:14:00 +02:00
testsuite ztest: end tests more robustly 2020-05-07 19:21:16 -04:00
tracing dts: Rename DT_HAS_NODE macro to DT_HAS_NODE_STATUS_OKAY 2020-05-06 05:25:41 -05:00
usb usb: Special return values for custom_handler 2020-05-07 11:20:27 +02:00
CMakeLists.txt
Kconfig