mirror of
https://xff.cz/git/u-boot/
synced 2025-09-08 04:02:07 +02:00
test: Add tests for sysreset_get_status
Add some tests for sysreset_get_status. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
This commit is contained in:
@@ -29,6 +29,13 @@ static int sandbox_warm_sysreset_request(struct udevice *dev,
|
|||||||
return -EINPROGRESS;
|
return -EINPROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sandbox_warm_sysreset_get_status(struct udevice *dev, char *buf, int size)
|
||||||
|
{
|
||||||
|
strlcpy(buf, "Reset Status: WARM", size);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
|
static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
|
||||||
{
|
{
|
||||||
struct sandbox_state *state = state_get_current();
|
struct sandbox_state *state = state_get_current();
|
||||||
@@ -60,8 +67,16 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
|
|||||||
return -EINPROGRESS;
|
return -EINPROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sandbox_sysreset_get_status(struct udevice *dev, char *buf, int size)
|
||||||
|
{
|
||||||
|
strlcpy(buf, "Reset Status: COLD", size);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static struct sysreset_ops sandbox_sysreset_ops = {
|
static struct sysreset_ops sandbox_sysreset_ops = {
|
||||||
.request = sandbox_sysreset_request,
|
.request = sandbox_sysreset_request,
|
||||||
|
.get_status = sandbox_sysreset_get_status,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct udevice_id sandbox_sysreset_ids[] = {
|
static const struct udevice_id sandbox_sysreset_ids[] = {
|
||||||
@@ -78,6 +93,7 @@ U_BOOT_DRIVER(sysreset_sandbox) = {
|
|||||||
|
|
||||||
static struct sysreset_ops sandbox_warm_sysreset_ops = {
|
static struct sysreset_ops sandbox_warm_sysreset_ops = {
|
||||||
.request = sandbox_warm_sysreset_request,
|
.request = sandbox_warm_sysreset_request,
|
||||||
|
.get_status = sandbox_warm_sysreset_get_status,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct udevice_id sandbox_warm_sysreset_ids[] = {
|
static const struct udevice_id sandbox_warm_sysreset_ids[] = {
|
||||||
|
@@ -45,6 +45,26 @@ static int dm_test_sysreset_base(struct unit_test_state *uts)
|
|||||||
}
|
}
|
||||||
DM_TEST(dm_test_sysreset_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
|
DM_TEST(dm_test_sysreset_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
|
||||||
|
|
||||||
|
static int dm_test_sysreset_get_status(struct unit_test_state *uts)
|
||||||
|
{
|
||||||
|
struct udevice *dev;
|
||||||
|
char msg[64];
|
||||||
|
|
||||||
|
/* Device 1 is the warm sysreset device */
|
||||||
|
ut_assertok(uclass_get_device(UCLASS_SYSRESET, 1, &dev));
|
||||||
|
ut_assertok(sysreset_get_status(dev, msg, sizeof(msg)));
|
||||||
|
ut_asserteq_str("Reset Status: WARM", msg);
|
||||||
|
|
||||||
|
/* Device 2 is the cold sysreset device */
|
||||||
|
ut_assertok(uclass_get_device(UCLASS_SYSRESET, 2, &dev));
|
||||||
|
ut_assertok(sysreset_get_status(dev, msg, sizeof(msg)));
|
||||||
|
ut_asserteq_str("Reset Status: COLD", msg);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DM_TEST(dm_test_sysreset_get_status, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
|
||||||
|
|
||||||
/* Test that we can walk through the sysreset devices */
|
/* Test that we can walk through the sysreset devices */
|
||||||
static int dm_test_sysreset_walk(struct unit_test_state *uts)
|
static int dm_test_sysreset_walk(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user