To declare coLunacyDNS stable, I first had to declare it feature complete: I will add no more features to coLunacyDNS (for now). Instead, I tested coLunacyDNS to make it stable.
So, I began testing coLunacyDNS, with a handful of informal tests to make sure it ran correctly. It did. But, then, I asked myself this: How can I see how many of coLunacyDNS’s lines we are running to make sure we are testing all of the code?
The tool to use with C language programs to see which lines we are testing against is gcov. There was no need for me to find and install gcov; it was included when I installed GCC on my CentOS 8 development system.
Some points about gcov:
Here’s a simple example of gcov in action:
$ cat > foo.c
#include <stdio.h>
int main() {
puts("Hello, world!");
return 0;
}
$ gcc -o foo foo.c -fprofile-arcs -ftest-coverage
$ ./foo
Hello, world!
$ gcov foo.c
File 'foo.c'
Lines executed:100.00% of 3
Creating 'foo.c.gcov'
$ cat foo.c.gcov
-: 0:Source:foo.c
-: 0:Graph:foo.gcno
-: 0:Data:foo.gcda
-: 0:Runs:1
-: 0:Programs:1
-: 1:#include <stdio.h>
-: 2:
1: 3:int main() {
1: 4: puts("Hello, world!");
1: 5: return 0;
-: 6:}
If a line is not run, the .gcov file will have something that looks like this:
#####: 123: foo = bar;
==coLunacyDNS’s test coverage==
As of the MaraDNS 3.5.0015 release, coLunacyDNS has 92.73% test coverage. Some notes:
My goal is to get 100% test coverage, provided I #ifdef out code which can not be readily tested.
MaraDNS is available, as always, on its download page:
https://maradns. samiam. org/ download. html
Did you know that all of my blog entries are available in a free to download eBook at https://www.samiam.org/blog/ebooks.html.