How would one go about unit testing an atomic function that is part of an API? How can you guarantee that the atomicity of the function is actually being tested in time dependent situations like this? The system I am working with is inherently multithreaded with many real-time elements, and is written in C.
My first thought is to perhaps set up one or more threads that are set to try and modify the same data that the atomic function under test is operating on, then check to see if the resultant value of the data is different than expected. Is this a valid approach? Or am I missing an obvious solution to the problem?
Aucun commentaire:
Enregistrer un commentaire