1
0
mirror of https://frontier.innolan.net/rainlance/c-ares.git synced 2025-11-21 12:39:54 +00:00
Commit Graph

1695 Commits

Author SHA1 Message Date
830e8fe2b3 test: Disable tests that manipulate env on Windows 2016-02-02 10:13:48 +00:00
d3bccff740 test: Move file lists into Makefile.inc
In preparation for a Win32 build of the test suite.
2016-02-02 10:13:48 +00:00
9edf9411c7 test: Add a simple multi-server test
Check rotate option does something
2016-02-02 10:13:48 +00:00
d448d6604f test: Allow for multiple mock servers
- Update the MockServer to allow separate specification of
   UDP and TCP ports
 - Have an array of mock servers listening on consecutive
   sets of ports.
 - Rename Process(fd) to ProcessFD(fd) to avoid confusion.
 - Initialize channel by using the new ares_set_servers_ports()
   entrypoint, so multiple ports on the same loopback address
   can be used.
2016-02-02 10:13:48 +00:00
92656bcc82 test: Update test for set/get_servers variants
Ports are significant in the _ports_ variant functions, so update test to cope.
2016-02-02 10:13:48 +00:00
3231480a85 test: Make GetNameServers() utility function port-aware
Also make it generally available.
2016-02-02 10:13:48 +00:00
e26a678f26 test: more testing, including of internal static functions 2016-02-02 10:13:48 +00:00
25adcc413e test: more tests, especially fallback processing
- Make mock server listen on UDP + TCP in parallel.
 - Test UDP->TCP fallback on truncation
 - Test EDNS->no-EDNS fallback
 - Test some environment init options
 - Test nonsense reply

test: short response
2016-02-02 10:13:48 +00:00
a05f240dea test: more tests, particularly of initialization 2016-02-02 10:13:48 +00:00
83839fde7a test: Run mock tests over both TCP and UDP
With the exception of a few tests that make use of the timed
retry aspect of UDP.
2016-02-02 10:13:48 +00:00
0c423efd78 test: Run mock tests over both IPv4 and IPv6 2016-02-02 10:13:48 +00:00
0ef56333a0 test: Add more tests for edge cases 2016-02-02 10:13:48 +00:00
ce3f896572 test: more nooks and crannies of pton functions 2016-02-02 10:13:48 +00:00
f939efe7df test: More tests for PTR parsing 2016-02-02 10:13:48 +00:00
a2c5b1d378 test: Use of HOSTALIAS environment variable 2016-02-02 10:13:48 +00:00
834c98e9d9 test: Add RAII utility classes for testing
- TempFile holds specific contents
 - EnvValue sets an environment variable
2016-02-02 10:13:48 +00:00
693e566b66 test: More search domain scenarios 2016-02-02 10:13:47 +00:00
3ce586feb7 test: Remove duplicate flags from Makefile.am 2016-02-02 10:13:47 +00:00
6589ebfd6a test: Make test code leak-free 2016-02-02 10:13:47 +00:00
4a09121923 test: More tests
- test use of sortlist
 - test gethostbyname(AF_UNSPEC)
2016-02-02 10:13:47 +00:00
f2ae5d72da test: Test ares_gethostbyname_file() 2016-02-02 10:13:47 +00:00
0c03bee6ed test: Add more tests of ares_getnameinfo() 2016-02-02 10:13:47 +00:00
ffc7c52656 test: Tweak tests, add alloc failure test 2016-02-02 10:13:47 +00:00
e3434ef33f test: Test init with options 2016-02-02 10:13:47 +00:00
a48447ee27 test: More tests
- ares_inet_net_pton() variants
 - ares_getsock() variants
2016-02-02 10:13:47 +00:00
f9b9817d1d test: Expose ProcessWork() function 2016-02-02 10:13:47 +00:00
c778f0136b test: More parsing tests
Including:
 - Split each parse function test set out into separate files.
 - Add an allocation failure test for each parsing function.
 - Add error check test for each parsing function.
2016-02-02 10:13:47 +00:00
79dc327a2d test: Add various additional tests 2016-02-02 10:13:47 +00:00
5da3201a05 test: More tests
Include tests of internal functions, based on the value of the
CARES_SYMBOL_HIDING macro; need to configure the library with
--disable-symbol-hiding to enable these tests.
2016-02-02 10:13:47 +00:00
3907b6dc68 test: Allow command line override of mock server port 2016-02-02 10:13:47 +00:00
2aa07c7d02 test: Add README.md documentation 2016-02-02 10:13:47 +00:00
b651f825d6 test: Temporarily avoid latest Python requests package
Currently get error from Travis on this install step, and downgrading one
version appears to fix the problem.

"Could not find any downloads that satisfy the requirement pyOpenSSL>=0.13
(from requests[security])"
2016-02-02 10:13:47 +00:00
72555b6cad test: Add AppVeyor config file for Windows build 2016-02-02 10:13:47 +00:00
4a4f875c5a test: Add configuration for a Travis build
Cover Linux & OSX on the container infrastructure, but install
a later G++ to satisfy the tests' need for C++11.

Use a build matrix to include a variety of build variants:
 - ASAN
 - UBSAN
 - LSAN
 - Coverage via coveralls.io

test: invoke ASAN and coverage in Travis build

Also shift to use explicit build matrix

test: Use coveralls.io for coverage tracking

test: Add a build with UBSAN

Also expand and re-order the setting of environment variables
for easier modification.

test: Add LSAN build to Travis config
2016-02-02 10:13:47 +00:00
af3ee9a8ba test: Add initial unit tests for c-ares library
The tests are written in C++11, using the GoogleTest and GoogleMock
frameworks.  They have their own independent autoconf setup, so that
users of the library need not have a C++ compiler just to get c-ares
working (however, the test/configure.ac file does assume the use of
a shared top-level m4/ directory).  However, this autoconf setup has
only been tested on Linux and OSX so far.

Run with "./arestest", or "./arestest -v" to see extra debug info.
The GoogleTest options for running specific tests are also
available (e.g. "./arestest --gtest_filter=*Live*").

The tests are nowhere near complete yet (currently hitting around
60% coverage as reported by gcov), but they do include examples
of a few different styles of testing:

 - There are live tests (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.

 - There a few mock tests (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.

    - To make this generation/injection easier, the dns-proto.h file
      includes C++ helper classes for building DNS packets.

 - Other library entrypoints that don't require network activity
   (e.g. ares_parse_*_reply) are tested directly.

 - There are few tests of library-internal functions that are not
   normally visible to API users (in ares-test-internal.cc).

 - A couple of the tests use a helper method of the test fixture to
   inject memory allocation failures, using the earlier change to the
   library to allow override of malloc/realloc/free.

 - There is also an entrypoint to allow Clang's libfuzzer to drive
   the packet parsing code in ares_parse_*_reply, together with a
   standalone wrapper for it (./aresfuzz) to allow use of afl-fuzz
   for further fuzz testing.
2016-02-02 10:13:46 +00:00
148b6e93b9 test: Add local copy of GoogleMock/GoogleTest 1.7.0
Don't check in gtest/m4 files, as they are unused and interfere
with the top-level configure process.
2016-02-02 10:13:46 +00:00
59b3f81ab4 doc: Show build badges in README.md
Note that these URLs will need to be updated if/when the test branch
gets pulled into the master repo/branch.
2016-02-02 10:13:46 +00:00
5f59b88431 doc: Convert README to README.md
Gives better display on GitHub
2016-02-02 10:13:46 +00:00
b2dbc698ea doc: Update in preparation for next release
Assume 1.11.0 is next (as there are various API additions).
Also add myself to AUTHORS.
2016-02-02 10:13:46 +00:00
ce1ea79943 build: Allow header compilation by Windows C++ compiler 2016-02-02 10:13:46 +00:00
8042524c70 build: Expose whether symbol hiding is on
Adding the CARES_SYMBOL_HIDING definition allows the test suite to
detect whether internal symbols are available or not.
2016-02-02 10:13:46 +00:00
ace90cce05 build: Add autoconf macros for C++11 code using pthreads
Pull in testing macros from the GNU autoconf archive to allow
configure scripts to test for and setup use of a C++11 compiler
(AX_CXX_COMPILE_STDCXX_11) and the pthreads library (AX_PTHREAD).

Note that these macros are not used by the main library autoconf,
just by the tests (which share the same m4/ directory).
2016-02-02 10:13:46 +00:00
1b6905cc7f build: Add a code coverage option
Configure with:
  ./configure --enable-code-coverage
Show coverage output with:
  make code-coverage-capture

Built on m4/ax_code_coverage.m4 from the GNU autoconf archive
to provide the macros to check for presence of gcov + lcov;
upstream macro modified to:
 - Remove use of $(AM_DEFAULT_VERBOSITY) , as earlier versions of
   autoconf (such as the one used by default on Travis) do not have this.
 - Rather than automatically defining CODE_COVERAGE_RULES to be a set
   of makefile rules that use ifeq/endif (which is GNU make-specific),
   instead only define CODE_COVERAGE_RULES if coverages is turned on,
   and in that case don't use conditionals in the makefile.
2016-02-02 10:13:46 +00:00
7972adc5d7 api: Add entrypoints to allow use of per-server ports
Add user-visible entrypoints ares_{get,set}_servers_ports(3), which
take struct ares_addr_port_node rather than struct ares_addr_node.
This structure includes a UDP and TCP port number; if this is set
to zero, the channel-wide port values are used as before.

Similarly, add a new ares_set_servers_ports_csv(3) entrypoint, which
is analogous to ares_set_servers(3) except it doesn't ignore any
specified port information; instead, any per-server specified port
is used as both the UDP and TCP port for that server.

The internal struct ares_addr is extended to hold the UDP/TCP ports,
stored in network order, with the convention that a value of zero
indicates that the channel-wide UDP/TCP port should be used.

For the internal implementation of ares_dup(3), shift to use the
_ports() version of the get/set functions, so port information is
transferred correctly to the new channel.

Update manpages, and add missing ares_set_servers_csv to the lists
while we're at it
2016-02-02 10:13:46 +00:00
06d0f72e54 api: Add ares_set_sortlist(3) entrypoint
Allow explicit configuration of the channel's sortlist, by
specifying a string in the same format as the equivalent
/etc/resolv.conf option.

This allows library users to perform the same configuration
that is available via /etc/resolv.conf, but without needing
to change that file.
2016-02-02 10:05:07 +00:00
f1bcfa1122 api: Allow injection of user-specified malloc/free functions
Add a new ares_library_init_mem() initialization function for the
library which allows the library user to specify their own malloc,
realloc & free equivalents for use library-wide.

Store these function pointers in library-wide global variables,
defaulting to libc's malloc(), realloc() and free().

Change all calls to malloc, realloc and free to use the function pointer
instead.  Also ensure that ares_strdup() is always available
(even if the local environment includes strdup(3)), and change the
library code to always use it.

Convert calls to calloc() to use ares_malloc() + memset
2016-02-02 10:05:07 +00:00
d493e9b17c api: Add option to expose some internal functions
Purely for testing, add --enable-expose-statics option to configure
which converts some static internal functions to be externally visible.
2016-02-02 10:05:07 +00:00
b619d13693 api: Expose the ares_library_initialized() function 2016-02-02 10:05:07 +00:00
4ad3111a49 ahost: Allow repeated -s <domain> options
This also removes a potential leak where later -s options would
replace earlier ones without freeing the relevant string.
2016-02-02 10:05:07 +00:00
87ff25049c Mark unhittable lines
Add comments for the benefit of the lcov tool, marking
lines that cannot be hit.  Typically these are fall-back
protection arms that are already covered by earlier checks,
and so it's not worth taking out the unhittable code (in case
someone changes the code between the two places in future).
2016-02-02 10:05:07 +00:00