]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: skip instead of fail if crypto kmods are not available 5525/head
authorMartin Pitt <martin@piware.de>
Thu, 2 Mar 2017 22:42:01 +0000 (23:42 +0100)
committerMartin Pitt <martin@piware.de>
Fri, 3 Mar 2017 15:45:44 +0000 (16:45 +0100)
Package build machines may have module loading disabled, thus AF_ALG
sockets are not available. Skip the tests that cover those (khash and
id128) instead of failing them in this case.

Fixes #5524

src/test/test-hash.c
src/test/test-id128.c

index 1972b94cfe89ad617f5b7da153b9d684e2b4127a..02d1cfaee30a3d19e5672571625417683d3b929f 100644 (file)
@@ -17,6 +17,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include <stdio.h>
+
 #include "alloc-util.h"
 #include "log.h"
 #include "string-util.h"
 int main(int argc, char *argv[]) {
         _cleanup_(khash_unrefp) khash *h = NULL, *copy = NULL;
         _cleanup_free_ char *s = NULL;
+        int r;
 
         log_set_max_level(LOG_DEBUG);
 
         assert_se(khash_new(&h, NULL) == -EINVAL);
         assert_se(khash_new(&h, "") == -EINVAL);
-        assert_se(khash_new(&h, "foobar") == -EOPNOTSUPP);
+        r = khash_new(&h, "foobar");
+        if (r == -EAFNOSUPPORT) {
+                puts("khash not supported on this kernel, skipping");
+                return EXIT_TEST_SKIP;
+        }
+        assert_se(r == -EOPNOTSUPP);
 
         assert_se(khash_new(&h, "sha256") >= 0);
         assert_se(khash_get_size(h) == 32);
index e8c4c3e550d26fa95c85442356dfb837ff574f70..e5f45206f16a086d5d89585a98948285efd058b0 100644 (file)
@@ -154,11 +154,16 @@ int main(int argc, char *argv[]) {
         assert_se(id128_read_fd(fd, ID128_UUID, &id2) >= 0);
         assert_se(sd_id128_equal(id, id2));
 
-        assert_se(sd_id128_get_machine_app_specific(SD_ID128_MAKE(f0,3d,aa,eb,1c,33,4b,43,a7,32,17,29,44,bf,77,2e), &id) >= 0);
-        assert_se(sd_id128_get_machine_app_specific(SD_ID128_MAKE(f0,3d,aa,eb,1c,33,4b,43,a7,32,17,29,44,bf,77,2e), &id2) >= 0);
-        assert_se(sd_id128_equal(id, id2));
-        assert_se(sd_id128_get_machine_app_specific(SD_ID128_MAKE(51,df,0b,4b,c3,b0,4c,97,80,e2,99,b9,8c,a3,73,b8), &id2) >= 0);
-        assert_se(!sd_id128_equal(id, id2));
+        r = sd_id128_get_machine_app_specific(SD_ID128_MAKE(f0,3d,aa,eb,1c,33,4b,43,a7,32,17,29,44,bf,77,2e), &id);
+        if (r == -EAFNOSUPPORT) {
+                log_info("khash not supported on this kernel, skipping sd_id128_get_machine_app_specific() checks");
+        } else {
+                assert_se(r >= 0);
+                assert_se(sd_id128_get_machine_app_specific(SD_ID128_MAKE(f0,3d,aa,eb,1c,33,4b,43,a7,32,17,29,44,bf,77,2e), &id2) >= 0);
+                assert_se(sd_id128_equal(id, id2));
+                assert_se(sd_id128_get_machine_app_specific(SD_ID128_MAKE(51,df,0b,4b,c3,b0,4c,97,80,e2,99,b9,8c,a3,73,b8), &id2) >= 0);
+                assert_se(!sd_id128_equal(id, id2));
+        }
 
         /* Query the invocation ID */
         r = sd_id128_get_invocation(&id);