wenquan2015 opened a new pull request, #3794:
URL: https://github.com/apache/nuttx-apps/pull/3794
## Summary
Add cmocka-based test program for the SO_TIMESTAMPING socket option
under `testing/nettest/timestamp/`.
Covers all five test scenarios from the SO_TIMESTAMPING PR:
1. **SO_TIMESTAMPING setsockopt/getsockopt** — set TX flags, read back,
verify flag value
2. **SO_TIMESTAMP/SO_TIMESTAMPNS backward compatibility** — setsockopt
both options on PKT socket
3. **TX timestamping + MSG_ERRQUEUE** — send packet, recvmsg(MSG_ERRQUEUE)
returns SO_TIMESTAMPING cmsg with valid timestamp
4. **RX timestamp via SO_TIMESTAMP** — receive broadcast packet, cmsg
contains valid struct timeval timestamp
5. **TX timestamping with poll(POLLPRI)** — send packet, poll() returns
POLLPRI, then recvmsg(MSG_ERRQUEUE) returns valid TX
timestamp
Files added/modified:
- `testing/nettest/timestamp/test_timestamp.h` — header (state struct +
prototypes)
- `testing/nettest/timestamp/test_timestamp.c` — main entry, registers 5
cmocka tests
- `testing/nettest/timestamp/test_timestamp_common.c` — group
setup/teardown + all 5 test functions
- `testing/nettest/Kconfig` — add `TESTING_NET_TIMESTAMP` option
- `testing/nettest/Makefile` — add timestamp build rules
- `testing/nettest/CMakeLists.txt` — add timestamp cmake rules
## Impact
- New test program `cmocka_net_timestamp`, no impact on existing code
- Enable with `CONFIG_TESTING_NET_TIMESTAMP=y`
- Requires: `CONFIG_NET_TIMESTAMP`, `CONFIG_NET_PKT`,
`CONFIG_TESTING_CMOCKA`
## Testing
**Host:** Ubuntu 22.04 x86_64, GCC 13.1.0, cmake 3.23.0 + Ninja 1.10.1
**Target:** sim:dynconns (with `CONFIG_NET_TIMESTAMP=y`,
`CONFIG_NET_PKT=y`, `CONFIG_TESTING_CMOCKA=y`,
`CONFIG_TESTING_NET_TIMESTAMP=y`)
**Build:**
cmake -Bbuild -GNinja -DBOARD_CONFIG=sim:dynconns nuttx
enable ALLOW_MIT_COMPONENTS, LIBC_REGEX, TESTING_CMOCKA, TESTING_NET_TEST,
TESTING_NET_TIMESTAMP
ninja olddefconfig && ninja
**Runtime (TAP networking):**
nsh> cmocka_net_timestamp
[==========] timestamp_tests: Running 5 test(s).
[ RUN ] test_timestamp_setsockopt
[ OK ] test_timestamp_setsockopt
[ RUN ] test_timestamp_compat
[ OK ] test_timestamp_compat
[ RUN ] test_timestamp_tx
[ OK ] test_timestamp_tx
[ RUN ] test_timestamp_rx
[ OK ] test_timestamp_rx
[ RUN ] test_timestamp_poll
[ OK ] test_timestamp_poll
[==========] timestamp_tests: 5 test(s) run.
[ PASSED ] 5 test(s).
--
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]