]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bootstd: Drop delays in the tests
authorSimon Glass <sjg@chromium.org>
Sat, 30 Jul 2022 21:52:16 +0000 (15:52 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 12 Aug 2022 12:14:24 +0000 (08:14 -0400)
Some tests go as far as booting a distribution. In this case a menu is
presented to the user, with a two-second timeout. This adds a total of
12 seconds to the test runs at present.

Avoid this by inserting a response using the console-recording feature.

Signed-off-by: Simon Glass <sjg@chromium.org>
test/boot/bootflow.c

index 1ebb789e97bc9689cdf56f16af9a76b2a8d034a6..a2ed8ac774f973329a3e30b2ebe7c072e6c99c2c 100644 (file)
 #include <test/ut.h>
 #include "bootstd_common.h"
 
+static int inject_response(struct unit_test_state *uts)
+{
+       /*
+        * The image being booted presents a menu of options:
+        *
+        * Fedora-Workstation-armhfp-31-1.9 Boot Options.
+        * 1:   Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
+        * Enter choice:
+        *
+        * Provide input for this, to avoid waiting two seconds for a timeout.
+        */
+       ut_asserteq(2, console_in_puts("1\n"));
+
+       return 0;
+}
+
 /* Check 'bootflow scan/list' commands */
 static int bootflow_cmd(struct unit_test_state *uts)
 {
@@ -188,6 +204,7 @@ BOOTSTD_TEST(bootflow_cmd_info, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
 static int bootflow_scan_boot(struct unit_test_state *uts)
 {
        console_record_reset_enable();
+       ut_assertok(inject_response(uts));
        ut_assertok(run_command("bootflow scan -b", 0));
        ut_assert_nextline(
                "** Booting bootflow 'mmc1.bootdev.part_1' with syslinux");
@@ -351,6 +368,8 @@ static int bootflow_iter_disable(struct unit_test_state *uts)
        ut_assertok(bootstd_test_drop_bootdev_order(uts));
 
        bootstd_clear_glob();
+       console_record_reset_enable();
+       ut_assertok(inject_response(uts));
        ut_assertok(run_command("bootflow scan -lb", 0));
 
        /* Try to boot the bootmgr flow, which will fail */
@@ -358,6 +377,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts)
        ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
        ut_asserteq(3, iter.num_methods);
        ut_asserteq_str("sandbox", iter.method->name);
+       ut_assertok(inject_response(uts));
        ut_asserteq(-ENOTSUPP, bootflow_run_boot(&iter, &bflow));
 
        ut_assert_skip_to_line("Boot method 'sandbox' failed and will not be retried");
@@ -382,6 +402,8 @@ static int bootflow_cmd_boot(struct unit_test_state *uts)
        ut_assert_console_end();
        ut_assertok(run_command("bootflow select 0", 0));
        ut_assert_console_end();
+
+       ut_assertok(inject_response(uts));
        ut_asserteq(1, run_command("bootflow boot", 0));
        ut_assert_nextline(
                "** Booting bootflow 'mmc1.bootdev.part_1' with syslinux");