Re: [PATCH can-next v4 2/9] selftests: can: add J1939 test helper header and library

From: netdev-bot+sashiko

Date: Thu Nov 19 2026 - 18:54:42 EST


Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] Baseline decision: false positive.

--

selftests: can: add J1939 test helper header and library

This commit adds the shared code for the upcoming J1939 selftests: the C
helpers in j1939_helpers.c/.h, the harness glue in j1939_tests.h, and the
j1939_lib.sh vcan setup and runner. It also adds j1939_gw, which sets up
CAN gateway rules so that the CAN_RAW peer can sit on its own vcan,
separate from the J1939 sockets.

> diff --git a/tools/testing/selftests/net/can/j1939_lib.sh b/tools/testing/selftests/net/can/j1939_lib.sh
> new file mode 100644
> index 0000000000000..796022760e487
> --- /dev/null
> +++ b/tools/testing/selftests/net/can/j1939_lib.sh

[ ... ]

> +setup()
> +{
> + vcan_setup "$CANIF"
> +
> + # shared or none: no second vcan
> + [ "$j1939_peer" = gateway ] || return 0
> +
> + if [ "$CANIF_RAW" = "$CANIF" ]; then
> + echo "SKIP: CANIF_RAW is CANIF ($CANIF); set another CANIF_RAW or J1939_SHARED_IF=1"
> + exit "$ksft_skip"
> + fi
> +
> + vcan_setup "$CANIF_RAW"
> +
> + # rtnetlink does not load can-gw on demand
> + modprobe -q can-gw 2>/dev/null
> +
> + if ! "$(dirname "$0")/j1939_gw" "$CANIF" "$CANIF_RAW"; then

[Severity: Low]
This isn't a bug, but at this patch tools/testing/selftests/net/can/config
still contains only:

CONFIG_CAN=m
CONFIG_CAN_DEV=m
CONFIG_CAN_VCAN=m

In the default gateway mode, setup() needs CAN_GW. The checks in
j1939_test_main() need CAN_J1939, and CAN_RAW too when a test passes
J1939_NEEDS_RAW:

if (can_proto_missing(SOCK_DGRAM, CAN_J1939)) {
fprintf(stderr, "# kernel lacks CAN_J1939\n");
return KSFT_SKIP;
}

A kernel built only from this fragment would skip every J1939 test.

At this patch nothing goes wrong. TEST_PROGS is still only
test_raw_filter.sh, so no test reaches j1939_lib.sh or j1939_test_main()
yet.

The next patch in the series, "selftests: can: add J1939 base functional
tests", adds the first J1939 test. In the same patch it adds
CONFIG_CAN_GW=m, CONFIG_CAN_J1939=m and CONFIG_CAN_RAW=m to the fragment,
so this is resolved later in the series.

Would it be clearer to add those options here, next to the library and
j1939_gw that depend on them, or is the current split intended?

> + echo "SKIP: cannot route $CANIF <-> $CANIF_RAW (can-gw?); try J1939_SHARED_IF=1"
> + exit "$ksft_skip"
> + fi
> +}

[ ... ]

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118-j1939-selftests-v4-0-756768d32ff2%40pengutronix.de