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

Unified Diff: tests/tpm_lite/timing.c

Issue 6719005: Cherry-pick vboot_reference files from TOT to support crossystem (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@0.11.257.B
Patch Set: Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « host/lib/crossystem.c ('k') | tests/vboot_nvstorage_test.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ }
}
« no previous file with comments | « host/lib/crossystem.c ('k') | tests/vboot_nvstorage_test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698