diff --git a/test/units/TEST-74-AUX-UTILS.varlinkctl-job.sh b/test/units/TEST-74-AUX-UTILS.varlinkctl-job.sh new file mode 100755 index 0000000000..032904b4e5 --- /dev/null +++ b/test/units/TEST-74-AUX-UTILS.varlinkctl-job.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -eux +set -o pipefail + +# test io.systemd.Job +varlinkctl introspect /run/systemd/io.systemd.Manager io.systemd.Job + +# List with no jobs pending — should return empty with --more +varlinkctl --more call /run/systemd/io.systemd.Manager io.systemd.Job.List '{}' --graceful=io.systemd.Job.NoSuchJob + +# Without --more and no filter, must fail (streaming required) +(! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Job.List '{}') + +# Error cases: non-existent job ID, non-existent unit +(! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Job.List '{"id": 999999}') +(! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Job.List '{"unit": "non-existent.service"}') + +# Invalid inputs +(! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Job.List '{"id": 0}') +(! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Job.List '{"unit": ""}') + +at_exit() { + systemctl stop varlink-test-job.service 2>/dev/null || true + rm -f /run/systemd/system/varlink-test-job.service + systemctl daemon-reload +} +trap at_exit EXIT + +# Create a job by starting a slow service, then test List/Cancel +cat >/run/systemd/system/varlink-test-job.service <