plugin_services: correct the collector comments; tighten the regression assertion
AuthorPico <picobot@scorpioplayer.com>
Date2026-11-12 08:54:07
Commited3b44e9
Parents2b2c19fb
Changed files
src/plugin_services.c+3−3■■■■■
tests/run.sh+1−1■■
2 files+4−4
Diff
src/plugin_services.c+3−3■■■■■
index 2a69f3b..a944b35 100644
--- a/src/plugin_services.c
+++ b/src/plugin_services.c
@@ -9,8 +9,8 @@
99 * It reports every service the node's init system knows about:
1010 *
1111 * Linux systemd via `systemctl list-units --output=json` (falls back to the
12- * plain table on systemd < 248), enriched once by a single
13- * `systemctl show --type=service --all -p ...` pass. Inside a
12+ * plain table on systemd < 248), enriched by `systemctl show -p ...`
13+ * over the validated unit names. Inside a
1414 * container with no init system (no /run/systemd/system) it reports
1515 * init_system:"none" and lists the long-running daemons it can see in
1616 * /proc instead of pretending the node has none.
@@ -565,7 +565,7 @@ static void parse_plain_units(const char *text)
565565 }
566566 }
567567
568-/* One pass over `systemctl show --type=service --all -p ...`, whose output is
568+/* Output of `systemctl show -p ...` over a batch of unit names, whose output is
569569 * key=value blocks separated by a blank line. */
570570 static void apply_show(const char *text)
571571 {
tests/run.sh+1−1■■
index d59ea44..7b1c3d2 100644
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -382,7 +382,7 @@ grep -q 'QueryServiceConfigA' src/plugin_services.c && pass "Windows reads the s
382382 grep -q '_DARWIN_C_SOURCE' src/plugin_services.c && pass "_DARWIN_C_SOURCE is defined for Apple" || fail "_DARWIN_C_SOURCE missing"
383383 grep -q 'launchctl list' src/plugin_services.c && pass "macOS reads launchctl list" || fail "no launchctl list"
384384 grep -q 'output=json' src/plugin_services.c && pass "systemd uses --output=json first" || fail "no --output=json"
385-grep -q 'systemctl show --type=service --all' src/plugin_services.c && fail "the empty-set 'show --type= --all' form is back" || pass "show asks for units by name, not the empty --type/--all set"
385+grep -q 'capture("systemctl show --type=service --all' src/plugin_services.c && fail "the empty-set 'show --type= --all' form is back" || pass "show asks for units by name, not the empty --type/--all set"
386386 grep -q 'systemctl show -p Id' src/plugin_services.c && pass "the enrichment pass asks for units by name" || fail "no per-unit show call"
387387 grep -q 'not-found' src/plugin_services.c && pass "there is a legacy-table fallback path" || fail "no not-found handling"
388388 grep -q 'init_system' src/plugin_services.c && pass "the API reports init_system" || fail "no init_system"
389389
src/plugin_services.c+3−3■■■■■
index 2a69f3b..a944b35 100644index 2a69f3b..a944b35 100644
--- a/src/plugin_services.c--- a/src/plugin_services.c
+++ b/src/plugin_services.c+++ b/src/plugin_services.c
@@ -9,8 +9,8 @@@@ -9,8 +9,8 @@
9 * It reports every service the node's init system knows about:9 * It reports every service the node's init system knows about:
10 *10 *
11 * Linux systemd via `systemctl list-units --output=json` (falls back to the11 * Linux systemd via `systemctl list-units --output=json` (falls back to the
12- * plain table on systemd < 248), enriched once by a single12+ * plain table on systemd < 248), enriched by `systemctl show -p ...`
13- * `systemctl show --type=service --all -p ...` pass. Inside a13+ * over the validated unit names. Inside a
14 * container with no init system (no /run/systemd/system) it reports14 * container with no init system (no /run/systemd/system) it reports
15 * init_system:"none" and lists the long-running daemons it can see in15 * init_system:"none" and lists the long-running daemons it can see in
16 * /proc instead of pretending the node has none.16 * /proc instead of pretending the node has none.
@@ -565,7 +565,7 @@ static void parse_plain_units(const char *text)@@ -565,7 +565,7 @@ static void parse_plain_units(const char *text)
565 }565 }
566 }566 }
567 567
568-/* One pass over `systemctl show --type=service --all -p ...`, whose output is568+/* Output of `systemctl show -p ...` over a batch of unit names, whose output is
569 * key=value blocks separated by a blank line. */569 * key=value blocks separated by a blank line. */
570 static void apply_show(const char *text)570 static void apply_show(const char *text)
571 {571 {
tests/run.sh+1−1■■
index d59ea44..7b1c3d2 100644index d59ea44..7b1c3d2 100644
--- a/tests/run.sh--- a/tests/run.sh
+++ b/tests/run.sh+++ b/tests/run.sh
@@ -382,7 +382,7 @@ grep -q 'QueryServiceConfigA' src/plugin_services.c && pass "Windows reads the s@@ -382,7 +382,7 @@ grep -q 'QueryServiceConfigA' src/plugin_services.c && pass "Windows reads the s
382 grep -q '_DARWIN_C_SOURCE' src/plugin_services.c && pass "_DARWIN_C_SOURCE is defined for Apple" || fail "_DARWIN_C_SOURCE missing"382 grep -q '_DARWIN_C_SOURCE' src/plugin_services.c && pass "_DARWIN_C_SOURCE is defined for Apple" || fail "_DARWIN_C_SOURCE missing"
383 grep -q 'launchctl list' src/plugin_services.c && pass "macOS reads launchctl list" || fail "no launchctl list"383 grep -q 'launchctl list' src/plugin_services.c && pass "macOS reads launchctl list" || fail "no launchctl list"
384 grep -q 'output=json' src/plugin_services.c && pass "systemd uses --output=json first" || fail "no --output=json"384 grep -q 'output=json' src/plugin_services.c && pass "systemd uses --output=json first" || fail "no --output=json"
385-grep -q 'systemctl show --type=service --all' src/plugin_services.c && fail "the empty-set 'show --type= --all' form is back" || pass "show asks for units by name, not the empty --type/--all set"385+grep -q 'capture("systemctl show --type=service --all' src/plugin_services.c && fail "the empty-set 'show --type= --all' form is back" || pass "show asks for units by name, not the empty --type/--all set"
386 grep -q 'systemctl show -p Id' src/plugin_services.c && pass "the enrichment pass asks for units by name" || fail "no per-unit show call"386 grep -q 'systemctl show -p Id' src/plugin_services.c && pass "the enrichment pass asks for units by name" || fail "no per-unit show call"
387 grep -q 'not-found' src/plugin_services.c && pass "there is a legacy-table fallback path" || fail "no not-found handling"387 grep -q 'not-found' src/plugin_services.c && pass "there is a legacy-table fallback path" || fail "no not-found handling"
388 grep -q 'init_system' src/plugin_services.c && pass "the API reports init_system" || fail "no init_system"388 grep -q 'init_system' src/plugin_services.c && pass "the API reports init_system" || fail "no init_system"
389389