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.
This commit is contained in:
@@ -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[]) {
|
||||
|
||||
Reference in New Issue
Block a user