tests: lib: ringbuffer: Fixing tests for various platforms

Stress test that was validating thread safeness was configured to use
higher sys tick rate and targeting qemu_x86 platform. However, it was
also build for other platforms and was failing. Fixing it by extracting
stress tests to separate configuration that is run only on qemu_x86.

Modified the test to fail when number of preemptions is less than
expected only on qemu_x86.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2021-09-01 11:46:12 +02:00 committed by Anas Nashif
commit ad6fc38b2f
3 changed files with 20 additions and 7 deletions

View file

@ -2,4 +2,3 @@ CONFIG_ZTEST=y
CONFIG_IRQ_OFFLOAD=y
CONFIG_RING_BUFFER=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_SYS_CLOCK_TICKS_PER_SEC=100000

View file

@ -330,7 +330,7 @@ static void microdelay(int delay)
static void thread_entry_spsc(void *p1, void *p2, void *p3)
{
struct ring_buf *rbuf = p1;
uint32_t timeout = 5000;
uint32_t timeout = 6000;
bool high_producer = (bool)p2;
uint32_t start = k_uptime_get_32();
struct k_timer timer;
@ -370,10 +370,16 @@ static void thread_entry_spsc(void *p1, void *p2, void *p3)
}
PRINT("preempted: %d\n", preempt_cnt);
zassert_true(preempt_cnt > 1500, "If thread operation was not preempted "
/* Test is tailored for qemu_x86 to generate enough number of preemptions
* to validate that ring buffer is safe to be used without any locks in
* single producer single consumer scenario.
*/
if (IS_ENABLED(CONFIG_BOARD_QEMU_X86)) {
zassert_true(preempt_cnt > 1500, "If thread operation was not preempted "
"multiple times then we cannot have confidance that it "
"validated the module properly. Platform should not be "
"used in that case");
}
}
extern uint32_t test_rewind_threshold;
@ -387,8 +393,7 @@ static void test_ringbuffer_spsc(bool higher_producer, int api_type)
uint8_t buf[32];
uint32_t buf32[32];
/* Native posix cannot have sys tick high enough to run this stress test. */
if (IS_ENABLED(CONFIG_BOARD_NATIVE_POSIX)) {
if (CONFIG_SYS_CLOCK_TICKS_PER_SEC < 100000) {
ztest_test_skip();
}

View file

@ -1,7 +1,16 @@
tests:
libraries.data_structures:
common:
tags: ring_buffer circular_buffer
tests:
libraries.ring_buffer:
# FIXME: qemu_arc_hs6x excluded, see #37861
platform_exclude: qemu_arc_hs6x
integration_platforms:
- native_posix
libraries.ring_buffer_concurrent:
platform_allow: qemu_x86
extra_configs:
- CONFIG_SYS_CLOCK_TICKS_PER_SEC=100000
integration_platforms:
- qemu_x86