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

Support testing.set_fail_timeout on UNIX-likes #3538

Closed
wants to merge 1 commit into from

Conversation

Feoramund
Copy link
Contributor

This will require #3468 in order to terminate tests that are stuck in a loop or otherwise preoccupied, but it does register the test as a failure, if it ever yields back to the runner.

Tested on Linux and FreeBSD amd64.

@laytan
Copy link
Collaborator

laytan commented May 9, 2024

You are not using futexes correctly here. futex_wait accepts the expected value currently at the given futex as its second argument, you are giving it 0 every time now, and when you futex_broadcast you must first write a new value to the futex.

Waiting on a specific futex value has to also be done inside a loop, that actually checks that the value indeed changed to what is wanted.

A good example usage is the One_Shot_Event in core:sync

One_Shot_Event :: struct #no_copy {
you can see it is doing the wait in a loop, and actually changing the value before broadcasting.

Besides that I also don't like that this will run every single test by first creating a new thread and running the test in it, this will slow down testing quite a bit I imagine (I know this is also done on Windows currently, but imo this is not the way to go in the long run), but we can probably look at improving that later.

@Feoramund
Copy link
Contributor Author

What would be the alternative solution? Creating threads at testing.runner that can be passed each test and replaced as necessary if they timeout?

@laytan
Copy link
Collaborator

laytan commented May 10, 2024

What would be the alternative solution? Creating threads at testing.runner that can be passed each test and replaced as necessary if they timeout?

That would be ideal I think, some kind of thread pool (probably not the one in the threads package) that tests get ran on.

But, to be clear, I am not asking you to do that here, we can look at that later too.

@Feoramund
Copy link
Contributor Author

Does the thread pool implementation in the threads package need improvement, or are there special requirements for a test runner thread pool? I had a look for issues regarding the thread pool and could only find #2746.

@laytan
Copy link
Collaborator

laytan commented May 11, 2024

Does the thread pool implementation in the threads package need improvement, or are there special requirements for a test runner thread pool? I had a look for issues regarding the thread pool and could only find #2746.

No I think the thread pool is pretty good there, I just mean you'd at least need some timeout mechanism in it right, but you might be able to built that on top of it, idk.

@Feoramund
Copy link
Contributor Author

Closing in favor of #3646.

@Feoramund Feoramund closed this May 28, 2024
@Feoramund Feoramund deleted the test-timeout-unix branch June 30, 2024 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants