Contributing PowerDNS tests: unit tests

May 7, 2013

Each and every PowerDNS change is tested by our Jenkins continuous integration setup, as hosted on The more tests we have, the more valuable this setup becomes, and in this post you can find easy to follow instructions on how to contribute unit tests.

Our automated testing consists of two parts: regression-tests and unit tests. The regression tests stress full operational scenarios, with actually running PowerDNS binaries being queried for records, doing AXFRs, signing records, the works. We exercise hundreds of scenarios this way.

In addition, we run ‘unit tests’ which stress out particular pieces of code, so that we know that they do what we think they do. Both of these testing strategies (‘whole binary’, ‘component’) have their merits. This post is about adding unit tests.

Forking the repository

Step one is to fork PowerDNS via our GitHub repository. This requires a GitHub account. Forking is explained here: After you’ve forked us, clone your fork & create a branch for your work:

$ git clone
$ cd pdns
$ git checkout -b Base64UnitTest

Next, make sure that you meet the basic dependencies for building PowerDNS. On Debian 7, we have verified that “apt-get install autoconf automake bison flex g++ libboost-all-dev libtool make pkg-config ragel" does the job.

Then run:

$ cd pdns
$ ./bootstrap
$ ./configure --with-modules="" --enable-unit-tests --without-lua
$ make

This will generate PowerDNS binaries and libraries, allowing us to build and run the ‘testrunner’:

$ cd pdns
$ make testrunner
$ ./testrunner
Running 9 test cases...
*** No errors detected

Nine tests is not enough by far, so let’s go about adding a new one. PowerDNS uses the Boost Unit Test framework, and by convention all test files are called ‘’. So, to add a test for, we create ‘’:

#include "base64.hh"
#include <boost/test/unit_test.hpp>
// tests go here

Next, add ‘’ to the testrunner_SOURCES variable in, re-run bootstrap and configure, and run ‘make testrunner’.  If we now actually execute our new testrunner, it still says ‘Running 9 testcases’, and to fix this, we’ll actually need to hook up a testcase (where we said // tests go here):

BOOST_AUTO_TEST_CASE(test_Base64_Roundtrip) {
    std::string before("Some Random String"), after;
    std::string encoded = Base64Encode(before);
    B64Decode(encoded, after);
    BOOST_CHECK_EQUAL(before, after);

And if we now rebuild testrunner & run it, it does indeed report 10 tests that passed! Within the PowerDNS Jenkins framework, testrunner is called with parameters that make it emit the status of each test as XML, which is then displayed visually on

Now that we’ve built a working test & hooked it up, we need to submit it to GitHub so that we over at PowerDNS can integrate your work at the touch of a button:

$ git add
$ git commit -a -m "create and hook up base64 tests"
$ git push origin Base64UnitTest

Your  code is at GitHub now, so head over there and go to your fork (in our example, this would be

There you will find a panel that lists “Your recently pushed branches”, including Base64UnitTest. You can press ‘compare’ to see that it indeed matches what you did, and then press the “Pull Request” button. This allows you to describe your work, and it pays to spend some time on this as it makes our decision to merge your fork easier. Once the description & title are ok, press submit.

Quite soon you should be getting feedback that your test is now part of each and every PowerDNS build!

About the author

Bert Hubert

Bert Hubert

Principal, PowerDNS

Related Articles

PowerDNSSEC Available For Testing!

Dear PowerDNS people, On you will find the newest version of PowerDNS with DNSSEC...

Bert Hubert 04/5/10

PowerDNS 2.x End of Life Statement

PowerDNS Authoritative Server 2.9.22 was released more than 6 years ago, in January 2009. Because of its immense and durable...

Peter van Dijk 05/6/15

Some good news on

Way way back in the history of PowerDNS, we bought the full suite of domain names for our new company:,...

Bert Hubert 10/4/16

On PowerDNS.COM and Express PowerDNS.NET Hosting by Trilab

Hi everybody, This post serves to clarify why we (‘PowerDNS.COM’) can’t help you with issues with Express PowerDNS.NET...

Bert Hubert 04/1/14