casaroli opened a new pull request, #3916: URL: https://github.com/apache/nuttx-apps/pull/3916
## Summary In the Android init language a line that starts with `#` (after optional whitespace) is a comment. NXInit did not know comments: a comment line before the first section stopped the parse with `-EINVAL`, so init ran no action and no service, and a comment line inside an action became a command named `#`. Only a board `init.rc` that goes through the C preprocessor at build time could hold comments. This PR makes NXInit skip a line when its first character that is not whitespace is `#`, in the same place where it skips empty lines. It adds the unit test case `test_nxinit_parser_config_skip_comments`. The NuttX PR "Documentation/nxinit: Describe comment lines in init.rc." documents the change. The two PRs go together. ## Impact An `init.rc` that NXInit reads at run time can have comment lines. A file without them does not change. ## Testing The NXInit unit tests (`CONFIG_SYSTEM_NXINIT_TEST`, cmocka) on qemu-armv8a:nsh (flat, QEMU with HVF), built in: | | without the parser change | this PR | |---|---|---| | `test_nxinit_parser_config_skip_comments` | FAILED (`-22 != 0`) | OK | | all cases | 20 of 21 passed | 21 of 21 passed | Test program `nxinitcmt.c` on qemu-armv8a:knsh (kernel, QEMU with HVF), with NXInit as the program `nxinit` and the rc file `/system/hb-init.rc`: the program writes an `init.rc` with `#` lines before the first section, inside the action (also indented) and at the end. The action removes two flag files with `unlink`. The program runs NXInit for 2 s and checks the files. | | apps master | this PR | |---|---|---| | flag files | both still there (no action ran) | both removed | | result | FAIL | PASS | ostest exits with status 0 on qemu-armv8a:knsh and qemu-armv8a:nsh (qemu-armv8a:nsh uses NXInit as its init). Build with NuttX master, each OK: qemu-armv8a:nsh (flat, arm64), qemu-armv8a:knsh (kernel, arm64), rv-virt:pnsh64 (protected, rv64) with `CONFIG_SYSTEM_NXINIT`. `tools/checkpatch.sh -c -u -m -g` 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]
