[bind10-dev] Coding guidelines and tests
Tomasz Mrugalski
tomasz at isc.org
Wed Oct 12 15:34:26 UTC 2011
Hi,
Current version of coding guidelines states that "Use 192.0.2.0/24 and
2001:db8::/32 for purposes like addresses used in test cases or examples
in documentation". Documentation purposes is ok, but definitely not tests.
Tests should be as broad as possible. For example in tests for DHCPv6
option that conveys IPv6 addresses, I check:
- :: (any address, a valid value that must be supported),
- ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff (to see if there are no
integer overflows),
- ff02::face:b00c (to see that multicast addresses are handled ok)
- and some other addresses to verify that tested code does not have
first 32 bits hardcoded to 2001:db8.
I propose removing suggestion that 2001:db8::/32 should be used in
tests. That class is for documentation only, not for tests. The same
hold true for 192.0.2.0/24.
Another thing that was pointed out in one of ticket reviews is that
there are more efficient ways of generating test data than plain uint8_t
array. That is true, but in my opinion more efficient is not always
suitable for test code. Tests should be as simple (read: error-proof) as
possible, no necessarily the most efficient. This is not production
code. I propose to add something along the lines of "In tests,
simplicity should be favored over efficient, but more complicated code."
to coding guidelines.
Tomek
More information about the bind10-dev
mailing list