On Mon, May 04, 2020 at 05:02:38PM +0200, Petr Menšík wrote:
> 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 think it is great to have unittests.


> 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.

<quote from="Harry Callahan" skipped="yes"/>



 
> 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

Be aware that I'm a "sysadmin",  not a programmer ...


> >From 9395cc84f93c63573ba28e4e349c44adb5dbb34d Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemen...@redhat.com>
> Date: Mon, 4 May 2020 16:26:17 +0200
> Subject: [PATCH] Create unittests with dhcp and option tests
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> diff --git a/Makefile b/Makefile
> index 78e25f0..e390745 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -24,7 +24,7 @@ MANDIR        = $(PREFIX)/share/man
>  LOCALEDIR     = $(PREFIX)/share/locale
>  BUILDDIR      = $(SRC)
>  DESTDIR       = 
> -CFLAGS        = -Wall -W -O2
> +CFLAGS        = -Wall -W -O2 -ggdb

How does that effect the regular builds?



>  LDFLAGS       = 
>  COPTS         = 
>  RPM_OPT_FLAGS = 

      ....


<screenshot says="stappers takes a deeper dive">
stappers@alpaca:~/src/dnsmasq
$ git am unittests.patch 
Patch format detection failed.
stappers@alpaca:~/src/dnsmasq
$ git am < unittests.patch 
Applying: Create unittests with dhcp and option tests
/home/stappers/src/dnsmasq/.git/rebase-apply/patch:469: trailing
whitespace.
  
/home/stappers/src/dnsmasq/.git/rebase-apply/patch:535: trailing
whitespace.
  /* Min buffer size: we check after adding each record, so there must
 * be 
/home/stappers/src/dnsmasq/.git/rebase-apply/patch:538: trailing
whitespace.
     This might be increased is EDNS packet size if greater than the
minimum. */ 
/home/stappers/src/dnsmasq/.git/rebase-apply/patch:541: trailing
whitespace.
  
/home/stappers/src/dnsmasq/.git/rebase-apply/patch:610: trailing
whitespace.
size_t answer_auth(struct dns_header *header, char *limit, size_t qlen,
time_t now, union mysockaddr *peer_addr, 
warning: squelched 1 whitespace error
warning: 6 lines add whitespace errors.
stappers@alpaca:~/src/dnsmasq
$ 
</screenshot>

To be continued ...

_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to