Skip to content

tests: the one-line skip_all is copied into five scripts; lib.sh can carry it #1186

Open

Description

@lneto

(posted by an agent, not by @lneto)

skip_all() { ktap_header; ktap_plan 1; ktap_skip "$1"; ktap_totals; exit 0; } is written identically in tests/device/held.sh:53, tests/rcu/entry_release.sh:42 and tests/runtime/collected.sh:29, and #1168 and #1169 copy it into tests/device/returns.sh and tests/control/session.sh. tests/lib.sh, which every test sources, has no skip helper, so each new test copies it again. Moving the one-liner into tests/lib.sh and deleting the copies is a tree-wide change of its own; the scripts whose skip_all skips each planned case, in notifier, probe, sched, skb, tc and xdp, keep theirs.

Found in the review of #1169.

Update: more than forty scripts skip a whole suite with echo "# SKIP: ..."; ktap_totals; exit 0 after ktap_plan N (61 such lines in 47 files at b64c6f9). The comment is not a KTAP result: the plan is left unmet, ktap_totals prints skip:0 since only ktap_skip counts, and tests/run.sh, which sums the # Totals: lines, reports no skip for the script. The counted form, one ktap_skip per planned case, is in tests/crypto/context.sh and tests/fsnotify/run.sh. Three scripts also spell the same check before a stimulus only a fixed module survives, the loaded module is the installed one and carries the refusal: tests/runtime/self_stop.sh, tests/netlink/rtnl.sh and #1247's tests/cpu/run.sh. tests/lib.sh can carry that check beside skip_all, and the sweep that moves the copies can turn the comments into counted skips. Found in the review of #1247.

