summaryrefslogtreecommitdiff
path: root/tests/vb2_ec_sync_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/vb2_ec_sync_tests.c')
-rw-r--r--tests/vb2_ec_sync_tests.c98
1 files changed, 30 insertions, 68 deletions
diff --git a/tests/vb2_ec_sync_tests.c b/tests/vb2_ec_sync_tests.c
index 80b48908..ad747e09 100644
--- a/tests/vb2_ec_sync_tests.c
+++ b/tests/vb2_ec_sync_tests.c
@@ -34,9 +34,7 @@ static int shutdown_request_calls_left;
static vb2_error_t ec_vboot_done_retval;
static int ec_vboot_done_calls;
-static uint32_t screens_displayed[8];
-static uint32_t screens_count = 0;
-
+static int mock_display_available;
static uint8_t mock_ec_ro_hash[32];
static uint8_t mock_ec_rw_hash[32];
static uint8_t hmir[32];
@@ -61,10 +59,11 @@ static void ResetMocks(void)
vb2_nv_init(ctx);
sd = vb2_get_sd(ctx);
- sd->flags |= VB2_SD_FLAG_DISPLAY_AVAILABLE;
memset(&gbb, 0, sizeof(gbb));
+ mock_display_available = 1;
+
ec_ro_updated = 0;
ec_rw_updated = 0;
ec_ro_protected = 0;
@@ -94,9 +93,6 @@ static void ResetMocks(void)
update_hash = 42;
- memset(screens_displayed, 0, sizeof(screens_displayed));
- screens_count = 0;
-
vb2api_secdata_kernel_create(ctx);
vb2_secdata_kernel_init(ctx);
@@ -182,6 +178,9 @@ vb2_error_t vb2ex_ec_update_image(enum vb2_firmware_selection select)
if (update_retval)
return update_retval;
+ if (!mock_display_available)
+ return VBERROR_REBOOT_REQUIRED;
+
if (select == VB_SELECT_FIRMWARE_READONLY) {
ec_ro_updated = 1;
mock_ec_ro_hash[0] = update_hash;
@@ -192,15 +191,6 @@ vb2_error_t vb2ex_ec_update_image(enum vb2_firmware_selection select)
return VB2_SUCCESS;
}
-vb2_error_t VbDisplayScreen(struct vb2_context *c, uint32_t screen, int force,
- const VbScreenData *data)
-{
- if (screens_count < ARRAY_SIZE(screens_displayed))
- screens_displayed[screens_count++] = screen;
-
- return VB2_SUCCESS;
-}
-
vb2_error_t vb2ex_ec_vboot_done(struct vb2_context *c)
{
ec_vboot_done_calls++;
@@ -494,58 +484,30 @@ static void VbSoftwareSyncTest(void)
TEST_EQ(ec_rw_protected, 0, " ec rw protected");
TEST_EQ(ec_run_image, 0, " ec run image");
- /* Tests related to slow update wait screen */
- if (EC_SLOW_UPDATE) {
- ResetMocks();
- mock_ec_rw_hash[0]++;
- test_ssync(0, 0, "Slow update");
- TEST_EQ(ec_ro_updated, 0, " ec ro updated");
- TEST_EQ(ec_rw_updated, 1, " ec rw updated");
- TEST_EQ(ec_ro_protected, 1, " ec ro protected");
- TEST_EQ(ec_rw_protected, 1, " ec rw protected");
- TEST_EQ(ec_run_image, 1, " ec run image");
- TEST_EQ(screens_displayed[0], VB_SCREEN_WAIT, " wait screen");
-
- ResetMocks();
- mock_ec_rw_hash[0]++;
- sd->flags &= ~VB2_SD_FLAG_DISPLAY_AVAILABLE;
- test_ssync(VBERROR_REBOOT_REQUIRED, 0,
- "Slow update - reboot for display");
- TEST_EQ(ec_ro_updated, 0, " ec ro updated");
- TEST_EQ(ec_rw_updated, 0, " ec rw updated");
- TEST_EQ(ec_ro_protected, 0, " ec ro protected");
- TEST_EQ(ec_rw_protected, 0, " ec rw protected");
- TEST_EQ(ec_run_image, 0, " ec run image");
-
- ResetMocks();
- mock_ec_rw_hash[0]++;
- vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 1);
- test_ssync(VB2_SUCCESS, 0,
- "Slow update with display request");
- TEST_EQ(ec_ro_updated, 0, " ec ro updated");
- TEST_EQ(ec_rw_updated, 1, " ec rw updated");
- TEST_EQ(ec_ro_protected, 1, " ec ro protected");
- TEST_EQ(ec_rw_protected, 1, " ec rw protected");
- TEST_EQ(ec_run_image, 1, " ec run image");
- TEST_EQ(screens_displayed[0], VB_SCREEN_WAIT, " wait screen");
- TEST_EQ(vb2_nv_get(ctx, VB2_NV_DISPLAY_REQUEST), 1,
- " DISPLAY_REQUEST left untouched");
-
- ResetMocks();
- mock_ec_rw_hash[0]++;
- vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 0);
- test_ssync(VB2_SUCCESS, 0,
- "Slow update without display request "
- "(no reboot needed)");
- TEST_EQ(ec_ro_updated, 0, " ec ro updated");
- TEST_EQ(ec_rw_updated, 1, " ec rw updated");
- TEST_EQ(ec_ro_protected, 1, " ec ro protected");
- TEST_EQ(ec_rw_protected, 1, " ec rw protected");
- TEST_EQ(ec_run_image, 1, " ec run image");
- TEST_EQ(screens_displayed[0], VB_SCREEN_WAIT, " wait screen");
- TEST_EQ(vb2_nv_get(ctx, VB2_NV_DISPLAY_REQUEST), 0,
- " DISPLAY_REQUEST left untouched");
- }
+ /* Display not available - RW */
+ ResetMocks();
+ mock_ec_rw_hash[0]++;
+ mock_display_available = 0;
+ test_ssync(VBERROR_REBOOT_REQUIRED, 0,
+ "Reboot for display - ec rw");
+ TEST_EQ(ec_ro_updated, 0, " ec ro updated");
+ TEST_EQ(ec_rw_updated, 0, " ec rw updated");
+ TEST_EQ(ec_ro_protected, 0, " ec ro protected");
+ TEST_EQ(ec_rw_protected, 0, " ec rw protected");
+ TEST_EQ(ec_run_image, 0, " ec run image");
+
+ /* Display not available - RO */
+ ResetMocks();
+ vb2_nv_set(ctx, VB2_NV_TRY_RO_SYNC, 1);
+ mock_ec_ro_hash[0]++;
+ mock_display_available = 0;
+ test_ssync(VBERROR_REBOOT_REQUIRED, 0,
+ "Reboot for display - ec ro");
+ TEST_EQ(ec_ro_updated, 0, " ec ro updated");
+ TEST_EQ(ec_rw_updated, 0, " ec rw updated");
+ TEST_EQ(ec_ro_protected, 0, " ec ro protected");
+ TEST_EQ(ec_rw_protected, 0, " ec rw protected");
+ TEST_EQ(ec_run_image, 1, " ec run image");
/* RW cases, no update */
ResetMocks();