]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: simple tests for io.systemd.Unit varlink interface
authorIvan Kruglov <mail@ikruglov.com>
Mon, 26 May 2025 10:14:28 +0000 (03:14 -0700)
committerIvan Kruglov <mail@ikruglov.com>
Tue, 27 May 2025 08:16:56 +0000 (01:16 -0700)
src/test/test-varlink-idl.c
test/units/TEST-74-AUX-UTILS.varlinkctl.sh

index 00e142ae61ccbac561c83dc6f26e500a771ab00e..6b3449f7772d36f6c35ff552b97738c2ce36631c 100644 (file)
@@ -31,6 +31,7 @@
 #include "varlink-io.systemd.Resolve.h"
 #include "varlink-io.systemd.Resolve.Monitor.h"
 #include "varlink-io.systemd.Udev.h"
+#include "varlink-io.systemd.Unit.h"
 #include "varlink-io.systemd.UserDatabase.h"
 #include "varlink-io.systemd.oom.h"
 #include "varlink-io.systemd.service.h"
@@ -211,6 +212,8 @@ TEST(parse_format) {
         print_separator();
         test_parse_format_one(&vl_interface_io_systemd_FactoryReset);
         print_separator();
+        test_parse_format_one(&vl_interface_io_systemd_Unit);
+        print_separator();
         test_parse_format_one(&vl_interface_xyz_test);
 }
 
index 0c7582db51a3e0cad803b48d12e488f577891311..2e0bf5f7d6aebad84b2a291a630daeb658fa0ba6 100755 (executable)
@@ -172,6 +172,16 @@ varlinkctl info /run/systemd/io.systemd.Manager
 varlinkctl introspect /run/systemd/io.systemd.Manager io.systemd.Manager
 varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Manager.Describe '{}'
 
+# test io.systemd.Unit
+varlinkctl info /run/systemd/io.systemd.Manager
+varlinkctl introspect /run/systemd/io.systemd.Manager io.systemd.Unit
+varlinkctl --more call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{}'
+varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{"name": "multi-user.target"}'
+varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{"pid": {"pid": 0}}'
+(! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{"name": ""}')
+(! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{"name": "non-existent.service"}')
+(! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{"pid": {"pid": -1}}' )
+
 # test io.systemd.Manager in user manager
 testuser_uid=$(id -u testuser)
 systemd-run --wait --pipe --user --machine testuser@ \
@@ -180,3 +190,7 @@ systemd-run --wait --pipe --user --machine testuser@ \
         varlinkctl introspect "/run/user/$testuser_uid/systemd/io.systemd.Manager"
 systemd-run --wait --pipe --user --machine testuser@ \
         varlinkctl call "/run/user/$testuser_uid/systemd/io.systemd.Manager" io.systemd.Manager.Describe '{}'
+
+# test io.systemd.Unit in user manager
+systemd-run --wait --pipe --user --machine testuser@ \
+        varlinkctl --more call "/run/user/$testuser_uid/systemd/io.systemd.Manager" io.systemd.Unit.List '{}'