| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
/* Some unit tests for the helper functions in timesyncd. */ |
| 4 |
|
| 5 |
#include "tests.h" |
| 6 |
#include "timesyncd-conf.h" |
| 7 |
#include "timesyncd-manager.h" |
| 8 |
#include "timesyncd-server.h" |
| 9 |
|
| 10 |
TEST(manager_parse_string) { |
| 11 |
/* Make sure that NTP_SERVERS is configured to something |
| 12 |
* that we can actually parse successfully. */ |
| 13 |
|
| 14 |
_cleanup_(manager_freep) Manager *m = NULL; |
| 15 |
|
| 16 |
assert_se(manager_new(&m) == 0); |
| 17 |
|
| 18 |
assert_se(!m->fallback_set); |
| 19 |
assert_se(manager_parse_server_string(m, SERVER_FALLBACK, NTP_SERVERS) == 0); |
| 20 |
assert_se(m->fallback_set); |
| 21 |
assert_se(manager_parse_fallback_string(m, NTP_SERVERS) == 0); |
| 22 |
|
| 23 |
assert_se(manager_parse_server_string(m, SERVER_SYSTEM, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); |
| 24 |
assert_se(manager_parse_server_string(m, SERVER_FALLBACK, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); |
| 25 |
assert_se(manager_parse_server_string(m, SERVER_LINK, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); |
| 26 |
} |
| 27 |
|
| 28 |
DEFINE_TEST_MAIN(LOG_DEBUG); |