diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-firewall-util.c (renamed from src/test/test-fw-util.c) | 2 | ||||
-rw-r--r-- | src/test/test-hashmap-plain.c | 1 | ||||
-rw-r--r-- | src/test/test-netlink-manual.c (renamed from src/test/test-rtnl-manual.c) | 54 | ||||
-rw-r--r-- | src/test/test-pty.c | 2 | ||||
-rw-r--r-- | src/test/test-udev.c | 2 | ||||
-rw-r--r-- | src/test/test-util.c | 37 |
6 files changed, 68 insertions, 30 deletions
diff --git a/src/test/test-fw-util.c b/src/test/test-firewall-util.c index ab891aa0c4..d636e427c4 100644 --- a/src/test/test-fw-util.c +++ b/src/test/test-firewall-util.c @@ -20,7 +20,7 @@ ***/ #include "log.h" -#include "fw-util.h" +#include "firewall-util.h" #define MAKE_IN_ADDR_UNION(a,b,c,d) (union in_addr_union) { .in.s_addr = htobe32((uint32_t) (a) << 24 | (uint32_t) (b) << 16 | (uint32_t) (c) << 8 | (uint32_t) (d))} diff --git a/src/test/test-hashmap-plain.c b/src/test/test-hashmap-plain.c index c1a5ccf1f5..057b6c1dc1 100644 --- a/src/test/test-hashmap-plain.c +++ b/src/test/test-hashmap-plain.c @@ -465,6 +465,7 @@ static void test_hashmap_foreach_key(void) { hashmap_put(m, key, (void*) (const char*) "my dummy val"); HASHMAP_FOREACH_KEY(s, key, m, i) { + assert(s); if (!key_found[0] && streq(key, "key 1")) key_found[0] = true; else if (!key_found[1] && streq(key, "key 2")) diff --git a/src/test/test-rtnl-manual.c b/src/test/test-netlink-manual.c index 9fc860d6a5..2879d7450f 100644 --- a/src/test/test-rtnl-manual.c +++ b/src/test/test-netlink-manual.c @@ -27,7 +27,7 @@ #include "util.h" #include "macro.h" -#include "sd-rtnl.h" +#include "sd-netlink.h" static int load_module(const char *mod_name) { struct kmod_ctx *ctx; @@ -62,9 +62,9 @@ static int load_module(const char *mod_name) { return r; } -static int test_tunnel_configure(sd_rtnl *rtnl) { +static int test_tunnel_configure(sd_netlink *rtnl) { int r; - sd_rtnl_message *m, *n; + sd_netlink_message *m, *n; struct in_addr local, remote; /* skip test if module cannot be loaded */ @@ -79,25 +79,25 @@ static int test_tunnel_configure(sd_rtnl *rtnl) { assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0) >= 0); assert_se(m); - assert_se(sd_rtnl_message_append_string(m, IFLA_IFNAME, "ipip-tunnel") >= 0); - assert_se(sd_rtnl_message_append_u32(m, IFLA_MTU, 1234)>= 0); + assert_se(sd_netlink_message_append_string(m, IFLA_IFNAME, "ipip-tunnel") >= 0); + assert_se(sd_netlink_message_append_u32(m, IFLA_MTU, 1234)>= 0); - assert_se(sd_rtnl_message_open_container(m, IFLA_LINKINFO) >= 0); + assert_se(sd_netlink_message_open_container(m, IFLA_LINKINFO) >= 0); - assert_se(sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, "ipip") >= 0); + assert_se(sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, "ipip") >= 0); inet_pton(AF_INET, "192.168.21.1", &local.s_addr); - assert_se(sd_rtnl_message_append_u32(m, IFLA_IPTUN_LOCAL, local.s_addr) >= 0); + assert_se(sd_netlink_message_append_u32(m, IFLA_IPTUN_LOCAL, local.s_addr) >= 0); inet_pton(AF_INET, "192.168.21.2", &remote.s_addr); - assert_se(sd_rtnl_message_append_u32(m, IFLA_IPTUN_REMOTE, remote.s_addr) >= 0); + assert_se(sd_netlink_message_append_u32(m, IFLA_IPTUN_REMOTE, remote.s_addr) >= 0); - assert_se(sd_rtnl_message_close_container(m) >= 0); - assert_se(sd_rtnl_message_close_container(m) >= 0); + assert_se(sd_netlink_message_close_container(m) >= 0); + assert_se(sd_netlink_message_close_container(m) >= 0); - assert_se(sd_rtnl_call(rtnl, m, -1, 0) == 1); + assert_se(sd_netlink_call(rtnl, m, -1, 0) == 1); - assert_se((m = sd_rtnl_message_unref(m)) == NULL); + assert_se((m = sd_netlink_message_unref(m)) == NULL); r = load_module("sit"); if(r < 0) @@ -107,41 +107,41 @@ static int test_tunnel_configure(sd_rtnl *rtnl) { assert_se(sd_rtnl_message_new_link(rtnl, &n, RTM_NEWLINK, 0) >= 0); assert_se(n); - assert_se(sd_rtnl_message_append_string(n, IFLA_IFNAME, "sit-tunnel") >= 0); - assert_se(sd_rtnl_message_append_u32(n, IFLA_MTU, 1234)>= 0); + assert_se(sd_netlink_message_append_string(n, IFLA_IFNAME, "sit-tunnel") >= 0); + assert_se(sd_netlink_message_append_u32(n, IFLA_MTU, 1234)>= 0); - assert_se(sd_rtnl_message_open_container(n, IFLA_LINKINFO) >= 0); + assert_se(sd_netlink_message_open_container(n, IFLA_LINKINFO) >= 0); - assert_se(sd_rtnl_message_open_container_union(n, IFLA_INFO_DATA, "sit") >= 0); + assert_se(sd_netlink_message_open_container_union(n, IFLA_INFO_DATA, "sit") >= 0); - assert_se(sd_rtnl_message_append_u8(n, IFLA_IPTUN_PROTO, IPPROTO_IPIP) >= 0); + assert_se(sd_netlink_message_append_u8(n, IFLA_IPTUN_PROTO, IPPROTO_IPIP) >= 0); inet_pton(AF_INET, "192.168.21.3", &local.s_addr); - assert_se(sd_rtnl_message_append_u32(n, IFLA_IPTUN_LOCAL, local.s_addr) >= 0); + assert_se(sd_netlink_message_append_u32(n, IFLA_IPTUN_LOCAL, local.s_addr) >= 0); inet_pton(AF_INET, "192.168.21.4", &remote.s_addr); - assert_se(sd_rtnl_message_append_u32(n, IFLA_IPTUN_REMOTE, remote.s_addr) >= 0); + assert_se(sd_netlink_message_append_u32(n, IFLA_IPTUN_REMOTE, remote.s_addr) >= 0); - assert_se(sd_rtnl_message_close_container(n) >= 0); - assert_se(sd_rtnl_message_close_container(n) >= 0); + assert_se(sd_netlink_message_close_container(n) >= 0); + assert_se(sd_netlink_message_close_container(n) >= 0); - assert_se(sd_rtnl_call(rtnl, n, -1, 0) == 1); + assert_se(sd_netlink_call(rtnl, n, -1, 0) == 1); - assert_se((m = sd_rtnl_message_unref(n)) == NULL); + assert_se((n = sd_netlink_message_unref(n)) == NULL); return EXIT_SUCCESS; } int main(int argc, char *argv[]) { - sd_rtnl *rtnl; + sd_netlink *rtnl; int r; - assert_se(sd_rtnl_open(&rtnl) >= 0); + assert_se(sd_netlink_open(&rtnl) >= 0); assert_se(rtnl); r = test_tunnel_configure(rtnl); - assert_se((rtnl = sd_rtnl_unref(rtnl)) == NULL); + assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL); return r; } diff --git a/src/test/test-pty.c b/src/test/test-pty.c index f8807c9150..3f97a64ccd 100644 --- a/src/test/test-pty.c +++ b/src/test/test-pty.c @@ -129,7 +129,7 @@ int main(int argc, char *argv[]) { log_parse_environment(); log_open(); - assert_se(sigprocmask_many(SIG_BLOCK, SIGCHLD, -1) >= 0); + assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0); /* Oh, there're ugly races in the TTY layer regarding HUP vs IN. Turns * out they appear only 10% of the time. I fixed all of them and diff --git a/src/test/test-udev.c b/src/test/test-udev.c index d1fe953071..2b765a3e90 100644 --- a/src/test/test-udev.c +++ b/src/test/test-udev.c @@ -116,7 +116,7 @@ int main(int argc, char *argv[]) { event = udev_event_new(dev); - assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, SIGHUP, SIGCHLD, -1) == 0); + assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, SIGHUP, SIGCHLD, -1) >= 0); /* do what devtmpfs usually provides us */ if (udev_device_get_devnode(dev) != NULL) { diff --git a/src/test/test-util.c b/src/test/test-util.c index 9d5516a18d..ed8db45115 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -1507,6 +1507,42 @@ static void test_parse_mode(void) { assert_se(parse_mode("0", &m) >= 0 && m == 0); } +static void test_tempfn(void) { + char *ret = NULL, *p; + + assert_se(tempfn_xxxxxx("/foo/bar/waldo", NULL, &ret) >= 0); + assert_se(streq_ptr(ret, "/foo/bar/.#waldoXXXXXX")); + free(ret); + + assert_se(tempfn_xxxxxx("/foo/bar/waldo", "[miau]", &ret) >= 0); + assert_se(streq_ptr(ret, "/foo/bar/.#[miau]waldoXXXXXX")); + free(ret); + + assert_se(tempfn_random("/foo/bar/waldo", NULL, &ret) >= 0); + assert_se(p = startswith(ret, "/foo/bar/.#waldo")); + assert_se(strlen(p) == 16); + assert_se(in_charset(p, "0123456789abcdef")); + free(ret); + + assert_se(tempfn_random("/foo/bar/waldo", "[wuff]", &ret) >= 0); + assert_se(p = startswith(ret, "/foo/bar/.#[wuff]waldo")); + assert_se(strlen(p) == 16); + assert_se(in_charset(p, "0123456789abcdef")); + free(ret); + + assert_se(tempfn_random_child("/foo/bar/waldo", NULL, &ret) >= 0); + assert_se(p = startswith(ret, "/foo/bar/waldo/.#")); + assert_se(strlen(p) == 16); + assert_se(in_charset(p, "0123456789abcdef")); + free(ret); + + assert_se(tempfn_random_child("/foo/bar/waldo", "[kikiriki]", &ret) >= 0); + assert_se(p = startswith(ret, "/foo/bar/waldo/.#[kikiriki]")); + assert_se(strlen(p) == 16); + assert_se(in_charset(p, "0123456789abcdef")); + free(ret); +} + int main(int argc, char *argv[]) { log_parse_environment(); log_open(); @@ -1582,6 +1618,7 @@ int main(int argc, char *argv[]) { test_sparse_write(); test_shell_maybe_quote(); test_parse_mode(); + test_tempfn(); return 0; } |