Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Pancakem
Copy link
Contributor

@Pancakem Pancakem commented Nov 13, 2024

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.

@zephyrbot zephyrbot added the area: POSIX POSIX API Library label Nov 13, 2024
@zephyrbot zephyrbot requested review from cfriedt and ycsin November 13, 2024 13:00
@Pancakem Pancakem force-pushed the separate_posix_thread_base_test_into_standalone_test branch 2 times, most recently from fcee92c to 88d572c Compare November 13, 2024 13:13
@cfriedt cfriedt changed the title tests: posix: common: separate posix thread base into a standalone test tests: posix: common: separate posix threads base into a standalone test Nov 17, 2024
@Pancakem Pancakem force-pushed the separate_posix_thread_base_test_into_standalone_test branch from 88d572c to 4f4b818 Compare November 27, 2024 12:12
Copy link
Member

@cfriedt cfriedt left a 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

@Pancakem Pancakem force-pushed the separate_posix_thread_base_test_into_standalone_test branch 3 times, most recently from 831747c to 4328024 Compare December 2, 2024 17:17
@cfriedt
Copy link
Member

cfriedt commented Dec 3, 2024

This needs a minor change. Also, I think it should only be merged after #81613 and #81858 are merged.

@Pancakem Pancakem force-pushed the separate_posix_thread_base_test_into_standalone_test branch 2 times, most recently from c3b8b4a to 01587a7 Compare December 17, 2024 09:28
@Pancakem Pancakem force-pushed the separate_posix_thread_base_test_into_standalone_test branch from 01587a7 to 50b9d55 Compare January 27, 2025 11:29
@Pancakem
Copy link
Contributor Author

Pancakem commented Feb 5, 2025

@cfriedt how are we looking on this?

Copy link
Member

@cfriedt cfriedt left a 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

Comment on lines +566 to +567
/* 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));
Copy link
Member

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, &param));
zassert_ok(pthread_attr_setinheritsched(&attr, inheritsched));
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@cfriedt cfriedt Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pancakem - I created #86061 and #86042

Copy link
Member

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.

Copy link
Member

@cfriedt cfriedt Feb 23, 2025

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.

@cfriedt
Copy link
Member

cfriedt commented Mar 4, 2025

There is some development against previously linked issues, but this might also be blocked by #83386

Copy link

github-actions bot commented May 4, 2025

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.

@github-actions github-actions bot added the Stale label May 4, 2025
@cfriedt cfriedt removed the Stale label May 4, 2025
@Pancakem Pancakem force-pushed the separate_posix_thread_base_test_into_standalone_test branch 2 times, most recently from 06fea49 to a186b8e Compare May 5, 2025 09:57
Comment on lines 6 to 7
CONFIG_POSIX_PRIORITY_SCHEDULING=y
CONFIG_POSIX_THREAD_PRIORITY_SCHEDULING=y
Copy link
Member

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

Comment on lines 11 to 12
CONFIG_DYNAMIC_THREAD_POOL_SIZE=6
CONFIG_POSIX_THREAD_THREADS_MAX=6
Copy link
Member

@cfriedt cfriedt May 5, 2025

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).

Suggested change
CONFIG_DYNAMIC_THREAD_POOL_SIZE=6
CONFIG_POSIX_THREAD_THREADS_MAX=6
CONFIG_DYNAMIC_THREAD_POOL_SIZE=3
CONFIG_POSIX_THREAD_THREADS_MAX=3

CONFIG_DYNAMIC_THREAD_POOL_SIZE=6
CONFIG_POSIX_THREAD_THREADS_MAX=6
CONFIG_HEAP_MEM_POOL_SIZE=4096
CONFIG_POSIX_THREAD_KEYS_MAX=512
Copy link
Member

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)

Suggested change
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>
@Pancakem Pancakem force-pushed the separate_posix_thread_base_test_into_standalone_test branch from a186b8e to ec08cde Compare June 17, 2025 13:04
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ C)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: POSIX POSIX API Library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tests: posix: common: split posix_threads_base tests into standalone test
3 participants