[PATCH can-next v2 0/9] selftests: can: add J1939 socket and transport tests

From: Oleksij Rempel

Date: Wed Nov 04 2026 - 11:28:15 EST


net/can/j1939 has had no in-tree selftests. This series adds a kselftest
suite for the J1939 socket layer and the TP/ETP transport, run on vcan with
a CAN_RAW socket as an independent on-the-wire peer.

The timer checks are relaxed by default, for slow CI machines;
J1939_STRICT_TIMING selects tight bounds. Not covered yet: the ETP abort
and timeout paths, and a received Connection Abort on a kernel TX
session, which the stack currently ignores.

Known issue: the stack updates a session from the loopback echo of its
own CTS, RTS and DT frames, and a CAN_RAW peer can see that echo before
the stack does. A peer frame that follows quickly can then cancel the
session and fail a multi test. I have not seen this in QEMU runs. The fix
belongs in the stack, not in these tests.

I used an LLM coding assistant to write most of the test code and to
review it. I have read, edited and run all of it myself, on vcan under
QEMU.

v1: https://lore.kernel.org/all/20261014154435.3577983-1-o.rempel@xxxxxxxxxxxxxx/

---
Oleksij Rempel (9):
selftests: can: install net/lib.sh with the CAN tests
selftests: can: add J1939 test helper header and library
selftests: can: add J1939 base functional tests
selftests: can: add J1939 socket option and metadata tests
selftests: can: add J1939 addressing and concurrency tests
selftests: can: add J1939 wire-format tests against CAN_RAW
selftests: can: add J1939 TP/ETP multi-frame tests against CAN_RAW
selftests: can: cover J1939 transport abort and timeout paths
selftests: can: check SO_J1939_PROMISC receive effect

tools/testing/selftests/net/can/.gitignore | 5 +
tools/testing/selftests/net/can/Makefile | 18 +-
tools/testing/selftests/net/can/config | 2 +
tools/testing/selftests/net/can/j1939_lib.sh | 86 ++
tools/testing/selftests/net/can/j1939_tests.h | 804 +++++++++++++++++++
tools/testing/selftests/net/can/test_j1939_addr.c | 679 ++++++++++++++++
tools/testing/selftests/net/can/test_j1939_addr.sh | 4 +
tools/testing/selftests/net/can/test_j1939_base.c | 180 +++++
tools/testing/selftests/net/can/test_j1939_base.sh | 4 +
tools/testing/selftests/net/can/test_j1939_multi.c | 869 +++++++++++++++++++++
.../testing/selftests/net/can/test_j1939_multi.sh | 4 +
tools/testing/selftests/net/can/test_j1939_opts.c | 326 ++++++++
tools/testing/selftests/net/can/test_j1939_opts.sh | 4 +
tools/testing/selftests/net/can/test_j1939_wire.c | 186 +++++
tools/testing/selftests/net/can/test_j1939_wire.sh | 4 +
15 files changed, 3173 insertions(+), 2 deletions(-)
---
base-commit: 734bef548a96e8774d6eef5dfa2026c6edc4e80b
change-id: 20261104-j1939-selftests-12fc860698c0

Best regards,
--
Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>