@@ -216,6 +216,9 @@ void *thread_top_term(void *p1)
216
216
}
217
217
218
218
if (id >= 2 ) {
219
+ if (IS_ENABLED (CONFIG_DYNAMIC_THREAD )) {
220
+ zassert_false (pthread_detach (self ), "failed to set detach state" );
221
+ }
219
222
ret = pthread_detach (self );
220
223
if (id == 2 ) {
221
224
zassert_equal (ret , EINVAL , "re-detached thread!" );
@@ -345,8 +348,13 @@ ZTEST(posix_apis, test_pthread_execution)
345
348
getschedparam .sched_priority ,
346
349
"scheduling priorities do not match!" );
347
350
348
- ret = pthread_create (& newthread [i ], & attr [i ], thread_top_exec ,
349
- INT_TO_POINTER (i ));
351
+ if (IS_ENABLED (CONFIG_DYNAMIC_THREAD )) {
352
+ ret = pthread_create (& newthread [i ], NULL , thread_top_exec ,
353
+ INT_TO_POINTER (i ));
354
+ } else {
355
+ ret = pthread_create (& newthread [i ], & attr [i ], thread_top_exec ,
356
+ INT_TO_POINTER (i ));
357
+ }
350
358
351
359
/* TESTPOINT: Check if thread is created successfully */
352
360
zassert_false (ret , "Number of threads exceed max limit" );
@@ -500,8 +508,13 @@ ZTEST(posix_apis, test_pthread_termination)
500
508
schedparam .sched_priority = 2 ;
501
509
pthread_attr_setschedparam (& attr [i ], & schedparam );
502
510
pthread_attr_setstack (& attr [i ], & stack_t [i ][0 ], STACKS );
503
- ret = pthread_create (& newthread [i ], & attr [i ], thread_top_term ,
504
- INT_TO_POINTER (i ));
511
+ if (IS_ENABLED (CONFIG_DYNAMIC_THREAD )) {
512
+ ret = pthread_create (& newthread [i ], NULL , thread_top_term ,
513
+ INT_TO_POINTER (i ));
514
+ } else {
515
+ ret = pthread_create (& newthread [i ], & attr [i ], thread_top_term ,
516
+ INT_TO_POINTER (i ));
517
+ }
505
518
506
519
zassert_false (ret , "Not enough space to create new thread" );
507
520
}
@@ -571,8 +584,10 @@ ZTEST(posix_apis, test_pthread_create_negative)
571
584
pthread_attr_t attr1 ;
572
585
573
586
/* create pthread without attr initialized */
574
- ret = pthread_create (& pthread1 , NULL , create_thread1 , (void * )1 );
575
- zassert_equal (ret , EINVAL , "create thread with NULL successful" );
587
+ if (!IS_ENABLED (CONFIG_DYNAMIC_THREAD )) {
588
+ ret = pthread_create (& pthread1 , NULL , create_thread1 , (void * )1 );
589
+ zassert_equal (ret , EAGAIN , "create thread with NULL successful" );
590
+ }
576
591
577
592
/* initialized attr without set stack to create thread */
578
593
ret = pthread_attr_init (& attr1 );
@@ -777,3 +792,23 @@ ZTEST(posix_apis, test_pthread_equal)
777
792
zassert_true (pthread_equal (pthread_self (), pthread_self ()));
778
793
zassert_false (pthread_equal (pthread_self (), (pthread_t )4242 ));
779
794
}
795
+
796
+ static void * fun (void * arg )
797
+ {
798
+ * ((uint32_t * )arg ) = 0xB105F00D ;
799
+ return NULL ;
800
+ }
801
+
802
+ ZTEST (posix_apis , test_pthread_dynamic_stacks )
803
+ {
804
+ pthread_t th ;
805
+ uint32_t x = 0 ;
806
+
807
+ if (!IS_ENABLED (CONFIG_DYNAMIC_THREAD )) {
808
+ ztest_test_skip ();
809
+ }
810
+
811
+ zassert_ok (pthread_create (& th , NULL , fun , & x ));
812
+ zassert_ok (pthread_join (th , NULL ));
813
+ zassert_equal (0xB105F00D , x );
814
+ }
0 commit comments