mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 03:15:00 +00:00
bootstd: Create a function to reset USB
Set up a function for this, since it needs to be used from multiple test files. This test file is only used on sandbox, where USB is enabled, so drop the local declaration of usb_started Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
13a29ec40c
commit
a3fab7d1fb
3 changed files with 20 additions and 13 deletions
|
@ -16,13 +16,6 @@
|
||||||
#include <test/ut.h>
|
#include <test/ut.h>
|
||||||
#include "bootstd_common.h"
|
#include "bootstd_common.h"
|
||||||
|
|
||||||
/* Allow reseting the USB-started flag */
|
|
||||||
#if defined(CONFIG_USB_HOST) || defined(CONFIG_USB_GADGET)
|
|
||||||
extern bool usb_started;
|
|
||||||
#else
|
|
||||||
#include <usb.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Check 'bootdev list' command */
|
/* Check 'bootdev list' command */
|
||||||
static int bootdev_test_cmd_list(struct unit_test_state *uts)
|
static int bootdev_test_cmd_list(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -197,7 +190,7 @@ static int bootdev_test_order(struct unit_test_state *uts)
|
||||||
test_set_skip_delays(true);
|
test_set_skip_delays(true);
|
||||||
|
|
||||||
/* Start up USB which gives us three additional bootdevs */
|
/* Start up USB which gives us three additional bootdevs */
|
||||||
usb_started = false;
|
bootstd_reset_usb();
|
||||||
ut_assertok(run_command("usb start", 0));
|
ut_assertok(run_command("usb start", 0));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -313,7 +306,7 @@ static int bootdev_test_prio(struct unit_test_state *uts)
|
||||||
test_set_eth_enable(false);
|
test_set_eth_enable(false);
|
||||||
|
|
||||||
/* Start up USB which gives us three additional bootdevs */
|
/* Start up USB which gives us three additional bootdevs */
|
||||||
usb_started = false;
|
bootstd_reset_usb();
|
||||||
ut_assertok(run_command("usb start", 0));
|
ut_assertok(run_command("usb start", 0));
|
||||||
|
|
||||||
ut_assertok(bootstd_test_drop_bootdev_order(uts));
|
ut_assertok(bootstd_test_drop_bootdev_order(uts));
|
||||||
|
@ -352,7 +345,7 @@ static int bootdev_test_hunter(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
struct bootstd_priv *std;
|
struct bootstd_priv *std;
|
||||||
|
|
||||||
usb_started = false;
|
bootstd_reset_usb();
|
||||||
test_set_skip_delays(true);
|
test_set_skip_delays(true);
|
||||||
|
|
||||||
/* get access to the used hunters */
|
/* get access to the used hunters */
|
||||||
|
@ -392,7 +385,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts)
|
||||||
struct bootstd_priv *std;
|
struct bootstd_priv *std;
|
||||||
|
|
||||||
test_set_skip_delays(true);
|
test_set_skip_delays(true);
|
||||||
usb_started = false;
|
bootstd_reset_usb();
|
||||||
|
|
||||||
/* get access to the used hunters */
|
/* get access to the used hunters */
|
||||||
ut_assertok(bootstd_get_priv(&std));
|
ut_assertok(bootstd_get_priv(&std));
|
||||||
|
@ -520,7 +513,7 @@ BOOTSTD_TEST(bootdev_test_bootable, UTF_DM | UTF_SCAN_FDT);
|
||||||
/* Check hunting for bootdev of a particular priority */
|
/* Check hunting for bootdev of a particular priority */
|
||||||
static int bootdev_test_hunt_prio(struct unit_test_state *uts)
|
static int bootdev_test_hunt_prio(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
usb_started = false;
|
bootstd_reset_usb();
|
||||||
test_set_skip_delays(true);
|
test_set_skip_delays(true);
|
||||||
|
|
||||||
ut_assertok(bootdev_hunt_prio(BOOTDEVP_4_SCAN_FAST, false));
|
ut_assertok(bootdev_hunt_prio(BOOTDEVP_4_SCAN_FAST, false));
|
||||||
|
@ -548,7 +541,7 @@ static int bootdev_test_hunt_label(struct unit_test_state *uts)
|
||||||
struct bootstd_priv *std;
|
struct bootstd_priv *std;
|
||||||
int mflags;
|
int mflags;
|
||||||
|
|
||||||
usb_started = false;
|
bootstd_reset_usb();
|
||||||
|
|
||||||
/* get access to the used hunters */
|
/* get access to the used hunters */
|
||||||
ut_assertok(bootstd_get_priv(&std));
|
ut_assertok(bootstd_get_priv(&std));
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <memalign.h>
|
#include <memalign.h>
|
||||||
#include <mmc.h>
|
#include <mmc.h>
|
||||||
|
#include <usb.h>
|
||||||
#include <linux/log2.h>
|
#include <linux/log2.h>
|
||||||
#include <test/suites.h>
|
#include <test/suites.h>
|
||||||
#include <test/ut.h>
|
#include <test/ut.h>
|
||||||
|
@ -88,6 +89,11 @@ int bootstd_test_check_mmc_hunter(struct unit_test_state *uts)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bootstd_reset_usb(void)
|
||||||
|
{
|
||||||
|
usb_started = false;
|
||||||
|
}
|
||||||
|
|
||||||
int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
{
|
{
|
||||||
struct unit_test *tests = UNIT_TEST_SUITE_START(bootstd_test);
|
struct unit_test *tests = UNIT_TEST_SUITE_START(bootstd_test);
|
||||||
|
|
|
@ -53,4 +53,12 @@ int bootstd_setup_for_tests(void);
|
||||||
*/
|
*/
|
||||||
int bootstd_test_check_mmc_hunter(struct unit_test_state *uts);
|
int bootstd_test_check_mmc_hunter(struct unit_test_state *uts);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bootstd_reset_usb() - Reset the USB subsystem
|
||||||
|
*
|
||||||
|
* Resets USB so that it can be started (and scanning) again. This is useful in
|
||||||
|
* tests which need to use USB.
|
||||||
|
*/
|
||||||
|
void bootstd_reset_usb(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue