Skip to content
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

test: test-thread-priority.c fails on Linux #4382

Open
nikneym opened this issue Apr 6, 2024 · 5 comments
Open

test: test-thread-priority.c fails on Linux #4382

nikneym opened this issue Apr 6, 2024 · 5 comments

Comments

@nikneym
Copy link

nikneym commented Apr 6, 2024

Hi, assertion fails at ASSERT_EQ(priority, 0) in the following:

#ifdef __linux__
  ASSERT_OK(uv_thread_getpriority(pthread_self(), &priority));
  ASSERT_EQ(priority, 0);
  ASSERT_OK(uv_thread_setpriority(pthread_self(), UV_THREAD_PRIORITY_LOWEST));
  ASSERT_OK(uv_thread_getpriority(pthread_self(), &priority));
  ASSERT_EQ(priority, (0 - UV_THREAD_PRIORITY_LOWEST * 2));
#endif

make check output:

not ok 355 - thread_priority
# exit code 134
# Output from process `thread_priority`:
# Assertion failed in test/test-thread-priority.c on line 92: `priority == 0` (6 == 0)
  • Version: HEAD
  • Platform: Linux 6.8.0-76060800daily20240311-generic x86_64 GNU/Linux
@bnoordhuis
Copy link
Member

The test makes the (perhaps somewhat naive) assumption that the main thread is created with a priority of 0. Do you happen to know what scheduling policy and priority were used when you ran the test?

The fix is probably quite simple:

diff --git a/test/test-thread-priority.c b/test/test-thread-priority.c
index 0aaf2977..769b485e 100644
--- a/test/test-thread-priority.c
+++ b/test/test-thread-priority.c
@@ -88,8 +88,6 @@ TEST_IMPL(thread_priority) {
  * test set nice value for the calling thread with default schedule policy
 */
 #ifdef __linux__
-  ASSERT_OK(uv_thread_getpriority(pthread_self(), &priority));
-  ASSERT_EQ(priority, 0);
   ASSERT_OK(uv_thread_setpriority(pthread_self(), UV_THREAD_PRIORITY_LOWEST));
   ASSERT_OK(uv_thread_getpriority(pthread_self(), &priority));
   ASSERT_EQ(priority, (0 - UV_THREAD_PRIORITY_LOWEST * 2));

@nikneym
Copy link
Author

nikneym commented Apr 7, 2024

The test makes the (perhaps somewhat naive) assumption that the main thread is created with a priority of 0. Do you happen to know what scheduling policy and priority were used when you ran the test?

I don't know how to do this. Where should I look while tests are running?

I've applied the diff and it fails with the following:

not ok 355 - thread_priority
# exit code 134
# Output from process `thread_priority`:
# Assertion failed in test/test-thread-priority.c on line 93: `uv_thread_setpriority(pthread_self(), UV_THREAD_PRIORITY_LOWEST) == 0` (-13 == 0)

@bnoordhuis
Copy link
Member

That -13 error suggests it's a permission error. Can you run strace -o trace.log -f build/uv_run_tests_a thread_priority thread_priority and post the contents of trace.log?

@nikneym
Copy link
Author

nikneym commented Apr 12, 2024

Hi, sorry for the late reply. Directory named build has not created actually, I'm using make to build and test things. Should I switch to cmake?

@bnoordhuis
Copy link
Member

No, that's okay. As long as you can strace the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants