I have implemented an abstraction layer on top of sockets and would like to properly test it with cmocka. I have functions like request_thingie_from_server() and serve_thingie_for_client() that include "object" serialization so it would be important to test all the layers of the implementation. An implementation for a single function in the API might also include several invocations of send(), recv() et al.
I've previously done this by setting up two threads, one for the server and one for the client, that can then each handle their own side and as the other end always knows what to expect the received data can be compared to some reference result. Using threads for this like that is however quite a heavy weight solution (IMO at least) and I was hoping I could replace this with a lighter single threaded one (and thought cmocka might be a good tool to use for achieving this).
What is the best way to implement tests for this kind of testing with cmocka? Do you wrap the send() and recv() functions or how would you approach this?
Aucun commentaire:
Enregistrer un commentaire