summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-10-14 12:31:57 +0200
committerLennart Poettering <lennart@poettering.net>2024-10-14 12:44:36 +0200
commitde34ec188c4d4f682a337445aa7753259cd7f821 (patch)
treec9b0b4c8d6716185324158c150f9b49a3233f4fe /src/test
parentMerge pull request #34716 from dvdhrm/pr/derand (diff)
downloadsystemd-de34ec188c4d4f682a337445aa7753259cd7f821.tar.xz
systemd-de34ec188c4d4f682a337445aa7753259cd7f821.zip
pidref: hookup PID_AUTOMATIC special pid_t value with PidRef
The PID_AUTOMATIC value is now properly recognized by the PidRef logic too. This needed some massaging of header includes, to ensure pidref.h can access process-util.h's definitions and vice versa.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-pidref.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/test-pidref.c b/src/test/test-pidref.c
index 53ed10d153..7298b36596 100644
--- a/src/test/test-pidref.c
+++ b/src/test/test-pidref.c
@@ -224,4 +224,20 @@ TEST(pidref_verify) {
assert_se(pidref_verify(&pidref) == (pidref.fd >= 0));
}
+TEST(pidref_is_automatic) {
+ assert_se(!pidref_is_automatic(NULL));
+ assert_se(!pidref_is_automatic(&PIDREF_NULL));
+ assert_se(!pidref_is_automatic(&PIDREF_MAKE_FROM_PID(1)));
+ assert_se(!pidref_is_automatic(&PIDREF_MAKE_FROM_PID(getpid_cached())));
+ assert_se(pidref_is_automatic(&PIDREF_AUTOMATIC));
+
+ assert_se(!pid_is_automatic(0));
+ assert_se(!pid_is_automatic(1));
+ assert_se(!pid_is_automatic(getpid_cached()));
+ assert_se(pid_is_automatic(PID_AUTOMATIC));
+
+ assert_se(!pidref_is_set(&PIDREF_AUTOMATIC));
+ assert_se(!pid_is_valid(PID_AUTOMATIC));
+}
+
DEFINE_TEST_MAIN(LOG_DEBUG);