1. 30 Jul, 2019 8 commits
    • Michał Kępień's avatar
      Fix awk invocation in the "verify" system test · bb9c1654
      Michał Kępień authored
      Appending output of a command to the same file as the one that command
      is reading from is a dangerous practice.  It seems to have accidentally
      worked with all the awk implementations we have tested against so far,
      but for BusyBox awk, doing this may result in the input/output file
      being written to in an infinite loop.  Prevent this from happening by
      redirect awk output to a temporary file and appending its contents to
      the original file in a separate shell pipeline.
      bb9c1654
    • Michał Kępień's avatar
      Extend prerequisites for the "xfer" system test · b10d28d1
      Michał Kępień authored
      The Net::DNS Perl module needs the Digest::HMAC module to support TSIG.
      However, since the latter is not a hard requirement for the former, some
      packagers do not make Net::DNS depend on Digest::HMAC.  If Net::DNS is
      installed on a host but Digest::HMAC is not, the "xfer" system test
      breaks in a very hard-to-debug way (ans5 returns TSIG RRs with empty
      RDATA, which prevents TSIG-signed SOA queries and transfers from
      working).  Prevent this from happening by making the "xfer" system test
      explicitly require Digest::HMAC apart from Net::DNS.
      b10d28d1
    • Michał Kępień's avatar
      Make "digdelv" system test work with BusyBox sed · 266e3ed5
      Michał Kępień authored
      The BusyBox version of sed treats leading '\+' in a regular expression
      to be matched as a syntax error ("Repetition not preceded by valid
      expression"), which triggers false positives for the "digdelv" system
      test.  Make the relevant sed invocations work portably across all sed
      implementations by removing the leading backslash.
      266e3ed5
    • Michał Kępień's avatar
      Make "autosign" system test work with BusyBox awk · ad008f7d
      Michał Kępień authored
      The BusyBox version of awk treats some variables which other awk
      implementations consider to be decimal values as octal values.  This
      intermittently breaks key event interval calculations in the "autosign"
      system test, trigger false positives for it.  Prevent the problem from
      happening by stripping leading zeros from the affected awk variables.
      ad008f7d
    • Michał Kępień's avatar
      Tweak buffer sizes to prevent compilation warnings · 33844556
      Michał Kępień authored
      For some libc implementations, BUFSIZ is small enough (e.g. 1024 for
      musl libc) to trigger compilation warnings about insufficient size of
      certain buffers.  Since the relevant buffers are used for printing DNS
      names, increase their size to '(n + 1) * DNS_NAME_FORMATSIZE', where 'n'
      is the number of DNS names which are printed to a given buffer.  This
      results in somewhat arbitrary, albeit nicely-aligned and large enough
      buffer sizes.
      33844556
    • Michał Kępień's avatar
      Always include <errno.h> instead of <sys/errno.h> · b5cd1460
      Michał Kępień authored
      Including <sys/errno.h> instead of <errno.h> raises a compiler warning
      when building against musl libc.  Always include <errno.h> instead of
      <sys/errno.h> to prevent that compilation warning from being triggered
      and to achieve consistency in this regard across the entire source tree.
      b5cd1460
    • Michał Kępień's avatar
      Unify header ordering in unit tests · 5381ac0f
      Michał Kępień authored
      Make sure all unit tests include headers in a similar order:
      
       1. Three headers which must be included before <cmocka.h>.
       2. System headers.
       3. UNIT_TESTING definition, followed by the <cmocka.h> header.
       4. libisc headers.
       5. Headers from other BIND libraries.
       6. Local headers.
      
      Also make sure header file names are sorted alphabetically within each
      block of #include directives.
      5381ac0f
    • Michał Kępień's avatar
      Include <sched.h> where necessary for musl libc · 59528d0e
      Michał Kępień authored
      All unit tests define the UNIT_TESTING macro, which causes <cmocka.h> to
      replace malloc(), calloc(), realloc(), and free() with its own functions
      tracking memory allocations.  In order for this not to break
      compilation, the system header declaring the prototypes for these
      standard functions must be included before <cmocka.h>.
      
      Normally, these prototypes are only present in <stdlib.h>, so we make
      sure it is included before <cmocka.h>.  However, musl libc also defines
      the prototypes for calloc() and free() in <sched.h>, which is included
      by <pthread.h>, which is included e.g. by <isc/mutex.h>.  Thus, unit
      tests including "dnstest.h" (which includes <isc/mem.h>, which includes
      <isc/mutex.h>) after <cmocka.h> will not compile with musl libc as for
      these programs, <sched.h> will be included after <cmocka.h>.
      
      Always including <cmocka.h> after all other header files is not a
      feasible solution as that causes the mock assertion macros defined in
      <isc/util.h> to mangle the contents of <cmocka.h>, thus breaking
      compilation.  We cannot really use the __noreturn__ or analyzer_noreturn
      attributes with cmocka assertion functions because they do return if the
      tested condition is true.  The problem is that what BIND unit tests do
      is incompatible with Clang Static Analyzer's assumptions: since we use
      cmocka, our custom assertion handlers are present in a shared library
      (i.e. it is the cmocka library that checks the assertion condition, not
      a macro in unit test code).  Redefining cmocka's assertion macros in
      <isc/util.h> is an ugly hack to overcome that problem - unfortunately,
      this is the only way we can think of to make Clang Static Analyzer
      properly process unit test code.  Giving up on Clang Static Analyzer
      being able to properly process unit test code is not a satisfactory
      solution.
      
      Undefining _GNU_SOURCE for unit test code could work around the problem
      (musl libc's <sched.h> only defines the prototypes for calloc() and
      free() when _GNU_SOURCE is defined), but doing that could introduce
      discrepancies for unit tests including entire *.c files, so it is also
      not a good solution.
      
      All in all, including <sched.h> before <cmocka.h> for all affected unit
      tests seems to be the most benign way of working around this musl libc
      quirk.  While quite an ugly solution, it achieves our goals here, which
      are to keep the benefit of proper static analysis of unit test code and
      to fix compilation against musl libc.
      59528d0e
  2. 29 Jul, 2019 2 commits
    • Michał Kępień's avatar
      Merge branch... · 03de3419
      Michał Kępień authored
      Merge branch 'michal/filter-aaaa-system-test-make-root-hints-consistent-with-authoritative-data' into 'master'
      
      "filter-aaaa" system test: make root hints consistent with authoritative data
      
      See merge request !2057
      03de3419
    • Michał Kępień's avatar
      Make root hints consistent with authoritative data · c19ebde1
      Michał Kępień authored
      Resolvers in the "filter-aaaa" system test are configured with a single
      root hint: "ns.rootservers.net", pointing to 10.53.0.1.  However,
      querying ns1 for "ns.rootservers.net" results in NXDOMAIN answers.
      Since the TTL for the root hint is set to 0, it may happen that a
      resolver's ADB will be asked to return any known addresses for
      "ns.rootservers.net", but it will only have access to a cached NXDOMAIN
      answer for that name and an expired root hint, which will result in a
      resolution failure, triggering a false positive for the "filter-aaaa"
      system test.  Prevent this from happening by making all the root hints
      consistent with authoritative data served by ns1.
      c19ebde1
  3. 26 Jul, 2019 4 commits
  4. 25 Jul, 2019 8 commits
  5. 23 Jul, 2019 18 commits