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

   ## Summary
   
   POSIX says that `"--"` ends the options: getopt() returns -1 and `optind` is 
the argument after it. A `"-"` is an operand: getopt() returns -1 and `optind` 
is the `"-"`. testing/ostest/getopt.c has no case for either.
   
   This PR adds six cases to the getopt() test of ostest: `"--"` and `"-"` for 
getopt(), getopt_long() and getopt_long_only(). Each case also checks `optind` 
after the last call, with a new small helper.
   
   The first commit adds the line `long_options[n].name = "OptionA";` of 
getopt.c to `.codespell-ignore-lines`: codespell reads `OptionA` as a 
misspelled "optional", and the check reads the whole file that the second 
commit changes.
   
   depends-on: apache/nuttx/pull/21564
   
   ## Impact
   
   ostest only. On a NuttX without apache/nuttx#21564, the new cases fail 
(ASSERT in getopt_test()).
   
   ## Testing
   
   - qemu-armv8a:nsh (flat build, arm64, QEMU) with apache/nuttx#21564: the 
getopt() test of ostest runs the six new cases; ostest exits 0.
   - The same on nuttx master: `ERROR: optind=2 (expected 3)` in the first new 
case, an assertion, and ostest exits with status 256.
   - The six new cases give the same results with the macOS libc 
(`POSIXLY_CORRECT`, a reset of getopt() before each case).
   
   `tools/checkpatch.sh -c -u -m -g origin/master..HEAD` passes.
   


-- 
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