tests: workq: add support for null name parameter

Validate k_work_queue_start() API with null name config, this should
not affect the name of queue's thread.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
This commit is contained in:
Lixin Guo 2021-12-08 16:21:24 +08:00 committed by Anas Nashif
commit 76a4c6dc72

View file

@ -114,6 +114,9 @@ static inline int preempt_counter(void)
return atomic_get(&preempt_ctr); return atomic_get(&preempt_ctr);
} }
static K_THREAD_STACK_DEFINE(invalid_test_stack, STACK_SIZE);
static struct k_work_q invalid_test_queue;
static atomic_t system_ctr; static atomic_t system_ctr;
static inline int system_counter(void) static inline int system_counter(void)
{ {
@ -245,6 +248,20 @@ static void test_queue_start(void)
zassert_equal(strcmp(tn, cfg.name), 0, NULL); zassert_equal(strcmp(tn, cfg.name), 0, NULL);
} }
cfg.name = NULL;
zassert_equal(invalid_test_queue.flags, 0, NULL);
k_work_queue_start(&invalid_test_queue, invalid_test_stack, STACK_SIZE,
PREEMPT_PRIORITY, &cfg);
zassert_equal(invalid_test_queue.flags, K_WORK_QUEUE_STARTED, NULL);
if (IS_ENABLED(CONFIG_THREAD_NAME)) {
const char *tn = k_thread_name_get(&invalid_test_queue.thread);
zassert_true(tn != cfg.name, NULL);
zassert_true(tn != NULL, NULL);
zassert_equal(strcmp(tn, ""), 0, NULL);
}
cfg.name = "wq.coophi"; cfg.name = "wq.coophi";
cfg.no_yield = true; cfg.no_yield = true;
k_work_queue_start(&coophi_queue, coophi_stack, STACK_SIZE, k_work_queue_start(&coophi_queue, coophi_stack, STACK_SIZE,