Compare commits

...

2 Commits

Author SHA1 Message Date
Luca Boccassi caecfe9734
Merge 6afbec91ef into 69af4849aa 2024-11-21 04:17:29 +09:00
Luca Boccassi 6afbec91ef test-audit-util: run only when booted via systemd
The test can be ran on systems that are not booted on systemd, so
making assertions based on the precise state of an unknown, foreign
pid1 is not guaranteed to yield the expected results and may fail
at any given time.

More specifically, this happens when building systemd on the buildd
network, which is used to build packages in Debian/Ubuntu:

 Assertion 'audit_session_from_pid(&pid1, &sessionid) == -ENODATA' failed at src/test/test-audit-util.c:27, function test_audit_loginuid_from_pid(). Aborting.

https://buildd.debian.org/status/fetch.php?pkg=systemd&arch=amd64&ver=257%7Erc2-1&stamp=1731712935&raw=0

Use the common .sd_booted idyom to ensure it only runs under a pid1
that we can reasonably make assertions for.

Fixes https://github.com/systemd/systemd/issues/35249
2024-11-20 17:46:47 +00:00
1 changed files with 1 additions and 1 deletions

View File

@ -3,7 +3,7 @@
#include "audit-util.h" #include "audit-util.h"
#include "tests.h" #include "tests.h"
TEST(audit_loginuid_from_pid) { TEST(audit_loginuid_from_pid, .sd_booted = true) {
_cleanup_(pidref_done) PidRef self = PIDREF_NULL, pid1 = PIDREF_NULL; _cleanup_(pidref_done) PidRef self = PIDREF_NULL, pid1 = PIDREF_NULL;
int r; int r;