|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| fuzzinput/ | | 22-Oct-2025 | - | | |
| fuzznames/ | | 22-Oct-2025 | - | 82 | 45 |
| CMakeLists.txt | D | 22-Oct-2025 | 4.3 KiB | 110 | 89 |
| Makefile.am | D | 22-Oct-2025 | 1.7 KiB | 44 | 28 |
| Makefile.in | D | 22-Oct-2025 | 100.6 KiB | 1,685 | 1,494 |
| Makefile.inc | D | 22-Oct-2025 | 990 | 43 | 35 |
| Makefile.m32 | D | 22-Oct-2025 | 2.1 KiB | 67 | 39 |
| Makefile.msvc | D | 22-Oct-2025 | 11.3 KiB | 328 | 174 |
| README.md | D | 22-Oct-2025 | 3.4 KiB | 76 | 62 |
| ares-fuzz.c | D | 22-Oct-2025 | 2.9 KiB | 99 | 55 |
| ares-test-ai.h | D | 22-Oct-2025 | 2.6 KiB | 92 | 53 |
| ares-test-fuzz-name.c | D | 22-Oct-2025 | 2.6 KiB | 80 | 36 |
| ares-test-fuzz.c | D | 22-Oct-2025 | 10.7 KiB | 317 | 239 |
| ares-test-init.cc | D | 22-Oct-2025 | 25 KiB | 726 | 571 |
| ares-test-internal.cc | D | 22-Oct-2025 | 72.5 KiB | 1,851 | 1,515 |
| ares-test-live.cc | D | 22-Oct-2025 | 26.5 KiB | 724 | 583 |
| ares-test-main.cc | D | 22-Oct-2025 | 4.1 KiB | 115 | 72 |
| ares-test-misc.cc | D | 22-Oct-2025 | 23.3 KiB | 660 | 508 |
| ares-test-mock-ai.cc | D | 22-Oct-2025 | 48.4 KiB | 1,281 | 1,074 |
| ares-test-mock-et.cc | D | 22-Oct-2025 | 64.5 KiB | 1,677 | 1,353 |
| ares-test-mock.cc | D | 22-Oct-2025 | 96.7 KiB | 2,594 | 2,087 |
| ares-test-ns.cc | D | 22-Oct-2025 | 7.2 KiB | 230 | 169 |
| ares-test-parse-a.cc | D | 22-Oct-2025 | 14.5 KiB | 386 | 307 |
| ares-test-parse-aaaa.cc | D | 22-Oct-2025 | 9 KiB | 228 | 170 |
| ares-test-parse-caa.cc | D | 22-Oct-2025 | 8.3 KiB | 154 | 108 |
| ares-test-parse-mx.cc | D | 22-Oct-2025 | 5.7 KiB | 170 | 114 |
| ares-test-parse-naptr.cc | D | 22-Oct-2025 | 6.5 KiB | 177 | 124 |
| ares-test-parse-ns.cc | D | 22-Oct-2025 | 5.4 KiB | 148 | 97 |
| ares-test-parse-ptr.cc | D | 22-Oct-2025 | 11.9 KiB | 286 | 222 |
| ares-test-parse-soa-any.cc | D | 22-Oct-2025 | 5.2 KiB | 140 | 92 |
| ares-test-parse-soa.cc | D | 22-Oct-2025 | 5 KiB | 137 | 89 |
| ares-test-parse-srv.cc | D | 22-Oct-2025 | 12 KiB | 317 | 242 |
| ares-test-parse-txt.cc | D | 22-Oct-2025 | 11.3 KiB | 328 | 251 |
| ares-test-parse-uri.cc | D | 22-Oct-2025 | 11.9 KiB | 317 | 242 |
| ares-test-parse.cc | D | 22-Oct-2025 | 6.7 KiB | 213 | 166 |
| ares-test.cc | D | 22-Oct-2025 | 40.1 KiB | 1,318 | 1,057 |
| ares-test.h | D | 22-Oct-2025 | 28.6 KiB | 908 | 663 |
| ares_queryloop.c | D | 22-Oct-2025 | 4.9 KiB | 180 | 127 |
| dns-dump.cc | D | 22-Oct-2025 | 2 KiB | 66 | 33 |
| dns-proto-test.cc | D | 22-Oct-2025 | 4.9 KiB | 157 | 115 |
| dns-proto.cc | D | 22-Oct-2025 | 23.9 KiB | 803 | 702 |
| dns-proto.h | D | 22-Oct-2025 | 12 KiB | 433 | 328 |
| fuzzcheck.sh | D | 22-Oct-2025 | 219 | 8 | 3 |
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