test: do not fail when lacking privs to create sysfs directory

4109s /* test_mdio_bus */
4109s src/libsystemd/sd-device/test-sd-device.c:55: Assertion failed: Expected "mkdir_p(syspath, 0755)" to succeed, but got error: Permission denied
4109s (mdio_bus) terminated by signal ABRT.
4109s src/libsystemd/sd-device/test-sd-device.c:37: Assertion failed: Expected "r = safe_fork("(mdio_bus)", FORK_CLOSE_ALL_FDS|FORK_DEATHSIG_SIGTERM|FORK_REOPEN_LOG|FORK_LOG|FORK_WAIT|FORK_NEW_MOUNTNS|FORK_MOUNTNS_SLAVE, NULL)" to succeed, but got error: Protocol error

Follow-up for 687a92a1b6
This commit is contained in:
Luca Boccassi
2025-06-08 12:21:58 +01:00
committed by Yu Watanabe
parent 1b4645d762
commit f245fa0058

View File

@@ -52,7 +52,12 @@ TEST(mdio_bus) {
ASSERT_OK_ERRNO(setenv("SYSTEMD_DEVICE_VERIFY_SYSFS", "0", /* overwrite = */ false));
ASSERT_OK(mount_nofollow_verbose(LOG_ERR, "tmpfs", "/sys/bus/", "tmpfs", 0, NULL));
ASSERT_OK(mkdir_p(syspath, 0755));
r = mkdir_p(syspath, 0755);
if (ERRNO_IS_NEG_PRIVILEGE(r)) {
log_tests_skipped("Lacking privileges to create %s", syspath);
_exit(EXIT_SUCCESS);
}
ASSERT_OK(r);
_cleanup_free_ char *uevent = path_join(syspath, "uevent");
ASSERT_NOT_NULL(uevent);