diff options
author | Tom Rini <trini@konsulko.com> | 2020-06-04 18:12:57 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-06-04 18:12:57 -0400 |
commit | 6bca655bcbc8e81a21ab27a0d1e9c711ab8e0e24 (patch) | |
tree | 047f05ad2648c4b88ff5e02187e92a9e7835e8ae /doc/README.commands | |
parent | 07d90d8bd451b9595fb0369c51f90ee2dccd5d9f (diff) | |
parent | f3e2ebede3019740ee90471acc0a29a684b59221 (diff) |
Merge branch '2020-06-04-misc-bugfixes'
- Resync checkpatch.pl (largely) with v5.7 and introduce U-Boot specific
checks in a localized area, so they aren't lost in the future.
- Complete / re-migrate some options from config headers to defconfigs
- Add dependencies to the various debug uart drivers
Diffstat (limited to 'doc/README.commands')
-rw-r--r-- | doc/README.commands | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/doc/README.commands b/doc/README.commands index 716ad227aa..229f86d8fb 100644 --- a/doc/README.commands +++ b/doc/README.commands @@ -134,3 +134,53 @@ by writing in u-boot.lds ($(srctree)/board/boardname/u-boot.lds) these .u_boot_list : { KEEP(*(SORT(.u_boot_list*))); } + +Writing tests +------------- + +All new commands should have tests. Tests for existing commands are very +welcome. + +It is fairly easy to write a test for a command. Enable it in sandbox, and +then add code that runs the command and checks the output. + +Here is an example: + +/* Test 'acpi items' command */ +static int dm_test_acpi_cmd_items(struct unit_test_state *uts) +{ + struct acpi_ctx ctx; + void *buf; + + buf = malloc(BUF_SIZE); + ut_assertnonnull(buf); + + ctx.current = buf; + ut_assertok(acpi_fill_ssdt(&ctx)); + console_record_reset(); + run_command("acpi items", 0); + ut_assert_nextline("dev 'acpi-test', type 1, size 2"); + ut_assert_nextline("dev 'acpi-test2', type 1, size 2"); + ut_assert_console_end(); + + ctx.current = buf; + ut_assertok(acpi_inject_dsdt(&ctx)); + console_record_reset(); + run_command("acpi items", 0); + ut_assert_nextline("dev 'acpi-test', type 2, size 2"); + ut_assert_nextline("dev 'acpi-test2', type 2, size 2"); + ut_assert_console_end(); + + console_record_reset(); + run_command("acpi items -d", 0); + ut_assert_nextline("dev 'acpi-test', type 2, size 2"); + ut_assert_nextlines_are_dump(2); + ut_assert_nextline("%s", ""); + ut_assert_nextline("dev 'acpi-test2', type 2, size 2"); + ut_assert_nextlines_are_dump(2); + ut_assert_nextline("%s", ""); + ut_assert_console_end(); + + return 0; +} +DM_TEST(dm_test_acpi_cmd_items, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |