casaroli opened a new pull request, #4004:
URL: https://github.com/apache/nuttx-apps/pull/4004

   depends-on: apache/nuttx/pull/21616
   
   ## Summary
   
   No test in nuttx-apps covers sockets on the loopback device that do not use 
IP: a `CAN_RAW` socket bound to `lo`, or a packet socket bound to `lo`. Both 
crashed the kernel (the loopback driver polls with a NULL callback). This PR 
adds two cmocka programs to `testing/nettest`, one commit each:
   
   - **testing/nettest: Add a test of bind() of a CAN socket.** 
`cmocka_net_can` (`can/`, `CONFIG_TESTING_NET_CAN`): `test_can_bind_nodev` 
(bind to an index with no device gives `ENODEV`), `test_can_bind_any` (bind to 
index 0, all CAN devices, gives 0), `test_can_bind_can0` (bind to `can0` gives 
0; skipped when there is no `can0`), `test_can_bind_todev` (`SO_BINDTODEVICE` 
to `lo`, then `write()` fails), `test_can_bind_sendto` (an unbound socket with 
`lo` in the `sendto()` address fails), `test_can_bind_lo` (bind to `lo` gives 
`ENODEV`; if it gives 0, the test writes a frame, as a program would, so it 
runs last).
   - **testing/nettest: Add a test of packet sockets on the loopback device.** 
`cmocka_net_pkt` (`pkt/`, `CONFIG_TESTING_NET_PKT`): `test_pkt_lo_send` (an 
IPv4 packet sent on `lo` by a packet socket comes back on an `ETH_P_ALL` socket 
bound to `lo`), `test_pkt_lo_frag` (the first fragment of an IPv4 packet sent 
on `lo` times out in the reassembly; the ICMP Time Exceeded message comes back; 
skipped without `NET_IPFRAG` and the ICMP stack).
   
   The tests are in their own directories and not in `others/`: `others/` 
checks internal helpers for every configuration, and these tests need their own 
options, as `tcp/` and `mcast/` have.
   
   ## Impact
   
   New tests only. Both options are `default y`, as most other nettest options: 
`TESTING_NET_CAN` depends on `NET_CAN`, `NET_LOOPBACK` and `NETDEV_IFINDEX`; 
`TESTING_NET_PKT` on `NET_PKT`, `NET_LOOPBACK` and `NET_IPv4`. No defconfig 
sets them. The other nettest programs do not change. No documentation change.
   
   ## Testing
   
   qemu-armv8a (arm64, HVF, 1 CPU), make. knsh: kernel build, the programs 
built by `make import` and run from `/system/bin`. nsh: flat build, the 
programs as builtins. Options: `NET_IPv4`, `NET_LOOPBACK`, `NETDEV_IFINDEX`, 
`NET_UDP`, `NET_ICMP`, `NET_IPFRAG`, `NET_PKT`, `NET_CAN`, `NET_SOCKOPTS`, 
`NET_BINDTODEVICE`, `DEBUG_ASSERTIONS`, `NET_PKT_WRITE_BUFFERS` in knsh only; 
for cmocka `ALLOW_MIT_COMPONENTS`, `LIBC_REGEX` and `ARCH_SETJMP_H`; 
`TESTING_NET_TEST`, `TESTING_NET_CAN`, `TESTING_NET_PKT`, `TESTING_OSTEST`. 
`TESTING_NET_OTHERS` is off: in the kernel build `others/test_others_bufpool.c` 
does not find `../../nuttx/net/utils/utils.h` (older than this PR).
   
   | Configuration | nuttx master c8c0661c997 | the nuttx PR of branch 
net-lo-fixes-up |
   |---|---|---|
   | qemu-armv8a:knsh | `cmocka_net_can`: 4 pass, 1 skipped 
(`test_can_bind_can0`: no CAN device in QEMU), then `test_can_bind_lo`: the 
kernel panics in hpwork (ELR 0). `cmocka_net_pkt`: `test_pkt_lo_send`: the 
kernel panics in hpwork (ELR 0) | `cmocka_net_can`: 6 run, 5 pass, 1 skipped; 
`cmocka_net_pkt`: 2 pass; ostest status 0 |
   | qemu-armv8a:nsh | the same as knsh | the same as knsh |
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   
   Not run: CMake builds, the protected build, sim, other arches, a real CAN 
device.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to