diff options
Diffstat (limited to 'tests/tpm_lite/tpmtest_timing.c')
-rw-r--r-- | tests/tpm_lite/tpmtest_timing.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/tests/tpm_lite/tpmtest_timing.c b/tests/tpm_lite/tpmtest_timing.c index 677b533b..d86b4eee 100644 --- a/tests/tpm_lite/tpmtest_timing.c +++ b/tests/tpm_lite/tpmtest_timing.c @@ -21,48 +21,48 @@ /* Runs [op] and ensures it returns success and doesn't run longer than * [time_limit] in milliseconds. */ -#define TTPM_CHECK(op, time_limit) do { \ - struct timeval before, after; \ - int time; \ - uint32_t __result; \ - gettimeofday(&before, NULL); \ - __result = op; \ - if (__result != TPM_SUCCESS) { \ - printf(#op ": error 0x%x\n", __result); \ - errors++; \ - } \ - gettimeofday(&after, NULL); \ - time = (int) ((after.tv_sec - before.tv_sec) * 1000 + \ - (after.tv_usec - before.tv_usec) / 1000); \ - printf(#op ": %d ms\n", time); \ - if (time > time_limit) { \ - printf(#op " exceeded " #time_limit " ms\n"); \ - time_limit_exceeded = 1; \ - } \ - } while (0) +#define TTPM_CHECK(op, time_limit) do { \ + struct timeval before, after; \ + int time; \ + uint32_t __result; \ + gettimeofday(&before, NULL); \ + __result = op; \ + if (__result != TPM_SUCCESS) { \ + printf(#op ": error 0x%x\n", __result); \ + errors++; \ + } \ + gettimeofday(&after, NULL); \ + time = (int) ((after.tv_sec - before.tv_sec) * 1000 + \ + (after.tv_usec - before.tv_usec) / 1000); \ + printf(#op ": %d ms\n", time); \ + if (time > time_limit) { \ + printf(#op " exceeded " #time_limit " ms\n"); \ + 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; + 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); - TTPM_CHECK(TlclAssertPhysicalPresence(), 100); - TTPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)), 100); - TTPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)), 100); - TTPM_CHECK(TlclExtend(0, in, out), 200); - TTPM_CHECK(TlclSetGlobalLock(), 50); - TTPM_CHECK(TlclLockPhysicalPresence(), 100); - if (time_limit_exceeded || errors > 0) { - printf("TEST FAILED\n"); - exit(1); - } else { - printf("TEST SUCCEEDED\n"); - return 0; - } + TlclLibInit(); + TTPM_CHECK(0, 50); + TTPM_CHECK(TlclStartupIfNeeded(), 50); + TTPM_CHECK(TlclContinueSelfTest(), 100); + TTPM_CHECK(TlclSelfTestFull(), 1000); + TTPM_CHECK(TlclAssertPhysicalPresence(), 100); + TTPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)), 100); + TTPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)), 100); + TTPM_CHECK(TlclExtend(0, in, out), 200); + TTPM_CHECK(TlclSetGlobalLock(), 50); + TTPM_CHECK(TlclLockPhysicalPresence(), 100); + if (time_limit_exceeded || errors > 0) { + printf("TEST FAILED\n"); + exit(1); + } else { + printf("TEST SUCCEEDED\n"); + return 0; + } } |