common: Drop part.h from common header
[oweals/u-boot.git] / test / dm / sysreset.c
index 04d4621d9e1ab7fd388f93e1086fae4135e0ab53..5b2358ef674c5651936d94b4af35530d3e64d41a 100644 (file)
@@ -62,7 +62,6 @@ static int dm_test_sysreset_get_status(struct unit_test_state *uts)
 
        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 */
@@ -72,6 +71,7 @@ static int dm_test_sysreset_walk(struct unit_test_state *uts)
 
        /* If we generate a power sysreset, we will exit sandbox! */
        state->sysreset_allowed[SYSRESET_POWER] = false;
+       state->sysreset_allowed[SYSRESET_POWER_OFF] = false;
        ut_asserteq(-EACCES, sysreset_walk(SYSRESET_WARM));
        ut_asserteq(-EACCES, sysreset_walk(SYSRESET_COLD));
        ut_asserteq(-EACCES, sysreset_walk(SYSRESET_POWER));
@@ -91,3 +91,22 @@ static int dm_test_sysreset_walk(struct unit_test_state *uts)
        return 0;
 }
 DM_TEST(dm_test_sysreset_walk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int dm_test_sysreset_get_last(struct unit_test_state *uts)
+{
+       struct udevice *dev;
+
+       /* Device 1 is the warm sysreset device */
+       ut_assertok(uclass_get_device(UCLASS_SYSRESET, 1, &dev));
+       ut_asserteq(SYSRESET_WARM, sysreset_get_last(dev));
+
+       /* Device 2 is the cold sysreset device */
+       ut_assertok(uclass_get_device(UCLASS_SYSRESET, 2, &dev));
+       ut_asserteq(SYSRESET_POWER, sysreset_get_last(dev));
+
+       /* This is device 0, the non-DT one */
+       ut_asserteq(SYSRESET_POWER, sysreset_get_last_walk());
+
+       return 0;
+}
+DM_TEST(dm_test_sysreset_get_last, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);