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

Side by Side Diff: tests/tpm_lite/globallock.c

Issue 6349091: Improve error messages from tests (Closed) Base URL: http://git.chromium.org/git/vboot_reference.git@master
Patch Set: Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/tpm_lite/redefine_unowned.c » ('j') | tests/tpm_lite/tlcl_tests.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* Test of two-stage locking using bGlobalLock and PP. 6 /* Test of two-stage locking using bGlobalLock and PP.
7 */ 7 */
8 8
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 13 matching lines...) Expand all
24 TPM_CHECK(TlclSelfTestFull()); 24 TPM_CHECK(TlclSelfTestFull());
25 TPM_CHECK(TlclAssertPhysicalPresence()); 25 TPM_CHECK(TlclAssertPhysicalPresence());
26 TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x))); 26 TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)));
27 TPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &zero, sizeof(uint32_t))); 27 TPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &zero, sizeof(uint32_t)));
28 TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x))); 28 TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
29 TPM_CHECK(TlclWrite(INDEX1, (uint8_t*) &zero, sizeof(uint32_t))); 29 TPM_CHECK(TlclWrite(INDEX1, (uint8_t*) &zero, sizeof(uint32_t)));
30 TPM_CHECK(TlclSetGlobalLock()); 30 TPM_CHECK(TlclSetGlobalLock());
31 31
32 // Verifies that write to index0 fails. 32 // Verifies that write to index0 fails.
33 x = 1; 33 x = 1;
34 result = TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)); 34 TPM_EXPECT(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)), TPM_E_AREA_LOCKED);
35 assert(result == TPM_E_AREA_LOCKED);
36 TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x))); 35 TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)));
37 assert(x == 0); 36 assert(x == 0);
38 37
39 // Verifies that write to index1 is still possible. 38 // Verifies that write to index1 is still possible.
40 x = 2; 39 x = 2;
41 TPM_CHECK(TlclWrite(INDEX1, (uint8_t*) &x, sizeof(x))); 40 TPM_CHECK(TlclWrite(INDEX1, (uint8_t*) &x, sizeof(x)));
42 TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x))); 41 TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
43 assert(x == 2); 42 assert(x == 2);
44 43
45 // Turns off PP. 44 // Turns off PP.
46 TlclLockPhysicalPresence(); 45 TlclLockPhysicalPresence();
47 46
48 // Verifies that write to index1 fails. 47 // Verifies that write to index1 fails.
49 x = 3; 48 x = 3;
50 result = TlclWrite(INDEX1, (uint8_t*) &x, sizeof(x)); 49 TPM_EXPECT(TlclWrite(INDEX1, (uint8_t*) &x, sizeof(x)), TPM_E_BAD_PRESENCE);
51 assert(result == TPM_E_BAD_PRESENCE);
52 TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x))); 50 TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
53 assert(x == 2); 51 assert(x == 2);
54 printf("TEST SUCCEEDED\n"); 52 printf("TEST SUCCEEDED\n");
55 exit(0); 53 exit(0);
56 } 54 }
OLDNEW
« no previous file with comments | « no previous file | tests/tpm_lite/redefine_unowned.c » ('j') | tests/tpm_lite/tlcl_tests.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698