Closed hadess closed 1 year ago
This would explain why it's reading data from the system rather than the mock dir:
openat(AT_FDCWD, "/run/udev/data/+sound:card0", O_RDONLY|O_CLOEXEC) = 10
My "fix" is:
diff --git a/src/libumockdev-preload.c b/src/libumockdev-preload.c
index db6e310cb445..5ede952b6e47 100644
--- a/src/libumockdev-preload.c
+++ b/src/libumockdev-preload.c
@@ -185,6 +185,8 @@ trap_path(const char *path)
if (strncmp(abspath, "/dev/", 5) == 0 || strcmp(abspath, "/dev") == 0 || strncmp(abspath, "/proc/", 6) == 0)
check_exist = 1;
+ else if (strncmp(abspath, "/run/", 5) == 0)
+ check_exist = 0;
else if (strncmp(abspath, "/sys/", 5) != 0 && strcmp(abspath, "/sys") != 0)
return path;
I straced this systemd test executable to double-check that trying to access a /run
file got redirected to the mock directory:
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "device-internal.h"
#include "device-private.h"
#include "fd-util.h"
#include "fs-util.h"
#include "tmpfile-util.h"
int main(int argc, char **argv) {
char *filename = argv[1];
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
printf("filename: %s\n", filename);
assert_se(device_new_aux(&dev) >= 0);
(void) device_read_db_internal_filename(dev, filename);
return 0;
}
Using
systemd-udev-253.5-1.fc38.x86_64
, current git main umockdev, libgudev and upower master branchesRunning the
test_headset_detection
test in upower, I get a failure on my desktop system because the headset device it detects shows up as aninternal
audio device, instead of a headset. The problem doesn't happen in the CI.The properties dump for the device shows:
Which looks suspiciously like something is reading from the real sound
card0
on my system!