Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 /* Common definitions for test programs. | 6 /* Common definitions for test programs. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef TLCL_TESTS_H | 9 #ifndef TLCL_TESTS_H |
| 10 #define TLCL_TESTS_H | 10 #define TLCL_TESTS_H |
| 11 | 11 |
| 12 /* Standard testing indexes. */ | 12 /* Standard testing indexes. */ |
| 13 #define INDEX0 0xcafe | 13 #define INDEX0 0xcafe |
| 14 #define INDEX1 0xcaff | 14 #define INDEX1 0xcaff |
| 15 | 15 |
| 16 #define DO_ON_FAILURE(tpm_command, action) do { \ | 16 /* Prints error and returns on failure */ |
| 17 uint32_t result; \ | 17 #define TPM_CHECK(tpm_command) TPM_EXPECT(tpm_command, TPM_SUCCESS) |
| 18 if ((result = (tpm_command)) != TPM_SUCCESS) { \ | |
| 19 action; \ | |
| 20 } \ | |
| 21 } while (0) | |
| 22 | 18 |
| 23 /* Prints error and returns on failure */ | 19 #define TPM_EXPECT(tpm_command, expected_result) do { \ |
| 24 #define TPM_CHECK(tpm_command) \ | 20 uint32_t _result; \ |
| 25 DO_ON_FAILURE(tpm_command, \ | 21 if ((_result = (tpm_command)) != expected_result) { \ |
|
Randall Spangler
2011/02/04 16:35:59
Minor nit: (expected_result)
(guard macro expansi
| |
| 26 printf("TEST FAILED: line %d: " #tpm_command ": 0x%x\n", \ | 22 printf("TEST FAILED: line %d: " #tpm_command ": 0x%x\n", \ |
| 27 __LINE__, result); return result) | 23 __LINE__, _result); \ |
|
Randall Spangler
2011/02/04 16:35:59
While we're making things more elegant, could prin
| |
| 24 return _result; \ | |
| 25 } \ | |
| 26 } while (0) | |
| 27 | |
| 28 | 28 |
| 29 /* Executes TlclStartup(), but ignores POSTINIT error if the | 29 /* Executes TlclStartup(), but ignores POSTINIT error if the |
| 30 * TLCL_RESILIENT_STARTUP environment variable is set. | 30 * TLCL_RESILIENT_STARTUP environment variable is set. |
| 31 */ | 31 */ |
| 32 uint32_t TlclStartupIfNeeded(void); | 32 uint32_t TlclStartupIfNeeded(void); |
| 33 | 33 |
| 34 #endif // TLCL_TESTS_H | 34 #endif // TLCL_TESTS_H |
| OLD | NEW |