diff options
author | Furquan Shaikh <furquan@google.com> | 2015-05-25 21:49:11 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-05-29 11:29:29 +0000 |
commit | 773b5ac3a61f4ced2e0815959a6824bf8ba62f4f (patch) | |
tree | 4349fed1342677e51dafceaaf667ac84f58b4f1b /tests/vboot_api_kernel6_tests.c | |
parent | d08a3435f867700c90e33398bf104557d98bf791 (diff) | |
download | vboot-stabilize-7131.B.tar.gz |
fastboot: Add routines for unlock and lock devicestabilize-7131.B
Add support for functions to request unlock and lock of devices in
response to fastboot oem unlock/lock commands. Unlock operation is
equivalent to enabling dev mode and lock operation is equivalent to
leaving dev mode. It is the responsibility of the caller to ensure
that user confirmation is obtained before unlock/lock operations.
BUG=chrome-os-partner:40196
BRANCH=None
TEST=Compiles successfully and fastboot lock/unlock operations work as
expected on smaug. Added tests to ensure lock/unlock operations are
covered. Verified using make -j runtests.
Change-Id: Ibafe75abdd1202473009208a414f3996d537db4f
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/273182
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
Diffstat (limited to 'tests/vboot_api_kernel6_tests.c')
-rw-r--r-- | tests/vboot_api_kernel6_tests.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/vboot_api_kernel6_tests.c b/tests/vboot_api_kernel6_tests.c new file mode 100644 index 00000000..42bd279c --- /dev/null +++ b/tests/vboot_api_kernel6_tests.c @@ -0,0 +1,62 @@ +/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Tests for vboot_api_kernel.c + */ + +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "test_common.h" +#include "vboot_api.h" +#include "vboot_nvstorage.h" + +/* Mock data */ +static uint32_t virtual_dev_mode_fail; + +/** + * Reset mock data (for use before each test) + */ +static void ResetMocks(void) +{ + virtual_dev_mode_fail = 0; +} + +/* Mocks */ +uint32_t SetVirtualDevMode(int val) +{ + if (virtual_dev_mode_fail) + return VBERROR_SIMULATED; + return VBERROR_SUCCESS; +} + +static void VbUnlockDeviceTest(void) +{ + ResetMocks(); + TEST_EQ(VbUnlockDevice(), 0, "unlock success"); + + ResetMocks(); + virtual_dev_mode_fail = 1; + TEST_EQ(VbUnlockDevice(), VBERROR_TPM_SET_BOOT_MODE_STATE, + "set dev fail"); +} + +static void VbLockDeviceTest(void) +{ + ResetMocks(); + TEST_EQ(VbLockDevice(), 0, "lock success"); +} + +int main(void) +{ + VbUnlockDeviceTest(); + VbLockDeviceTest(); + + if (vboot_api_stub_check_memory()) + return 255; + + return gTestSuccess ? 0 : 255; +} |