tests: posix: test support for pthread_attr_setstacksize
Tests for `pthread_attr_setstacksize(3)` and `pthread_attr_getstacksize(3)`. Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
This commit is contained in:
parent
7c583bbf8f
commit
ddf3c57a39
2 changed files with 24 additions and 0 deletions
|
@ -21,6 +21,7 @@ extern void test_posix_pthread_create_negative(void);
|
||||||
extern void test_posix_pthread_termination(void);
|
extern void test_posix_pthread_termination(void);
|
||||||
extern void test_posix_multiple_threads_single_key(void);
|
extern void test_posix_multiple_threads_single_key(void);
|
||||||
extern void test_posix_single_thread_multiple_keys(void);
|
extern void test_posix_single_thread_multiple_keys(void);
|
||||||
|
extern void test_posix_thread_attr_stacksize(void);
|
||||||
extern void test_nanosleep_NULL_NULL(void);
|
extern void test_nanosleep_NULL_NULL(void);
|
||||||
extern void test_nanosleep_NULL_notNULL(void);
|
extern void test_nanosleep_NULL_notNULL(void);
|
||||||
extern void test_nanosleep_notNULL_NULL(void);
|
extern void test_nanosleep_notNULL_NULL(void);
|
||||||
|
@ -45,6 +46,7 @@ void test_main(void)
|
||||||
ztest_unit_test(test_posix_pthread_termination),
|
ztest_unit_test(test_posix_pthread_termination),
|
||||||
ztest_unit_test(test_posix_multiple_threads_single_key),
|
ztest_unit_test(test_posix_multiple_threads_single_key),
|
||||||
ztest_unit_test(test_posix_single_thread_multiple_keys),
|
ztest_unit_test(test_posix_single_thread_multiple_keys),
|
||||||
|
ztest_unit_test(test_posix_thread_attr_stacksize),
|
||||||
ztest_unit_test(test_posix_clock),
|
ztest_unit_test(test_posix_clock),
|
||||||
ztest_unit_test(test_posix_semaphore),
|
ztest_unit_test(test_posix_semaphore),
|
||||||
ztest_unit_test(test_posix_normal_mutex),
|
ztest_unit_test(test_posix_normal_mutex),
|
||||||
|
|
|
@ -531,6 +531,28 @@ void test_posix_pthread_termination(void)
|
||||||
zassert_equal(ret, ESRCH, "got attr from terminated thread!");
|
zassert_equal(ret, ESRCH, "got attr from terminated thread!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_posix_thread_attr_stacksize(void)
|
||||||
|
{
|
||||||
|
size_t act_size;
|
||||||
|
pthread_attr_t attr;
|
||||||
|
const size_t exp_size = 0xB105F00D;
|
||||||
|
|
||||||
|
/* TESTPOINT: specify a custom stack size via pthread_attr_t */
|
||||||
|
zassert_equal(0, pthread_attr_init(&attr), "pthread_attr_init() failed");
|
||||||
|
|
||||||
|
if (PTHREAD_STACK_MIN > 0) {
|
||||||
|
zassert_equal(EINVAL, pthread_attr_setstacksize(&attr, 0),
|
||||||
|
"pthread_attr_setstacksize() did not fail");
|
||||||
|
}
|
||||||
|
|
||||||
|
zassert_equal(0, pthread_attr_setstacksize(&attr, exp_size),
|
||||||
|
"pthread_attr_setstacksize() failed");
|
||||||
|
zassert_equal(0, pthread_attr_getstacksize(&attr, &act_size),
|
||||||
|
"pthread_attr_getstacksize() failed");
|
||||||
|
zassert_equal(exp_size, act_size, "wrong size: act: %zu exp: %zu",
|
||||||
|
exp_size, act_size);
|
||||||
|
}
|
||||||
|
|
||||||
static void *create_thread1(void *p1)
|
static void *create_thread1(void *p1)
|
||||||
{
|
{
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue