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 1 : 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 1 : _cleanup_(manager_freep) Manager *m = NULL; 15 : 16 1 : assert_se(manager_new(&m) == 0); 17 : 18 1 : assert_se(!m->have_fallbacks); 19 1 : assert_se(manager_parse_server_string(m, SERVER_FALLBACK, NTP_SERVERS) == 0); 20 1 : assert_se(m->have_fallbacks); 21 1 : assert_se(manager_parse_fallback_string(m, NTP_SERVERS) == 0); 22 : 23 1 : assert_se(manager_parse_server_string(m, SERVER_SYSTEM, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); 24 1 : assert_se(manager_parse_server_string(m, SERVER_FALLBACK, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); 25 1 : assert_se(manager_parse_server_string(m, SERVER_LINK, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); 26 1 : } 27 : 28 1 : int main(int argc, char **argv) { 29 1 : test_setup_logging(LOG_DEBUG); 30 : 31 1 : test_manager_parse_string(); 32 : 33 1 : return 0; 34 : }