LCOV - code coverage report
Current view: top level - resolve - test-resolved-packet.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 15 15 100.0 %
Date: 2019-08-23 13:36:53 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 14 71.4 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include "log.h"
       4                 :            : #include "resolved-dns-packet.h"
       5                 :            : #include "tests.h"
       6                 :            : 
       7                 :          4 : static void test_dns_packet_new(void) {
       8                 :            :         size_t i;
       9                 :          4 :          _cleanup_(dns_packet_unrefp) DnsPacket *p2 = NULL;
      10                 :            : 
      11         [ +  + ]:       2164 :         for (i = 0; i <= DNS_PACKET_SIZE_MAX; i++) {
      12                 :       2160 :                 _cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
      13                 :            : 
      14         [ -  + ]:       2160 :                 assert_se(dns_packet_new(&p, DNS_PROTOCOL_DNS, i, DNS_PACKET_SIZE_MAX) == 0);
      15                 :            : 
      16         [ +  - ]:       2160 :                 log_debug("dns_packet_new: %zu → %zu", i, p->allocated);
      17         [ -  + ]:       2160 :                 assert_se(p->allocated >= MIN(DNS_PACKET_SIZE_MAX, i));
      18                 :            : 
      19   [ +  +  +  + ]:       2160 :                 if (i > DNS_PACKET_SIZE_START + 10 && i < DNS_PACKET_SIZE_MAX - 10)
      20                 :         28 :                         i = MIN(i * 2, DNS_PACKET_SIZE_MAX - 10);
      21                 :            :         }
      22                 :            : 
      23         [ -  + ]:          4 :         assert_se(dns_packet_new(&p2, DNS_PROTOCOL_DNS, DNS_PACKET_SIZE_MAX + 1, DNS_PACKET_SIZE_MAX) == -EFBIG);
      24                 :          4 : }
      25                 :            : 
      26                 :          4 : int main(int argc, char **argv) {
      27                 :          4 :         test_setup_logging(LOG_DEBUG);
      28                 :            : 
      29                 :          4 :         test_dns_packet_new();
      30                 :            : 
      31                 :          4 :         return 0;
      32                 :            : }

Generated by: LCOV version 1.14