OLD | NEW |
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 /* Testing: ownership testing code, ForceClear, and nvram write limit. | 6 /* Testing: ownership testing code, ForceClear, and nvram write limit. |
7 */ | 7 */ |
8 | 8 |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 | 10 |
11 #include "tlcl.h" | 11 #include "tlcl.h" |
12 | 12 #include "tlcl_tests.h" |
13 #define CHECK(command) do { \ | 13 #include "utility.h" |
14 uint32_t r = (command); \ | |
15 if (r != 0) { \ | |
16 printf(#command "returned 0x%x\n", r); \ | |
17 } \ | |
18 } while(0) | |
19 | 14 |
20 int main(int argc, char** argv) { | 15 int main(int argc, char** argv) { |
21 uint8_t disable, deactivated; | 16 uint8_t disable, deactivated; |
22 | 17 |
23 TlclLibInit(); | 18 TlclLibInit(); |
24 TlclStartup(); | 19 TPM_CHECK(TlclStartupIfNeeded()); |
25 CHECK(TlclSelfTestFull()); | 20 TPM_CHECK(TlclSelfTestFull()); |
26 | 21 TPM_CHECK(TlclAssertPhysicalPresence()); |
27 CHECK(TlclAssertPhysicalPresence()); | 22 TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL)); |
28 CHECK(TlclGetFlags(&disable, &deactivated, NULL)); | |
29 printf("disable is %d, deactivated is %d\n", disable, deactivated); | 23 printf("disable is %d, deactivated is %d\n", disable, deactivated); |
30 CHECK(TlclSetEnable()); | 24 TPM_CHECK(TlclSetEnable()); |
31 CHECK(TlclSetDeactivated(0)); | 25 TPM_CHECK(TlclSetDeactivated(0)); |
32 CHECK(TlclGetFlags(&disable, &deactivated, NULL)); | 26 TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL)); |
33 printf("disable is %d, deactivated is %d\n", disable, deactivated); | 27 printf("disable is %d, deactivated is %d\n", disable, deactivated); |
34 | 28 if (disable == 1 || deactivated == 1) { |
| 29 error("failed to enable or activate"); |
| 30 } |
| 31 printf("TEST SUCCEEDED\n"); |
35 return 0; | 32 return 0; |
36 } | 33 } |
OLD | NEW |