Repository navigation
testing/libc/inetntop: Add a test of inet_ntop() - #4024
Merged
Merged
Conversation
No test in nuttx-apps checks inet_ntop(). This test converts IPv6 addresses with inet_ntop(AF_INET6) and compares the text with the recommended form of RFC 5952: "::" only for the longest run of two or more 0 fields (the first one on a tie), no "::" for one 0 field, and lowercase hexadecimal. The IPv4-mapped address (::ffff:127.0.0.1) and the IPv4-compatible address (::1.2.3.4) end in the dotted-decimal form; :: and ::1 do not. glibc gives the same text for each case. Each case also checks the size of the buffer, for AF_INET6 and AF_INET: the call succeeds with strlen() + 1 bytes and fails with ENOSPC with strlen() bytes. The program prints PASS or FAIL for each case and returns the number of errors. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
acassis
approved these changes
Nov 11, 2026
xiaoxiang781216
approved these changes
Nov 11, 2026
casaroli
marked this pull request as ready for review
November 11, 2026 19:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
No test in nuttx-apps checks
inet_ntop(). This PR addstesting/libc/inetntop. It converts 25 IPv6 addresses withinet_ntop(AF_INET6)and compares the text with the recommended form of RFC 5952:::only for the longest run of two or more 0 fields, the first one on a tie (1::2:0:0:3:4,1:0:0:2::3), and no::for one 0 field (1:0:2:3:4:5:6:7,2001:db8:0:1:1:1:1:1).::ffff:127.0.0.1,::ffff:0.0.0.0) and an IPv4-compatible address (::1.2.3.4), but not for::,::1,::102,::fffe:102:304,1::ffff:102:304or64:ff9b::c000:221.Each case, and 4
AF_INETcases, also checks the size of the buffer: the call succeeds withstrlen() + 1bytes and fails with ENOSPC withstrlen()bytes.The program prints PASS or FAIL for each case and returns the number of errors. It needs IPv4 and IPv6 address conversions (
NET_IPv4/NET_IPv6orLIBC_IPv4_ADDRCONV/LIBC_IPv6_ADDRCONV).Impact
New test only,
default nlike the other tests in testing/libc. No change to other code.Testing
The expected texts are the glibc 2.43 results: the same source built on fedora x86_64 against glibc passes all 29 cases.
EXTRAFLAGS="-Wno-cpp -Werror", nuttx master 03aea786390 vs the nuttx PR, withLIBC_IPv4_ADDRCONV,LIBC_IPv6_ADDRCONVandTESTING_INETNTOP:On master the 37 errors are 28 ENOSPC with a buffer that fits and 9 wrong texts. ostest: status 0 in all runs. No warnings.
tools/checkpatch.sh -c -u -m -g origin/master..HEADpasses.