Update: tests: the check that the loaded module is the installed build and carries a refusal is open coded in each test that needs it (#1342)

Before a stimulus that would wedge the host on a build without the fix, tests/netlink/rtnl.sh, tests/runtime/self_stop.sh, tests/socket/rtnl.sh and tests/crypto/context.sh each spell the same test: /sys/module//srcversion equal to modinfo -F srcversion <m>, and a grep -aF of the refusal in modinfo -n <m>. tests/hid/context.sh and tests/darken/run.sh from #1342 add two more copies, and #1194 and #1276 carry one each. A single helper in tests/lib.sh, for example carries <module> <message>, would replace them all and keep one spelling of what AGENTS.md, Tests, asks for.

Update: #1276 merged its copy as tests/runtime/percpu_netfilter.sh, so tests/runtime now spells the check twice, there and in self_stop.sh, which skips on each half separately where tests/netlink/rtnl.sh has one skip. A carries <module> <message> helper in tests/lib.sh folds both into one line each. Found in the review of #1276.

Update: tests: the one-line skip_all is spelled in five scripts instead of lib.sh (#1509)

Five test scripts define the same one-line skip_all() { ktap_header; ktap_plan 1; ktap_skip "$1"; ktap_totals; exit 0; }: tests/device/held.sh, tests/device/returns.sh, tests/runtime/collected.sh, tests/rcu/entry_release.sh and tests/hid/device.sh (#1509). tests/lib.sh, which every test sources, has ktap_skip but no way to skip a whole test. The multi-line variants in tests/notifier and tests/probe skip one line per planned case and do not fit the same helper.

Fix: define skip_all once in tests/lib.sh and drop the five copies.

Contract: undocumented

Update: tests: skip_all is spelled in five scripts and N-skip loops in four more; tests/lib.sh carries neither (#1551)

Two shapes are copied across test scripts instead of living in tests/lib.sh.

  1. One case that skips the whole script. This one-liner is spelled identically in five places:

    skip_all() { ktap_header; ktap_plan 1; ktap_skip "$1"; ktap_totals; exit 0; }

  2. N skips under a plan already printed, then the totals and exit:

    tests/notifier/{inside,stop,replay}.sh and tests/probe/{raise,dropreason}.sh define multi-line skip_all variants worth reading alongside.

Fix: one helper per shape in tests/lib.sh, next to ktap_skip, and the scripts call it. For example ktap_skip_all <reason> for the first shape, and ktap_skip_n <count> <reason> followed by the totals and exit 0 for the second. This touches only tests.

Contract: undocumented for shell; AGENTS.md Lua style, read here by analogy: "Code two scripts of one directory repeat goes in a module beside them that both require" (tests/lib.sh is the shell scripts' shared module)

Update: tests: the one-line skip_all is copied into five scripts; lib.sh can carry it (#1643)

#1643 adds a twelfth identical copy, skip_all() { ktap_header; ktap_plan 1; ktap_skip "$1"; ktap_totals; exit 0; } in tests/rcu/foreach_overflow.sh. At 3fb2799, eleven scripts carry the same line, among them tests/device/held.sh, tests/rcu/entry_release.sh, tests/rcu/cycle_release.sh and tests/runtime/collected.sh, and tests/lib.sh still has ktap_skip but nothing that skips a whole test. A skip_all in tests/lib.sh, with the copies deleted in one sweep, ends the copying. The variants that skip one line per planned case keep theirs. Found in the review of #1643.

Contract: undocumented (test harness cleanup; AGENTS.md C style: "When a two line pattern repeats in every method, collapse it into one helper or macro")

Update: tests/netlink: route_adddel.sh and rule_adddel.sh add two more uncounted whole-script skips (#1559)

On a kernel without CONFIG_IP_MULTIPLE_TABLES, the policy-routing skip in tests/netlink/route_adddel.sh (after ktap_plan 4) and tests/netlink/rule_adddel.sh (after ktap_plan 5) prints # SKIP: ..., calls ktap_totals and exits 0. That leaves the KTAP plan unmet and prints # Totals: pass:0 fail:0 skip:0. tests/run.sh sums those Totals lines, so it reports neither script as passed or skipped. Seen by running both scripts with an ip shim that refuses -4 rule show. Each file's own module skip has the same shape. tests/netlink/list_family.sh, which uses the same probe, counts its skips with one ktap_skip per planned case. Fix: the sweep #1186 describes, turning the echo "# SKIP" form into counted skips through a tests/lib.sh helper, covers these two sites with the rest.

Contract: undocumented: .agents/rules/tests.md says only "skip, do not fail, when the kernel lacks a required config", which both scripts meet

Update: tests/netlink: route_adddel.sh and rule_adddel.sh add two more uncounted whole-script skips (update to #1186) (#1798)

On a kernel without CONFIG_IP_MULTIPLE_TABLES, the policy-routing skip in tests/netlink/route_adddel.sh (after ktap_plan 4) and tests/netlink/rule_adddel.sh (after ktap_plan 5) prints # SKIP: ..., calls ktap_totals and exits 0. That leaves the KTAP plan unmet and prints # Totals: pass:0 fail:0 skip:0. tests/run.sh sums those Totals lines, so it reports neither script as passed or skipped. Seen by running both scripts with an ip shim that refuses -4 rule show. Each file's own module skip has the same shape. tests/netlink/list_family.sh, which uses the same probe, counts its skips with one ktap_skip per planned case. Fix: the sweep #1186 describes, turning the echo "# SKIP" form into counted skips through a tests/lib.sh helper, covers these two sites with the rest.

Contract: undocumented: .agents/rules/tests.md says only "skip, do not fail, when the kernel lacks a required config", which both scripts meet

Update: tests: passed() is copied into three tests/monitor scripts and tests/thread/driver.sh has the same read; tests/lib.sh carries none (#1879)

Three scripts in tests/monitor define the same one-line passed() { dmesg_since | grep -qE "PASS[[:space:]]$1\$"; }: collector.sh:27 and name.sh:26 on master, and hook.sh:36 on the monitor-hook-off-lock branch. Each one follows it with the same loop over its case names: passed "$case" || fail "$case: ..."; ktap_pass "$case". tests/thread/driver.sh writes the same read as reported() plus a verdict() that passes or fails a case, but only for the thread suite. tests/lib.sh, which every script sources, has no helper that reads the line tests.lib prints for a passed case, so each new suite that runs its cases through tests.lib copies it again.

Fix: move reported/verdict from tests/thread/driver.sh into tests/lib.sh, next to ktap_pass (or a ktap_cases <case>... that runs the loop), and delete the copies in tests/monitor/{collector,name,hook}.sh, in the same sweep that moves skip_all and the carries check. This touches only tests.

Found in the review of the monitor-hook-off-lock branch (#1878).

Contract: undocumented; by analogy, .agents/rules/lua.md: "Code two scripts of one directory repeat goes in a module beside them that both require" (tests/lib.sh is the shell scripts' shared module)

Activity

  1. added
    severity: lowDocumentation, tests or cleanup
    complexity: smallOne line or one file, with a trivial or existing test
    on Sep 26, 2026
  2. added this to the backlog milestone on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity: smallOne line or one file, with a trivial or existing testseverity: lowDocumentation, tests or cleanup

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions