This directory holds unit tests for the c-ares library. To build the tests:
./configure --disable-symbol-hiding
.configure
file by running autoreconf -iv
(which requires a local installation of autotools)../configure
make
./arestest
, or ./arestest -v
for extra debug info.Points to note:
./arestest --gtest_filter=-*.Live*
.-p 5300
option to arestest
.The test suite includes various different types of test.
ares-test-live.cc
), which assume that the current machine has a valid DNS setup and connection to the internet; these tests issue queries for real domains but don't particularly check what gets returned. The tests will fail on an offline machine.ares-test-mock.cc
) that set up a fake DNS server and inject its port into the c-ares library configuration. These tests allow specific response messages to be crafted and injected, and so are likely to be used for many more tests in future.dns-proto.h
file includes C++ helper classes for building DNS packets.ares_parse_*_reply
) are tested directly.malloc
/free
.ares-test-internal.c
), but these are only enabled if the library was configured with --disable-symbol-hiding
and/or --enable-expose-statics
.ares_parse_*_reply
, together with a standalone wrapper for it (./aresfuzz
) to allow use of command line fuzzers (such as afl-fuzz) for further fuzz testing.To generate code coverage information:
./configure --enable-code-coverage
before building. This requires the relevant code coverage tools (gcov, lcov) to be installed locally.test/arestest
.make code-coverage-capture
in the library directory (i.e. not in test/
).