]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-sysctl-util.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 #include "sysctl-util.h"
7 static const char* cases
[] = {
13 "net.ipv4.conf.enp3s0/200.forwarding", "net/ipv4/conf/enp3s0.200/forwarding",
14 "net/ipv4/conf/enp3s0.200/forwarding", "net/ipv4/conf/enp3s0.200/forwarding",
18 ".a...b...c", "a/b/c",
19 "/a///b///c", "a/b/c",
23 static void test_sysctl_normalize(void) {
24 log_info("/* %s */", __func__
);
26 const char **s
, **expected
;
27 STRV_FOREACH_PAIR(s
, expected
, cases
) {
28 _cleanup_free_
char *t
;
30 assert_se(t
= strdup(*s
));
31 assert_se(sysctl_normalize(t
) == t
);
33 log_info("\"%s\" → \"%s\", expected \"%s\"", *s
, t
, *expected
);
34 assert_se(streq(t
, *expected
));
38 int main(int argc
, char *argv
[]) {
39 test_setup_logging(LOG_INFO
);
41 test_sysctl_normalize();