]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-fs-util: do not assume /dev is always real
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 27 Jul 2020 11:49:12 +0000 (13:49 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 28 Jul 2020 08:39:41 +0000 (10:39 +0200)
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

index 8d9a1974b24de4c1b65948a51e5505ca0b83fa8d..dfea70ca27390a4bcfa504f1d695ef8c2db2a175 100644 (file)
@@ -864,14 +864,17 @@ 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(); /* If this is run in build environments such as koji, /dev might be a
+                                   * reguar fs. Don't assume too much if not running under systemd. */
+
+        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("/dev", booted > 0 ? false : -1);
 }
 
 int main(int argc, char *argv[]) {