Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Unified Diff: tests/tpm_lite/writelimit.c

Issue 3389004: Rehaul of firmware TPM tests (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: remove leaked change Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/tpm_lite/tlcl_tests.c ('k') | utility/Makefile » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/tpm_lite/writelimit.c
diff --git a/tests/tpm_lite/writelimit.c b/tests/tpm_lite/writelimit.c
index f7d087c2203a7eed7a91f0e2bd7be54936bd3a8e..722e627ca0a666852753bcbf700dd9f080264082 100644
--- a/tests/tpm_lite/writelimit.c
+++ b/tests/tpm_lite/writelimit.c
@@ -11,50 +11,45 @@
#include <stdlib.h>
#include "tlcl.h"
+#include "tlcl_tests.h"
#include "utility.h"
-#define INDEX0 0xda70
#define TPM_MAX_NV_WRITES_NOOWNER 64
int main(int argc, char** argv) {
int i;
+
uint32_t result;
- uint8_t disable, deactivated; /* the TPM specs use these exact names */
TlclLibInit();
- TlclStartup();
- TlclSelfTestFull();
-
- TlclAssertPhysicalPresence();
-
- result = TlclGetFlags(&disable, &deactivated, NULL);
- printf("disable is %d, deactivated is %d\n", disable, deactivated);
-
- if (disable || deactivated) {
- TlclSetEnable();
- (void) TlclSetDeactivated(0);
- printf("TPM will be active after next reboot\n");
- exit(0);
- }
+ TPM_CHECK(TlclStartupIfNeeded());
+ TPM_CHECK(TlclSelfTestFull());
+ TPM_CHECK(TlclAssertPhysicalPresence());
+ TPM_CHECK(TlclForceClear());
+ TPM_CHECK(TlclSetEnable());
+ TPM_CHECK(TlclSetDeactivated(0));
for (i = 0; i < TPM_MAX_NV_WRITES_NOOWNER + 2; i++) {
printf("writing %d\n", i);
if ((result = TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i))) != TPM_SUCCESS) {
switch (result) {
case TPM_E_MAXNVWRITES:
- printf("Max NV writes exceeded - forcing clear\n");
- TlclForceClear();
- printf("Please reboot and run this program again\n");
- exit(0);
+ assert(i >= TPM_MAX_NV_WRITES_NOOWNER);
default:
- error("unexpected error code %d (0x%x)\n");
+ error("unexpected error code %d (0x%x)\n", result, result);
}
}
}
- /* Done for now.
- */
- printf("Test completed successfully\n");
+ /* Reset write count */
+ TPM_CHECK(TlclForceClear());
+ TPM_CHECK(TlclSetEnable());
+ TPM_CHECK(TlclSetDeactivated(0));
+
+ /* Try writing again. */
+ TPM_CHECK(TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i)));
+
+ printf("TEST SUCCEEDED\n");
exit(0);
}
« no previous file with comments | « tests/tpm_lite/tlcl_tests.c ('k') | utility/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698