-
Notifications
You must be signed in to change notification settings - Fork 318
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 unit tests for buffer processor (pa_process) code #779
Comments
Well put, I agree.
Phil and I have decided that we probably don't want to introduce such a dependency. I believe that Phil has some macros that will be sufficient. Personally I don't mind lightweight header-only frameworks such as Catch, but I don't know whether there's anything equivalent for C. I don't mind working on these tests, as I think it will help me get my head back in the code to help with resolving #770 / #772. If you have any ideas for specific unit tests feel free to add a bullet point list. |
Off the top of my head:
We'd potentially want to run some (most?) tests in a matrix of parameters:
Where it gets tricky is striking the right tradeoff between test suite readability/maintainability, test runtime, and coverage. Trying to test every possible combination of everything across every dimension, while valuable, might not be practical. Once we have the beginning of a test suite we could run it on CI and automatically fail CI if the tests fail - we can do this because the proposed test suite would have a clear PASS/FAIL result that is completely independent of the platform it's running on (and doesn't depend on scheduling/timing/hardware etc.). |
In #772 it was pointed out that the buffer processor code (i.e.
PaUtil_InitializeBufferProcessor()
and friends inpa_process.h
) could benefit from a test suite. Currently this code is not directly tested anywhere, although it is indirectly covered through any tests exercising host API streaming code (in particularpaloopback
).The API in
pa_process.h
would lend itself very well to unit tests, because it's a self-contained module with well-defined boundaries and behaviour, and no dependencies (so nothing to fake/mock). Also this module is extremely critical as it sits at the core of all host API streaming code, and its operation is quite non-trivial, so it seems like it would benefit a lot from the test coverage.In particular, tests could ensure that the stream callback is called appropriately and with the correct parameters, that the correct amount of data is read and written from/to host API buffers at the proper offsets (this would have caught #770) including wraparound, that sample format conversions are done appropriately, that interleaved/non-interleaved conversions are done appropriately, that the latency/timing reporting is correct, etc. for a variety of modes (input only, output only, full duplex) and buffer size combinations.
Best practice dictates this should be done through lots of small, focused tests. We might want to use some kind of unit testing framework for this.
The text was updated successfully, but these errors were encountered: