diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 13:00:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 13:00:47 +0000 |
commit | 2cb7e0aaedad73b076ea18c6900b0e86c5760d79 (patch) | |
tree | da68ca54bb79f4080079bf0828acda937593a4e1 /src/timesync/test-timesync.c | |
parent | Initial commit. (diff) | |
download | systemd-2cb7e0aaedad73b076ea18c6900b0e86c5760d79.tar.xz systemd-2cb7e0aaedad73b076ea18c6900b0e86c5760d79.zip |
Adding upstream version 247.3.upstream/247.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/timesync/test-timesync.c')
-rw-r--r-- | src/timesync/test-timesync.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/timesync/test-timesync.c b/src/timesync/test-timesync.c new file mode 100644 index 0000000..31e91e7 --- /dev/null +++ b/src/timesync/test-timesync.c @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +/* Some unit tests for the helper functions in timesyncd. */ + +#include "log.h" +#include "macro.h" +#include "timesyncd-conf.h" +#include "tests.h" + +static void test_manager_parse_string(void) { + /* Make sure that NTP_SERVERS is configured to something + * that we can actually parse successfully. */ + + _cleanup_(manager_freep) Manager *m = NULL; + + assert_se(manager_new(&m) == 0); + + assert_se(!m->have_fallbacks); + assert_se(manager_parse_server_string(m, SERVER_FALLBACK, NTP_SERVERS) == 0); + assert_se(m->have_fallbacks); + assert_se(manager_parse_fallback_string(m, NTP_SERVERS) == 0); + + assert_se(manager_parse_server_string(m, SERVER_SYSTEM, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); + assert_se(manager_parse_server_string(m, SERVER_FALLBACK, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); + assert_se(manager_parse_server_string(m, SERVER_LINK, "time1.foobar.com time2.foobar.com axrfav.,avf..ra 12345..123") == 0); +} + +int main(int argc, char **argv) { + test_setup_logging(LOG_DEBUG); + + test_manager_parse_string(); + + return 0; +} |