[PATCH] unit: Add graceful fail of pem, tls and key tests
by Brian Gix
Unit tests for PEM, TLS and KEY require the pkcs8_key_parser module
to be running in the kernel, however not all kernels have this
running by default. This checks for this possibility and aborts
these tests with exit(1) rather than an assert, and includes instruction
to correct the issue.
---
unit/test-key.c | 9 +++++++++
unit/test-pem.c | 9 +++++++++
unit/test-tls.c | 12 +++++++++++-
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/unit/test-key.c b/unit/test-key.c
index 697ff47..240a02c 100644
--- a/unit/test-key.c
+++ b/unit/test-key.c
@@ -569,6 +569,15 @@ static void test_key_crypto(const void *data)
privkey = l_pem_load_private_key(CERTDIR "cert-client-key-pkcs8.pem",
NULL, NULL);
+ if (!privkey) {
+ l_info("* Some kernel versions do not automatically load\n"
+ "* the pkcs8_key_parser module. If the system running\n"
+ "* test has not loaded this module, a failure here is\n"
+ "* likely. Running \"modprobe pkcs8_key_parser\" may\n"
+ "* correct this issue.\n");
+ exit(1);
+ }
+
assert(privkey);
success = l_key_get_info(privkey, rsa, hash, &keybits, &is_public);
assert(success);
diff --git a/unit/test-pem.c b/unit/test-pem.c
index d39003e..a1e8110 100644
--- a/unit/test-pem.c
+++ b/unit/test-pem.c
@@ -216,6 +216,15 @@ static void test_priv_key_from_data(const void *data)
key = l_pem_load_private_key_from_data(raw_private_key,
strlen(raw_private_key),
"abc", &is_encrypted);
+ if (!key) {
+ l_info("* Some kernel versions do not automatically load\n"
+ "* the pkcs8_key_parser module. If the system running\n"
+ "* test has not loaded this module, a failure here is\n"
+ "* likely. Running \"modprobe pkcs8_key_parser\" may\n"
+ "* correct this issue.\n");
+ exit(1);
+ }
+
assert(key);
assert(is_encrypted);
diff --git a/unit/test-tls.c b/unit/test-tls.c
index 1d47787..3519376 100644
--- a/unit/test-tls.c
+++ b/unit/test-tls.c
@@ -562,8 +562,18 @@ static void test_tls_with_ver(const struct tls_conn_test *test,
l_pem_load_private_key(test->server_key_path,
test->server_key_passphrase,
NULL);
- assert(server_cert);
+ if (!server_key) {
+ l_info("* Some kernel versions do not automatically\n"
+ "* load the pkcs8_key_parser module. If the\n"
+ "* system running test has not loaded this\n"
+ "* module, a failure here is likely. Running\n"
+ "* \"modprobe pkcs8_key_parser\" may correct\n"
+ "* this issue.\n");
+ exit(1);
+ }
+
assert(server_key);
+ assert(server_cert);
assert(l_tls_set_auth_data(s[0].tls, server_cert, server_key));
}
--
2.21.1
11 months, 2 weeks
[PATCH 1/4] genl: Update genl refcount when creating/freeing a family
by Andrew Zaborowski
Since struct l_genl is already refcounted we can hold references to the
l_genl object in an l_genl_family to allow the user to free them in
arbitrary order.
---
ell/genl.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ell/genl.c b/ell/genl.c
index 431ed05..ca4fa62 100644
--- a/ell/genl.c
+++ b/ell/genl.c
@@ -1800,7 +1800,7 @@ LIB_EXPORT struct l_genl_family *l_genl_family_new(struct l_genl *genl,
if (!entry)
return NULL;
- family = family_alloc(genl, info->id);
+ family = family_alloc(l_genl_ref(genl), info->id);
return family;
}
@@ -2059,4 +2059,5 @@ LIB_EXPORT void l_genl_family_free(struct l_genl_family *family)
}
l_free(family);
+ l_genl_unref(genl);
}
--
2.20.1
1 year
[PATCH 0/2] rtnl cleanups
by Daniel Wagner
As discussed on IRC here are the API changes.
Daniel Wagner (2):
rtnl: Make IPv4 and IPv6 naming scheme consistent
rtnl: Rename l_rtnl_ifaddr{4|6|}_get to l_rntl_ifaddr{4|6}_dump
ell/rtnl.c | 52 ++++++++++++++++++++++++------------------------
ell/rtnl.h | 28 +++++++++++++-------------
unit/test-rtnl.c | 42 +++++++++++++++++++-------------------
3 files changed, 61 insertions(+), 61 deletions(-)
--
2.25.0
1 year
[PATCH 0/3] rtnl: add missing APIs
by Daniel Wagner
The first two patches make the API for both protocol version
complete. The last patch adds the table, priority and preference to
the extract functions, which is a very uselful information.
This series is based on the cleanup series send before.
Daniel Wagner (3):
rtnl: Add l_rtnl_route6_dump() and l_rtnl_route6_extract()
unit: Add unit test for l_rtnl_route6_{dump|extract}
rtnl: Extract table, priority and pref
ell/rtnl.c | 130 ++++++++++++++++++++++++++++++++---------------
ell/rtnl.h | 10 +++-
unit/test-rtnl.c | 42 +++++++++++++--
3 files changed, 137 insertions(+), 45 deletions(-)
--
2.25.0
1 year
[PATCH 0/2] Import rntlutil from iwd
by Daniel Wagner
This just copies over the code from iwd. No changes there except the
prefix of the functions name.
Unfortunatly, the unit test can only test the get/dump function
because the setters need root permissions. For this we need some sort
of sandbox. Does anyone have any ideas for this?
While writing the test case I noticed some inconsistency in the naming
sceme:
The IPv6 functions are consistent in the naming sceme, always
append ipv6 after the first name:
rtnl_ifaddr_ipv6_extract
rtnl_ifaddr_ipv6_get
rtnl_ifaddr_ipv6_add
rtnl_ifaddr_ipv6_delete
rtnl_route_ipv6_add_gateway
rtnl_route_ipv6_delete_gateway
For the IPv4 functions it's either a plain 'ifaddr' infix or somewhere ipv4
in the name:
rtnl_ifaddr_extract
rtnl_ifaddr_get
rtnl_ifaddr_add
rtnl_ifaddr_delete
rtnl_route_extract_ipv4
rtnl_route_dump_ipv4
-> drop ipv4?
rtnl_route_ipv4_add_connected
rtnl_route_ipv4_add_gateway
-> drop ipv4?
And there are the setters:
rtnl_set_linkmode_and_operstate
rtnl_set_mac
rtnl_set_powered
Is this the standard naming sceme?
Thanks,
Daniel
Daniel Wagner (2):
rtnl: Add initial rtnl support
unit: Add l_rtnl_* unit tests
.gitignore | 1 +
Makefile.am | 5 +
ell/ell.h | 1 +
ell/rtnl.c | 641 +++++++++++++++++++++++++++++++++++++++++++++++
ell/rtnl.h | 119 +++++++++
unit/test-rtnl.c | 236 +++++++++++++++++
6 files changed, 1003 insertions(+)
create mode 100644 ell/rtnl.c
create mode 100644 ell/rtnl.h
create mode 100644 unit/test-rtnl.c
--
2.25.0
1 year