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

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

Issue 6462013: Run TPM timing test to completion instead of stopping at the first error. (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 | no next file » | no next file with comments »
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 /* Timing test for various TPM operations. This is mostly a sanity check to 6 /* Timing test for various TPM operations. This is mostly a sanity check to
7 * make sure the part doesn't have ridicolously bad timing on simple 7 * make sure the part doesn't have ridicolously bad timing on simple
8 * operations. 8 * operations.
9 */ 9 */
10 10
(...skipping 10 matching lines...) Expand all
21 /* Runs [op] and ensures it returns success and doesn't run longer than 21 /* Runs [op] and ensures it returns success and doesn't run longer than
22 * [time_limit] in milliseconds. 22 * [time_limit] in milliseconds.
23 */ 23 */
24 #define TTPM_CHECK(op, time_limit) do { \ 24 #define TTPM_CHECK(op, time_limit) do { \
25 struct timeval before, after; \ 25 struct timeval before, after; \
26 int time; \ 26 int time; \
27 uint32_t __result; \ 27 uint32_t __result; \
28 gettimeofday(&before, NULL); \ 28 gettimeofday(&before, NULL); \
29 __result = op; \ 29 __result = op; \
30 if (__result != TPM_SUCCESS) { \ 30 if (__result != TPM_SUCCESS) { \
31 printf(#op ": error 0x%x\n", __result); \ 31 printf(#op ": error 0x%x\n", __result); \
Randall Spangler 2011/02/08 23:03:44 Suggest incrementing an errors count here. errors
32 exit(1); \
33 } \ 32 } \
34 gettimeofday(&after, NULL); \ 33 gettimeofday(&after, NULL); \
35 time = (int) ((after.tv_sec - before.tv_sec) * 1000 + \ 34 time = (int) ((after.tv_sec - before.tv_sec) * 1000 + \
36 (after.tv_usec - before.tv_usec) / 1000); \ 35 (after.tv_usec - before.tv_usec) / 1000); \
37 printf(#op ": %d ms\n", time); \ 36 printf(#op ": %d ms\n", time); \
38 if (time > time_limit) { \ 37 if (time > time_limit) { \
39 printf(#op " exceeded " #time_limit " ms\n"); \ 38 printf(#op " exceeded " #time_limit " ms\n"); \
40 exit(1); \ 39 time_limit_exceeded = 1; \
41 } \ 40 } \
42 } while (0) 41 } while (0)
43 42
44 int main(int argc, char** argv) { 43 int main(int argc, char** argv) {
45 uint32_t x; 44 uint32_t x;
46 uint8_t in[20], out[20]; 45 uint8_t in[20], out[20];
46 int time_limit_exceeded = 0;
47 47
Randall Spangler 2011/02/08 23:03:44 int errors = 0;
48 TlclLibInit(); 48 TlclLibInit();
49 TTPM_CHECK(0, 50);
49 TTPM_CHECK(TlclStartupIfNeeded(), 50); 50 TTPM_CHECK(TlclStartupIfNeeded(), 50);
50 TTPM_CHECK(TlclContinueSelfTest(), 100); 51 TTPM_CHECK(TlclContinueSelfTest(), 100);
51 TTPM_CHECK(TlclSelfTestFull(), 1000); 52 TTPM_CHECK(TlclSelfTestFull(), 1000);
52 TTPM_CHECK(TlclAssertPhysicalPresence(), 100); 53 TTPM_CHECK(TlclAssertPhysicalPresence(), 100);
53 TTPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)), 100); 54 TTPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)), 100);
54 TTPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)), 100); 55 TTPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)), 100);
55 TTPM_CHECK(TlclExtend(0, in, out), 200); 56 TTPM_CHECK(TlclExtend(0, in, out), 200);
56 TTPM_CHECK(TlclSetGlobalLock(), 50); 57 TTPM_CHECK(TlclSetGlobalLock(), 50);
57 TTPM_CHECK(TlclLockPhysicalPresence(), 100); 58 TTPM_CHECK(TlclLockPhysicalPresence(), 100);
58 printf("TEST SUCCEEDED\n"); 59 if (time_limit_exceeded) {
Randall Spangler 2011/02/08 23:03:44 if (time_limit_exceeded || errors > 0) This way y
59 return 0; 60 printf("TEST FAILED\n");
61 exit(1);
62 } else {
63 printf("TEST SUCCEEDED\n");
64 return 0;
65 }
60 } 66 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698