]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
c6c1ba8f | 2 | /*** |
96b2fb93 | 3 | Copyright © 2017 Zbigniew Jędrzejewski-Szmek |
c6c1ba8f ZJS |
4 | ***/ |
5 | ||
6 | /* Some unit tests for the helper functions in timesyncd. */ | |
7 | ||
8 | #include "log.h" | |
9 | #include "macro.h" | |
10 | #include "timesyncd-conf.h" | |
11 | ||
12 | static void test_manager_parse_string(void) { | |
13 | /* Make sure that NTP_SERVERS is configured to something | |
14 | * that we can actually parse successfully. */ | |
15 | ||
16 | _cleanup_(manager_freep) Manager *m = NULL; | |
17 | ||
18 | assert_se(manager_new(&m) == 0); | |
19 | ||
20 | assert_se(!m->have_fallbacks); | |
21 | assert_se(manager_parse_server_string(m, SERVER_FALLBACK, NTP_SERVERS) == 0); | |
22 | assert_se(m->have_fallbacks); | |
23 | assert_se(manager_parse_fallback_string(m, NTP_SERVERS) == 0); | |
24 | ||
dcb37458 YW |
25 | assert_se(manager_parse_server_string(m, SERVER_SYSTEM, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); |
26 | assert_se(manager_parse_server_string(m, SERVER_FALLBACK, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); | |
27 | assert_se(manager_parse_server_string(m, SERVER_LINK, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); | |
c6c1ba8f ZJS |
28 | } |
29 | ||
30 | int main(int argc, char **argv) { | |
31 | log_set_max_level(LOG_DEBUG); | |
32 | log_parse_environment(); | |
33 | ||
34 | test_manager_parse_string(); | |
35 | ||
36 | return 0; | |
37 | } |