systemd: Add unit test cases

The tests cover `SystemdClient` and methods from `utils` mods.

Please note that the `SystemdClient` tests do not run well in parallel, but
work well in sequence. Please run them with `--test-threads=1`.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This commit is contained in:
Xuewei Niu
2025-07-10 16:01:04 +08:00
parent 0c26caecfc
commit d69517847b
5 changed files with 473 additions and 2 deletions

View File

@@ -20,8 +20,18 @@ build: debug
#
.PHONY: test
test:
cargo test -- --color always --nocapture
test: test-systemd
cargo test -- --color always --nocapture \
--skip systemd::dbus::client::tests
.PHONY: test-systemd
# Tests that manipulate cgroups should run in sequence, so that
# `--test-threads=1` is used.
test-systemd:
cargo test --package cgroups-rs --lib \
-- systemd::dbus::client::tests \
--color always --nocapture \
--test-threads=1
.PHONY: check
check: fmt clippy