LCOV - code coverage report
Current view: top level - timesync - test-timesync.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: 8 16 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : /* Some unit tests for the helper functions in timesyncd. */
       4                 :            : 
       5                 :            : #include "log.h"
       6                 :            : #include "macro.h"
       7                 :            : #include "timesyncd-conf.h"
       8                 :            : #include "tests.h"
       9                 :            : 
      10                 :          4 : static void test_manager_parse_string(void) {
      11                 :            :         /* Make sure that NTP_SERVERS is configured to something
      12                 :            :          * that we can actually parse successfully. */
      13                 :            : 
      14                 :          4 :         _cleanup_(manager_freep) Manager *m = NULL;
      15                 :            : 
      16         [ -  + ]:          4 :         assert_se(manager_new(&m) == 0);
      17                 :            : 
      18         [ -  + ]:          4 :         assert_se(!m->have_fallbacks);
      19         [ -  + ]:          4 :         assert_se(manager_parse_server_string(m, SERVER_FALLBACK, NTP_SERVERS) == 0);
      20         [ -  + ]:          4 :         assert_se(m->have_fallbacks);
      21         [ -  + ]:          4 :         assert_se(manager_parse_fallback_string(m, NTP_SERVERS) == 0);
      22                 :            : 
      23         [ -  + ]:          4 :         assert_se(manager_parse_server_string(m, SERVER_SYSTEM, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0);
      24         [ -  + ]:          4 :         assert_se(manager_parse_server_string(m, SERVER_FALLBACK, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0);
      25         [ -  + ]:          4 :         assert_se(manager_parse_server_string(m, SERVER_LINK, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0);
      26                 :          4 : }
      27                 :            : 
      28                 :          4 : int main(int argc, char **argv) {
      29                 :          4 :         test_setup_logging(LOG_DEBUG);
      30                 :            : 
      31                 :          4 :         test_manager_parse_string();
      32                 :            : 
      33                 :          4 :         return 0;
      34                 :            : }

Generated by: LCOV version 1.14