]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
c6c1ba8f ZJS |
2 | /*** |
3 | This file is part of systemd. | |
4 | ||
5 | Copyright 2017 Zbigniew Jędrzejewski-Szmek | |
6 | ||
7 | systemd is free software; you can redistribute it and/or modify it | |
8 | under the terms of the GNU Lesser General Public License as published by | |
9 | the Free Software Foundation; either version 2.1 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | systemd is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | Lesser General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Lesser General Public License | |
18 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
19 | ***/ | |
20 | ||
21 | /* Some unit tests for the helper functions in timesyncd. */ | |
22 | ||
23 | #include "log.h" | |
24 | #include "macro.h" | |
25 | #include "timesyncd-conf.h" | |
26 | ||
27 | static void test_manager_parse_string(void) { | |
28 | /* Make sure that NTP_SERVERS is configured to something | |
29 | * that we can actually parse successfully. */ | |
30 | ||
31 | _cleanup_(manager_freep) Manager *m = NULL; | |
32 | ||
33 | assert_se(manager_new(&m) == 0); | |
34 | ||
35 | assert_se(!m->have_fallbacks); | |
36 | assert_se(manager_parse_server_string(m, SERVER_FALLBACK, NTP_SERVERS) == 0); | |
37 | assert_se(m->have_fallbacks); | |
38 | assert_se(manager_parse_fallback_string(m, NTP_SERVERS) == 0); | |
39 | ||
40 | assert_se(manager_parse_server_string(m, SERVER_SYSTEM, "time1.foobar.com time2.foobar.com") == 0); | |
41 | assert_se(manager_parse_server_string(m, SERVER_FALLBACK, "time1.foobar.com time2.foobar.com") == 0); | |
42 | assert_se(manager_parse_server_string(m, SERVER_LINK, "time1.foobar.com time2.foobar.com") == 0); | |
43 | } | |
44 | ||
45 | int main(int argc, char **argv) { | |
46 | log_set_max_level(LOG_DEBUG); | |
47 | log_parse_environment(); | |
48 | ||
49 | test_manager_parse_string(); | |
50 | ||
51 | return 0; | |
52 | } |