[Dnsmasq-discuss] unittests

Petr Menšík pemensik at redhat.com
Tue Oct 5 22:11:58 UTC 2021

On 10/5/21 20:28, john doe wrote:
> On 10/5/2021 5:13 PM, Petr Menšík wrote:
>> Hey Geert,
>> I doubt unit tests would find that. Unit tests should test some
>> functions that they work correctly. My unit tests were just attempt to
>> make *some* tests, but just very basic. It was intended more to check
>> options parsing correctness and obvious breakages in these parts. There
>> is no function in dnsmasq, where you put "fake" incoming packet and it
>> would respond reply would look like this.
>> Unit tests usually require code like Lego, which uses parts of code to
>> prepare reply to a request. Then virtual responder can be made. Many
>> parts of dnsmasq are not ready for that. It provides no strong library,
>> which can replicate internal data processing. Response to a dns packet
>> is somehow hard to validate just from the code. cmocka library is a good
>> one for unit tests.
>> It would be beneficial to have also behavior tests. Which would start
>> dnsmasq with some parameters and use standard tools like dhclient or dig
> Those tools are not standards, for instance on OpenWRT.
> -- 
> John Doe

dig is quite standard thing for troubleshooting DNS. If it is not
available for OpenWRT, it should be fixed. I am bind9 maintainer too, it
might get surprising to me. For anything DNS related I would not write
tests without dig. I expect those tests would not be run on common
router. It should be run on some CI pipeline, which can install
environment with all dependencies and ensure tests are still passing.
Usually not even directly on developer's machine, if they modify
anything on the system.

dhclient is already abandoned by ISC, so good replacement able to make
DHCP requests would be nice. I don't know any better tool with support
for both IPv6 and IPv4, which can be used from scripts and would not
have to change system addresses. I know dhtest, which is nice piece. But
is IPv4 only AFAIK. Network Manager should have some DHCP client also,
but I am not sure we can borrow it without NM itself. Some lease utils
in contrib can do specialized things, but are no general dnsmasq
clients. I don't know good replacement, I am all ears if you do.

So if there are not all tools available on OpenWRT, we should be able to
skip such tests. It would be tested on different platforms with more
things available.

Any tools I proposed are open source and can be compiled almost on any
system just with some effort. If they have no existing packages yet on
some distributions, that could be fixed later. It is better to start



Petr Menšík
Software Engineer
Red Hat, http://www.redhat.com/
email: pemensik at redhat.com
PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB

More information about the Dnsmasq-discuss mailing list