Files
OpenCellular/tests/vboot_api_kernel6_tests.c
Randall Spangler 559a110f33 vboot: use malloc and free directly
Originally, vboot1 code used VbExMalloc() and VbExFree() since it needed
to talk to EFI firmware that didn't have standard malloc() and free().
Now, coreboot and depthcharge implement them as wrappers around those
standard calls.  vboot2 code already calls them directly, so let vboot1
code do that too.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I49ad0e32e38d278dc3589bfaf494bcf0e4b0a4bd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400905
2016-11-06 02:33:50 +00:00

60 lines
1.1 KiB
C

/* 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();
return gTestSuccess ? 0 : 255;
}