-
Notifications
You must be signed in to change notification settings - Fork 7.6k
tests: posix: common: separate posix threads base into a standalone test #81339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
tests: posix: common: separate posix threads base into a standalone test #81339
Conversation
fcee92c
to
88d572c
Compare
88d572c
to
4f4b818
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please substitute
/posix_thread_base/posix_threads_base/g
831747c
to
4328024
Compare
c3b8b4a
to
01587a7
Compare
01587a7
to
50b9d55
Compare
@cfriedt how are we looking on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally a lot of tests need to be moved out of the common
testsuite still to other testsuites like xsi_realtime_threads
or xsi_threads_ext
before we create the threads_base
testsuite.
I'll revisit again in a bit to scan through the whole change more thoroughly
/* TODO: pthread_attr_init() should be sufficient to initialize a thread by itself */ | ||
zassert_ok(pthread_attr_setstack(&attr, &static_thread_stack, STATIC_THREAD_STACK_SIZE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to a separate test suite first (xsi_threads_ext
)
|
||
zassert_ok(pthread_attr_setschedpolicy(&attr, policy)); | ||
zassert_ok(pthread_attr_setschedparam(&attr, ¶m)); | ||
zassert_ok(pthread_attr_setinheritsched(&attr, inheritsched)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pthread_attr_setinheritsched()
tests should be reserved to checking that the return value is equal to ENOSYS
in the threads_base
testsuite.
Additionally, we should also check that the POSIX Options (e.g. _POSIX_THREAD_PRIO_INHERIT
) listed in Realtime Threads (link below) are undefined in the threads_base
testsuite.
They should be defined with the CONFIG_XSI_REALTIME_THREADS
Kconfig option, which the xsi_realtime_threads
testsuite should enable.
Functional testing for pthread_attr_setinheritsched()
should be done in the xsi_realtime_threads
testsuite.
Ref Realtime Threads
So this whole function should probably not be in this testsuite.
UINT_TO_POINTER(k_thread_priority_get(k_current_get()))); | ||
} | ||
|
||
ZTEST(posix_threads_base, test_pthread_attr_setinheritsched) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be moved to xsi_realtime_threads
testsuite.
zassert_equal(contentionscope, PTHREAD_SCOPE_SYSTEM); | ||
} | ||
|
||
ZTEST(posix_threads_base, test_pthread_attr_getinheritsched) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should be moved to xsi_realtime_threads
testsuite.
@@ -605,22 +602,10 @@ static void *test_pthread_setschedprio_fn(void *arg) | |||
return NULL; | |||
} | |||
|
|||
ZTEST(pthread, test_pthread_setschedprio) | |||
ZTEST(posix_threads_base, test_pthread_setschedprio) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test belongs in the xsi_realtime_threads
testsuite with the _POSIX_THREAD_PRIORITY_SCHEDULING
Option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A number of tests in this file should be moved to an xsi testsuite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we currently do not have a xsi_realtime_threads
, can we have an issue to link that to I will open a PR dedicated to it. I will also have another PR to move the tests that belong to xsi_threads_ext
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this branch is a bit of a starter for XSI_REALTIME_THREADS
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pancakem - technically I think a testsuite can be created called xsi_realtime_threads
before we have the full Option Group as well, so that shouldn't be a blocker.
There is some development against previously linked issues, but this might also be blocked by #83386 |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
06fea49
to
a186b8e
Compare
tests/posix/threads_base/prj.conf
Outdated
CONFIG_POSIX_PRIORITY_SCHEDULING=y | ||
CONFIG_POSIX_THREAD_PRIORITY_SCHEDULING=y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these are Options rather than Option Groups, so we should remove them them here.
Additionally, _POSIX_THREAD_PRIORITY_SCHEDULING
should be activated by the XSI_REALTIME_THREADS
Option Group mentioned in #86061
The implication is that is someone were to call pthread_attr_setschedparam()
or pthread_attr_getschedparam()
, which are oddly still part of POSIX_THREADS_BASE
, then those functions would return ENOTSUP
. The posix_threads_base
testsuite should also account for that.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getschedparam.html
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
tests/posix/threads_base/prj.conf
Outdated
CONFIG_DYNAMIC_THREAD_POOL_SIZE=6 | ||
CONFIG_POSIX_THREAD_THREADS_MAX=6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that NR_THR
is set to 2 in the testsuite, we might be able to get away with setting these values to 3 (an additional thread just to be on the safe side).
CONFIG_DYNAMIC_THREAD_POOL_SIZE=6 | |
CONFIG_POSIX_THREAD_THREADS_MAX=6 | |
CONFIG_DYNAMIC_THREAD_POOL_SIZE=3 | |
CONFIG_POSIX_THREAD_THREADS_MAX=3 |
tests/posix/threads_base/prj.conf
Outdated
CONFIG_DYNAMIC_THREAD_POOL_SIZE=6 | ||
CONFIG_POSIX_THREAD_THREADS_MAX=6 | ||
CONFIG_HEAP_MEM_POOL_SIZE=4096 | ||
CONFIG_POSIX_THREAD_KEYS_MAX=512 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that NR_KEY
is set to 2 in the testsuite, we might be able to get away with setting these values to 6 (2 keys for each of the 3 possible threads)
CONFIG_POSIX_THREAD_KEYS_MAX=512 | |
CONFIG_POSIX_THREAD_KEYS_MAX=6 |
posix.common contains testsuites that can be separated into smaller groups of tests. This change moves pthread into a singular testsuite at tests/posix/thread_base app directory. Signed-off-by: Marvin Ouma <pancakesdeath@protonmail.com>
a186b8e
to
ec08cde
Compare
|
Fixes #81491
posix.common contains testsuites that can be separated into smaller groups of tests. This change moves pthread, cond, key, mutex and mutex_attr into a singular testsuite at tests/posix/thread_base app directory.