Commit d460a636 authored by Lixin Guo's avatar Lixin Guo Committed by Anas Nashif
Browse files

Test: stack: add a test case for code coverage



Add a testcase for stack_alloc_init API.

Signed-off-by: default avatarLixin Guo <lixinx.guo@intel.com>
parent 397edd1e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ extern void test_stack_pop_can_wait(void);
extern void test_stack_cleanup_error(void);
extern void test_stack_push_full(void);
extern void test_stack_multithread_competition(void);
extern void test_stack_alloc_null(void);
#ifdef CONFIG_USERSPACE
extern void test_stack_user_thread2thread(void);
extern void test_stack_user_pop_fail(void);
@@ -365,6 +366,7 @@ void test_main(void)
			 ztest_user_unit_test(test_stack_user_pop_null),
			 ztest_user_unit_test(test_stack_user_pop_permission),
			 ztest_unit_test(test_stack_alloc_thread2thread),
			 ztest_unit_test(test_stack_alloc_null),
			 ztest_user_unit_test(test_single_stack_play),
			 ztest_1cpu_user_unit_test(test_dual_stack_play),
			 ztest_1cpu_unit_test(test_isr_stack_play),
+18 −0
Original line number Diff line number Diff line
@@ -279,6 +279,24 @@ void test_stack_multithread_competition(void)
	k_thread_priority_set(k_current_get(), old_prio);
}

/**
 * @brief Test case of requesting a buffer larger than resource pool.
 *
 * @details Try to request a buffer larger than resource pool for stack,
 * then see if returns an expected value.
 *
 * @ingroup kernel_stack_tests
 */
void test_stack_alloc_null(void)
{
	int ret;

	/* Requested buffer allocation from the test pool. */
	ret = k_stack_alloc_init(&kstack_test_alloc, (STACK_SIZE/2)+1);
	zassert_true(ret == -ENOMEM,
			"requested buffer is smaller than resource pool");
}

/**
 * @}
 */