Make TestPidOf1 unit test more robust
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Tue, 30 Dec 2025 10:58:20 +0000 (11:58 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 31 Dec 2025 10:44:51 +0000 (11:44 +0100)
commit7948e0e2d267015796ba3de1cf8bfb2f4c348478
tree41887332c3714dc27b686d175ce90420637d1eb3
parentc816e31dfbdd463c6fbcd79f326403d993c32b50
Make TestPidOf1 unit test more robust

The test expects to find PID 1 by searching for "init" or "systemd".

While some LXC container is running:
- PID 1 runs systemd (not traditional init)
- Another process (e.g., PID 41150) may have "init" in its cmdline

This causes pid_of("init") to return PID 41150 instead of PID 1,
and the test would fail because PID 1 is not in the result.

The fix checks if PID 1 is found after the "init" search, and if not,
falls back to searching for "systemd" to find PID 1.
test/test_filefunc.cpp