"make check" has 6 failures for me: FAIL: test-unit-name FAIL: test-unit-file FAIL: test-id128 FAIL: test-journal FAIL: test-journal-stream FAIL: test-journal-verify Turns out that these rely on an existing /etc/machine-id. Once I create one, all tests succeed. Depending on the outside environment is rather bad for unit tests, as this breaks operation in continuous integration servers, ephemeral chroots, etc. If these tests need a machine ID, could they use one generated in a temporary location?
Note that this particularly hits us during package builds. These happen in minimal chroots which don't have any particular system setup, but we would still like to run the tests during package build to ensure they keep working on all architectures.
Hmm, if you run in a chroot, why not just add the missing file there?
Would it be acceptable to do something like this, and set it in the tests? - fd = open("/etc/machine-id", O_RDONLY|O_CLOEXEC|O_NOCTTY); + machine_id_path = getenv("SYSTEMD_MACHINE_ID_PATH"); + if (machine_id_path == NULL) + machine_id_path = "/etc/machine-id"; + fd = open(machine_id_path, O_RDONLY|O_CLOEXEC|O_NOCTTY); Security wise it should not matter much, as you can also use LD_PRELOAD to divert the path.
(In reply to comment #2) > Hmm, if you run in a chroot, why not just add the missing file there? Package builds can't do that, they don't run as root.
May I suggest to just add this to Ubuntu? It would really be a useful feature anyway... I mean, this is not really the most exotic thing, you could just link the dbus machine id to /etc/machine-id... The other option is simply not to run the tests on Ubuntu? We actually try to gently push people into just adopting /etc/machine-id, because it is so useful and we want to allow code to simply rely on it, and so I am not really interested in adding code that allows people to maintain fallback logic...
(In reply to comment #5) > May I suggest to just add this to Ubuntu? Sure, I can do that. I just thought I at least propose it before assuming it wasn't useful for anyone else. > I mean, this is not really the most exotic thing, you could just link the > dbus machine id to /etc/machine-id... Yeah, I guess we can do that, if the D-BUS id is a sanctioned source for libsystemd-id128. Thanks!
/etc/machine-id and the D-Bus machine-id are identical, yes. Systemd just moved it to /etc as a common interface, not a D-Bus private setting. All *should* work fine, if the D-Bus own one is removed today: http://cgit.freedesktop.org/dbus/dbus/commit/?id=66e52541d5bdd4927a5c702963749760643313f4 Future versions of D-Bus, including the ongoing kdbus work will not use the old location anymore, but require /etc/machine-id.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.