No Tsocket Unit tests? - Re: Samba | libcli:dns: SAMBA_INTERNAL DNS, set forwarder port (!2148)
uri at samba.org
Thu Sep 9 11:00:00 UTC 2021
On 9/9/21 8:16 AM, Matt Grant via samba-technical wrote:
> Hi Uri!
> Thank you for helping me while I drill into the tsocket library code.
> I have been working through things, and thought I should check to see if
> there are any unit of CI tests for the lib/tsocket code and I cannot find
> one single written test for that library.
> Please show me where these tests are if they do exist, otherwise I am
> asking questions about whether I should be proceeding to touch that library
> with new code for stability reasons, until a full test suite is written for
> it. I believe that should be a separate project covered under a different
> MR, not this one.
tsocket indeed is not tested as a library, as far as I can tell.
Historically Samba had torture tests (sending packets to a server and
observing the outcome), then blackbox tests (running command-line
utilities which interact with a server and observing he outcome), and
Python tests (calling C code via Python bindings). A few years ago we
finally added good-old unit tests with cmocka - this is good for testing
pure "stateless" functions such as in this case, and also allows mocking
where there are side effects and environmental dependencies.
Tsocket has been written in other times, and I think that in today's
standards, a new host:port parsing function is a prime candidate for
unit-testing, and the cmocka infrastructure should make that fairly
easy. I've already pointed at lib/util/tests/test_util_paths.c as a
I'm going to add this test myself to ease the burden a bit.
More information about the samba-technical