summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuigi Semenzato <semenzato@google.com>2011-03-15 15:49:49 -0700
committerLuigi Semenzato <semenzato@google.com>2011-03-15 15:49:49 -0700
commit0d2d13920470b90640b2a60c96b4f369da5c3087 (patch)
tree3447af724d1b41e32ce081888b2d35c119899908
parent99ca3466ba097cceacaff0129e9060578a8fcb20 (diff)
downloadvboot-0d2d13920470b90640b2a60c96b4f369da5c3087.tar.gz
Run TPM timing test to completion instead of stopping at the first error.
Change-Id: Iae764bfeb2c766abb550f338db3d35d1d7eebf1d BUG=433 TEST=compiled and ran. (QA NOTE: no testing required) Review URL: http://codereview.chromium.org/6462013
-rw-r--r--tests/tpm_lite/timing.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/tpm_lite/timing.c b/tests/tpm_lite/timing.c
index 9300d0cc..677b533b 100644
--- a/tests/tpm_lite/timing.c
+++ b/tests/tpm_lite/timing.c
@@ -21,7 +21,7 @@
/* Runs [op] and ensures it returns success and doesn't run longer than
* [time_limit] in milliseconds.
*/
-#define TTPM_CHECK(op, time_limit) do { \
+#define TTPM_CHECK(op, time_limit) do { \
struct timeval before, after; \
int time; \
uint32_t __result; \
@@ -29,7 +29,7 @@
__result = op; \
if (__result != TPM_SUCCESS) { \
printf(#op ": error 0x%x\n", __result); \
- exit(1); \
+ errors++; \
} \
gettimeofday(&after, NULL); \
time = (int) ((after.tv_sec - before.tv_sec) * 1000 + \
@@ -37,15 +37,18 @@
printf(#op ": %d ms\n", time); \
if (time > time_limit) { \
printf(#op " exceeded " #time_limit " ms\n"); \
- exit(1); \
+ time_limit_exceeded = 1; \
} \
} while (0)
int main(int argc, char** argv) {
uint32_t x;
uint8_t in[20], out[20];
+ int time_limit_exceeded = 0;
+ int errors = 0;
TlclLibInit();
+ TTPM_CHECK(0, 50);
TTPM_CHECK(TlclStartupIfNeeded(), 50);
TTPM_CHECK(TlclContinueSelfTest(), 100);
TTPM_CHECK(TlclSelfTestFull(), 1000);
@@ -55,6 +58,11 @@ int main(int argc, char** argv) {
TTPM_CHECK(TlclExtend(0, in, out), 200);
TTPM_CHECK(TlclSetGlobalLock(), 50);
TTPM_CHECK(TlclLockPhysicalPresence(), 100);
- printf("TEST SUCCEEDED\n");
- return 0;
+ if (time_limit_exceeded || errors > 0) {
+ printf("TEST FAILED\n");
+ exit(1);
+ } else {
+ printf("TEST SUCCEEDED\n");
+ return 0;
+ }
}