From: Mehmet Fide <[email protected]> do_bootd() only runs the bootcmd environment variable, but it lives in cmd/bootm.c, which made CMD_BOOTD depend on CMD_BOOTM. The four boards that disable bootm therefore have no "boot" or "bootd" command even though the implementation would work for them. Move the code to its own file and drop the dependency.
Changes in v2, all in patch 2/2 and all from Simon's review: - drop the CONFIG_CONSOLE_RECORD ifdef around the test object and put the entry next to the bdinfo line; UTF_CONSOLE already makes the runner skip the test when console recording is unavailable - do not depend on the shell for the return value leg: 'false' is a builtin of the modern hush only, and sandbox_defconfig selects the old one, so the leg passed for the wrong reason. Use an unknown command, which fails in either parser, and match only the start of the complaint because the two parsers word it differently - save bootcmd with env_get() and restore it at the end, so test ordering cannot be affected - assert the recursion guard, as suggested. Doing it needs a note: with CONFIG_HUSH_PARSER, run_command() hands the string to the parser and drops its flag argument, so CMD_FLAG_BOOTD never reaches cmd_process() and the guard cannot be reached that way. Calling do_bootd() directly does not reach it either, since the guard sits in cmd_process(). The test therefore calls cmd_process() with the flag, and sets bootcmd to an echo that would show up if the guard ever let it through Patch 1/2 is unchanged and carries Tom's Reviewed-by. Both patches are on top of baa64b2f892. "ut cmd" on sandbox runs 14 tests with no failures, the new one included. checkpatch reports two things I left as they are: no MAINTAINERS entry covers cmd/bootm.c, so the new cmd/bootd.c does not need one either, and "Possible new command - make sure you add a test" is what 2/2 does. Mehmet Fide (2): cmd: allow bootd without bootm test: cmd: add a test for bootd cmd/Kconfig | 3 +-- cmd/Makefile | 1 + cmd/bootd.c | 30 +++++++++++++++++++++ cmd/bootm.c | 24 ----------------- test/cmd/Makefile | 1 + test/cmd/bootd.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 99 insertions(+), 26 deletions(-) create mode 100644 cmd/bootd.c create mode 100644 test/cmd/bootd.c -- 2.54.0
