Unit tests for message builder/parsers
Aleksander Morgado
aleksander at aleksander.es
Sun Nov 9 09:44:00 PST 2014
Hey,
I've just pushed to git master some basic support to setup unit tests
to check that the request builders and response/indication parsers do
what they're supposed to do. You can check a sample test here, which
checks the DMS Get IDs messages (more in the same file):
http://cgit.freedesktop.org/libqmi/tree/src/libqmi-glib/test/test-generated.c#n29
As we don't expose the message builder/parser methods in the libqmi
API, I ended up doing something very similar to what we do in
ModemManager for system tests, but using the qmi-proxy as dummy
endpoint. In a nutshell, we create a QmiDevice which tries to connect
to a specific proxy path, and we also launch an extra thread with an
abstract socket listener in that same proxy path. So, there is no
proxy at the end, and we just have an endpoint which receives the
requests from the QmiDevice, and which we use to return the predefined
responses, which we then also parse in the test. The basic testing
support is here:
http://cgit.freedesktop.org/libqmi/tree/src/libqmi-glib/test/test-fixture.c
http://cgit.freedesktop.org/libqmi/tree/src/libqmi-glib/test/test-port-context.c
It's really not a unit test any more... i.e. not just a memcmp() of
the built message vs the expected message, but it serves the purpose.
Plus we test some proxy communication bits as well :)
Cheers,
--
Aleksander
https://aleksander.es
More information about the libqmi-devel
mailing list