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

Add hal::mock::stall_detector #42

Open
kammce opened this issue Jul 8, 2024 · 1 comment
Open

Add hal::mock::stall_detector #42

kammce opened this issue Jul 8, 2024 · 1 comment

Comments

@kammce
Copy link
Member

kammce commented Jul 8, 2024

It should look like this:

hal::mock::stall_detector detector(10ms);

// Do the actions that may cause a stall to occur like polling a register or waiting a duration of time.
detector.operation_finished();

The stall detector should spawn a thread that waits the amount of time specified in the constructor. That thread should throw an exception if the operation_finished() has not been called in the amount of time specified. That thrown exception object is not accessible by the rest of the code ensuring that it terminates the test. It would also be good to take a std::source_location as well in order for the developer to know where the deadlock occurred in the code. Maybe even a stack trace as well from the termination site. The destructor should join the thread.

@kammce
Copy link
Member Author

kammce commented Jul 8, 2024

Should replace the kind of code hand written here:

https://github.com/libhal/libhal-soft/blob/main/tests/atomic_spin_lock.test.cpp#L132-L162

@kammce kammce transferred this issue from libhal/libhal-mock Nov 30, 2024
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

No branches or pull requests

1 participant