Index: tests/tpm_lite/timing.c |
diff --git a/tests/tpm_lite/timing.c b/tests/tpm_lite/timing.c |
index 9300d0ccaace68b1dc9a6f1d6d7a5a2a1e9600d7..677b533b489e82ca553da97816ed3882c1e87dac 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; |
+ } |
} |