• Home
Name Date Size #Lines LOC

..--

fuzzinput/22-Oct-2025-

fuzznames/22-Oct-2025-8245

CMakeLists.txtD22-Oct-20254.3 KiB11089

Makefile.amD22-Oct-20251.7 KiB4428

Makefile.inD22-Oct-2025100.6 KiB1,6851,494

Makefile.incD22-Oct-2025990 4335

Makefile.m32D22-Oct-20252.1 KiB6739

Makefile.msvcD22-Oct-202511.3 KiB328174

README.mdD22-Oct-20253.4 KiB7662

ares-fuzz.cD22-Oct-20252.9 KiB9955

ares-test-ai.hD22-Oct-20252.6 KiB9253

ares-test-fuzz-name.cD22-Oct-20252.6 KiB8036

ares-test-fuzz.cD22-Oct-202510.7 KiB317239

ares-test-init.ccD22-Oct-202525 KiB726571

ares-test-internal.ccD22-Oct-202572.5 KiB1,8511,515

ares-test-live.ccD22-Oct-202526.5 KiB724583

ares-test-main.ccD22-Oct-20254.1 KiB11572

ares-test-misc.ccD22-Oct-202523.3 KiB660508

ares-test-mock-ai.ccD22-Oct-202548.4 KiB1,2811,074

ares-test-mock-et.ccD22-Oct-202564.5 KiB1,6771,353

ares-test-mock.ccD22-Oct-202596.7 KiB2,5942,087

ares-test-ns.ccD22-Oct-20257.2 KiB230169

ares-test-parse-a.ccD22-Oct-202514.5 KiB386307

ares-test-parse-aaaa.ccD22-Oct-20259 KiB228170

ares-test-parse-caa.ccD22-Oct-20258.3 KiB154108

ares-test-parse-mx.ccD22-Oct-20255.7 KiB170114

ares-test-parse-naptr.ccD22-Oct-20256.5 KiB177124

ares-test-parse-ns.ccD22-Oct-20255.4 KiB14897

ares-test-parse-ptr.ccD22-Oct-202511.9 KiB286222

ares-test-parse-soa-any.ccD22-Oct-20255.2 KiB14092

ares-test-parse-soa.ccD22-Oct-20255 KiB13789

ares-test-parse-srv.ccD22-Oct-202512 KiB317242

ares-test-parse-txt.ccD22-Oct-202511.3 KiB328251

ares-test-parse-uri.ccD22-Oct-202511.9 KiB317242

ares-test-parse.ccD22-Oct-20256.7 KiB213166

ares-test.ccD22-Oct-202540.1 KiB1,3181,057

ares-test.hD22-Oct-202528.6 KiB908663

ares_queryloop.cD22-Oct-20254.9 KiB180127

dns-dump.ccD22-Oct-20252 KiB6633

dns-proto-test.ccD22-Oct-20254.9 KiB157115

dns-proto.ccD22-Oct-202523.9 KiB803702

dns-proto.hD22-Oct-202512 KiB433328

fuzzcheck.shD22-Oct-2025219 83

README.md

1c-ares Unit Test Suite
2======================
3
4This directory holds unit tests for the c-ares library.  To build the tests:
5
6 - Build the main c-ares library first, in the directory above this.  To
7   enable tests of internal functions, configure the library build to expose
8   hidden symbols with `./configure --disable-symbol-hiding`.
9 - Generate a `configure` file by running `autoreconf -iv` (which requires
10   a local installation of
11   [autotools](https://www.gnu.org/software/automake/manual/html_node/Autotools-Introduction.html)).
12 - `./configure`
13 - `make`
14 - Run the tests with `./arestest`, or `./arestest -v` for extra debug info.
15
16Points to note:
17
18 - The tests are written in C++11, and so need a C++ compiler that supports
19   this.  To avoid adding this as a requirement for the library, the
20   configuration and build of the tests is independent from the library.
21 - The tests include some live queries, which will fail when run on a machine
22   without internet connectivity.  To skip live tests, run with
23   `./arestest --gtest_filter=-*.Live*`.
24 - The tests include queries of a mock DNS server.  This server listens on port
25   5300 by default, but the port can be changed with the `-p 5300` option to
26   `arestest`.
27
28
29Test Types
30----------
31
32The test suite includes various different types of test.
33
34 - There are live tests (`ares-test-live.cc`), which assume that the
35   current machine has a valid DNS setup and connection to the
36   internet; these tests issue queries for real domains but don't
37   particularly check what gets returned.  The tests will fail on
38   an offline machine.
39 - There are some mock tests (`ares-test-mock.cc`) that set up a fake DNS
40   server and inject its port into the c-ares library configuration.
41   These tests allow specific response messages to be crafted and
42   injected, and so are likely to be used for many more tests in
43   future.
44    - To make this generation/injection easier, the `dns-proto.h`
45      file includes C++ helper classes for building DNS packets.
46 - Other library entrypoints that don't require network activity
47   (e.g. `ares_parse_*_reply`) are tested directly.
48 - A couple of the tests use a helper method of the test fixture to
49   inject memory allocation failures, using a recent change to the
50   c-ares library that allows override of `malloc`/`free`.
51 - There are some tests of the internal entrypoints of the library
52   (`ares-test-internal.c`), but these are only enabled if the library
53   was configured with `--disable-symbol-hiding` and/or
54   `--enable-expose-statics`.
55 - There is also an entrypoint to allow Clang's
56   [libfuzzer](http://llvm.org/docs/LibFuzzer.html) to drive
57   the packet parsing code in `ares_parse_*_reply`, together with a
58   standalone wrapper for it (`./aresfuzz`) to allow use of command
59   line fuzzers (such as [afl-fuzz](http://lcamtuf.coredump.cx/afl/))
60   for further [fuzz testing](#fuzzing).
61
62
63Code Coverage Information
64-------------------------
65
66To generate code coverage information:
67
68 - Configure both the library and the tests with `./configure
69   --enable-code-coverage` before building. This requires the relevant code
70   coverage tools ([gcov](https://gcc.gnu.org/onlinedocs/gcc/Gcov.html),
71   [lcov](http://ltp.sourceforge.net/coverage/lcov.php)) to be installed locally.
72 - Run the tests with `test/arestest`.
73 - Generate code coverage output with `make code-coverage-capture` in the
74   library directory (i.e. not in `test/`).
75
76