[Dnsmasq-discuss] [PATCH] dnsmasq unit tests!

Petr Menšík pemensik at redhat.com
Mon May 4 16:02:38 BST 2020


Hello everyone,

we have merged support for multiple IPv6 addresses to our release in
RHEL. We tried to ensure it does not break anything and we failed.

I made already some dnsmasq tests in separate repository [1], running in
network namespaces. There are two kinds of tests. Simple shell backed
bats tests in bash. bats and bash packages are required to run them.
Second kind are few tests in beakerlib [2], which is test framework used
in Fedora and RHEL testing. They exist and can test few things.

But now, I have accomplished creating few unit tests [3] for dnsmasq.
They are kind of hack, but they should allow basic testing of options
working. I used cmocka library. Dnsmasq is not very well prepared for
unit testing, but some parts can be tested. It is much easier to test
just code, without providing fake network configuration. I want to use
it to ensure no change in DHCP breaks expected behaviour. It is much
easier to prepare code changes than full fledged functional test,
emulating real request over network.

I would love if you could try it and tell me what you think about it. I
am attaching squished patch, separate commits are at our github [3]. If
someone would like to add some test, please create a pull request!

If you would like to try it:
git clone -b unittests https://github.com/InfrastructureServices/dnsmasq.git
cd dnsmasq
make
cd tests
make
./option_test
./dhcp_test

Since these are related to dnsmasq internals, I think merge to master
would be nice eventually. Some parts of dnsmasq should be adjusted for
easier testing, I have to prepare some changes. It might be starting
block to ensure new releases do not break existing functionality.

Any opinions would be appreciated too.

Cheers,
Petr

1. https://github.com/InfrastructureServices/dnsmasq-tests
2. https://github.com/beakerlib/beakerlib
3. https://github.com/InfrastructureServices/dnsmasq/tree/unittests/tests
-- 
Petr Menšík
Software Engineer
Red Hat, http://www.redhat.com/
email: pemensik at redhat.com
PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unittests.patch
Type: text/x-patch
Size: 22307 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20200504/847dbfb8/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20200504/847dbfb8/attachment-0001.sig>


More information about the Dnsmasq-discuss mailing list