dcavalca / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
Blob Blame History Raw
From 34421f9caaa90224108e6c322985c479a49cbef9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Mon, 27 Jul 2020 13:49:12 +0200
Subject: [PATCH] test-fs-util: do not assume /dev is always real

When building in Fedora's koji, test-fs-util would fail:
--- command ---
10:18:29 SYSTEMD_LANGUAGE_FALLBACK_MAP='/builddir/build/BUILD/systemd-246-rc2/src/locale/language-fallback-map' PATH='/builddir/build/BUILD/systemd-246-rc2/x86_64-redhat-linux-gnu:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin' SYSTEMD_KBD_MODEL_MAP='/builddir/build/BUILD/systemd-246-rc2/src/locale/kbd-model-map' /builddir/build/BUILD/systemd-246-rc2/x86_64-redhat-linux-gnu/test-fs-util
--- stderr ---
/* test_chase_symlinks */
/* test_unlink_noerrno */
/* test_readlink_and_make_absolute */
/* test_var_tmp */
/* test_dot_or_dot_dot */
/* test_access_fd */
/* test_touch_file */
/* test_unlinkat_deallocate */
/* test_fsync_directory_of_file */
/* test_rename_noreplace */
/* test_path_is_encrypted */
/home encrypted: yes
/var encrypted: yes
/ encrypted: yes
/proc encrypted: no
/sys encrypted: no
/dev encrypted: yes
Assertion 'expect < 0 || ((r > 0) == (expect > 0))' failed at src/test/test-fs-util.c:863, function test_path_is_encrypted_one(). Aborting.
-------

It seems / is encrypted, but /dev is just a normal directory.
---
 src/test/test-fs-util.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c
index 8d9a1974b2..611057b90f 100644
--- a/src/test/test-fs-util.c
+++ b/src/test/test-fs-util.c
@@ -864,14 +864,16 @@ static void test_path_is_encrypted_one(const char *p, int expect) {
 }
 
 static void test_path_is_encrypted(void) {
-        log_info("/* %s */", __func__);
+        int booted = sd_booted();
+
+        log_info("/* %s (sd_booted=%d)*/", __func__, booted);
 
         test_path_is_encrypted_one("/home", -1);
         test_path_is_encrypted_one("/var", -1);
         test_path_is_encrypted_one("/", -1);
-        test_path_is_encrypted_one("/proc", false);
-        test_path_is_encrypted_one("/sys", false);
-        test_path_is_encrypted_one("/dev", false);
+        test_path_is_encrypted_one("/proc", booted > 0 ? false : -1);
+        test_path_is_encrypted_one("/sys", booted > 0 ? false : -1);
+        test_path_is_encrypted_one("/dev", booted > 0 ? false : -1);
 }
 
 int main(int argc, char *argv[]) {