Files
OpenCellular/tests/tpm_lite/fastenable.c
Luigi Semenzato a7e19cffbe Add new files: two tests, one common file, one program to set things up.
Change-Id: I4c9b7a937103f3978cbed6629ee4057018b80eae

More cleanup.  Also allow some tests to run even when TPM is already started.

Change-Id: I23558b96a1de55bbeca42dbf2e44f6802a0ec85b

Reorganize and standardize behavior of tests.

Change-Id: Id32fd09211a72deaa66a3dd0f973d35506ff96f2

BUG=433
TEST=ran all the tests I could run without TPM-free BIOS

Review URL: http://codereview.chromium.org/3389004
2010-09-15 17:20:36 -07:00

47 lines
1.6 KiB
C

/* Copyright (c) 2010 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.
*/
/* Testing: ForceClear and behavior of disable and permanent deactivated flags.
*
* ForceClear sets the permanent disable and deactivated flags to their default
* value of TRUE. The specs say nothing about STCLEAR flags, so they should be
* left alone. This test checks that both flags may be reset without a reboot,
* resulting in a fully enabled and activated TPM. (We know that because
* ForceClear requires that the TPM be enabled and activated to run.)
*/
#include <stdio.h>
#include "tlcl.h"
#include "tlcl_tests.h"
#include "utility.h"
int main(int argc, char** argv) {
uint8_t disable, deactivated;
int i;
TlclLibInit();
TPM_CHECK(TlclStartupIfNeeded());
TPM_CHECK(TlclSelfTestFull());
TPM_CHECK(TlclAssertPhysicalPresence());
TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
printf("disable is %d, deactivated is %d\n", disable, deactivated);
for (i = 0; i < 2; i++) {
TPM_CHECK(TlclForceClear());
TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
printf("disable is %d, deactivated is %d\n", disable, deactivated);
assert(disable == 1 && deactivated == 1);
TPM_CHECK(TlclSetEnable());
TPM_CHECK(TlclSetDeactivated(0));
TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
printf("disable is %d, deactivated is %d\n", disable, deactivated);
assert(disable == 0 && deactivated == 0);
}
printf("TEST SUCCEEDED\n");
return 0;
}