]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tests: don't test hostname if it looks like an id128
authorSteve Muir <muir@fb.com>
Wed, 27 Jul 2016 21:19:37 +0000 (14:19 -0700)
committerDavide Cavalca <dcavalca@fb.com>
Fri, 29 Jul 2016 21:30:39 +0000 (14:30 -0700)
The condition tests for hostname will fail if hostname looks like an id128.
The test function attempts to convert hostname to an id128, and if that
succeeds compare it to the machine ID (presumably because the 'hostname'
condition test is overloaded to also test machine ID). That will typically
fail, and unfortunately the 'mock' utility generates a random hostname that
happens to have the same format as an id128, thus causing a test failure.

src/test/test-condition.c

index 987862f1c62f08d68d4b99792ef75782a516a07f..4ef61ebfa514860bc82b06a31ae67ab5148196c5 100644 (file)
@@ -25,6 +25,7 @@
 #include "audit-util.h"
 #include "condition.h"
 #include "hostname-util.h"
+#include "id128-util.h"
 #include "ima-util.h"
 #include "log.h"
 #include "macro.h"
@@ -142,9 +143,14 @@ static void test_condition_test_host(void) {
         hostname = gethostname_malloc();
         assert_se(hostname);
 
-        condition = condition_new(CONDITION_HOST, hostname, false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
+        /* if hostname looks like an id128 then skip testing it */
+        if (id128_is_valid(hostname)) {
+                log_notice("hostname is an id128, skipping test");
+        } else {
+                condition = condition_new(CONDITION_HOST, hostname, false, false);
+                assert_se(condition_test(condition));
+                condition_free(condition);
+        }
 }
 
 static void test_condition_test_architecture(void) {